Commit 9df46a5b authored by nanahira's avatar nanahira

fix error stuck

parent 6676b083
...@@ -135,6 +135,12 @@ export class Attacker { ...@@ -135,6 +135,12 @@ export class Attacker {
return null; return null;
} }
async close() {
return new Promise<void>((done) => {
this.socket.close(done);
});
}
async attack(): Promise<string> { async attack(): Promise<string> {
this.socket = dgram.createSocket('udp4'); this.socket = dgram.createSocket('udp4');
let err: string = null; let err: string = null;
...@@ -157,6 +163,7 @@ export class Attacker { ...@@ -157,6 +163,7 @@ export class Attacker {
}); });
for (const step of AttackRoutine) { for (const step of AttackRoutine) {
if (this.error) { if (this.error) {
await this.close();
return `Error: ${this.error.toString()}`; return `Error: ${this.error.toString()}`;
} }
err = await this.performStep(step); err = await this.performStep(step);
...@@ -164,9 +171,7 @@ export class Attacker { ...@@ -164,9 +171,7 @@ export class Attacker {
break; break;
} }
} }
await new Promise<void>((done) => { await this.close();
this.socket.close(done);
});
return err; return err;
} }
} }
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