Commit 624e7ea8 authored by nanahira's avatar nanahira

error handle

parent e82382b0
...@@ -65,12 +65,14 @@ export class Attacker { ...@@ -65,12 +65,14 @@ export class Attacker {
port: number; port: number;
timeout: number; timeout: number;
socket: dgram.Socket; socket: dgram.Socket;
error: any;
currentWait: (msg: Buffer, rinfo: any) => void; currentWait: (msg: Buffer, rinfo: any) => void;
constructor(address: string, port: number, timeout: number) { constructor(address: string, port: number, timeout: number) {
this.address = address; this.address = address;
this.port = port; this.port = port;
this.timeout = timeout; this.timeout = timeout;
this.currentWait = null; this.currentWait = null;
this.error = null;
} }
sendMessage(message: number[]): Promise<any> { sendMessage(message: number[]): Promise<any> {
return new Promise(done => { return new Promise(done => {
...@@ -142,8 +144,14 @@ export class Attacker { ...@@ -142,8 +144,14 @@ export class Attacker {
if (this.currentWait) { if (this.currentWait) {
this.currentWait(msg, rinfo); this.currentWait(msg, rinfo);
} }
});
this.socket.on("error", (err) => {
this.error = err;
}) })
for (let step of AttackRoutine) { for (let step of AttackRoutine) {
if (this.error) {
return `Error: ${this.error.toString()}`;
}
err = await this.performStep(step); err = await this.performStep(step);
if (err) { if (err) {
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment