Skip to content

Commit 3272f12

Browse files
authored
fix: generate better random HTTP resource content (#267)
1 parent 37b166d commit 3272f12

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/programs/http_client.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ const RESOURCE_MAP_SIZES = new Map([
2323

2424
function generateResource(size: number): Uint8Array {
2525
const resource = new Uint8Array(size);
26+
const characters =
27+
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
2628
for (let i = 0; i < size; i++) {
27-
resource[i] = Math.floor(Math.random() * 256);
29+
resource[i] = characters.charCodeAt(
30+
Math.floor(Math.random() * characters.length),
31+
);
2832
}
2933
return resource;
3034
}
@@ -79,7 +83,7 @@ export class HttpClient extends ProgramBase {
7983
// Encode HTTP request
8084
// NOTE: For now, as hosts have just one interface, destination ip is hardcoded
8185
const httpRequest = getContentRequest(
82-
this.runner.interfaces[0].toString(),
86+
this.runner.interfaces[0].ip.toString(),
8387
this.resource,
8488
);
8589

0 commit comments

Comments
 (0)