Skip to content

Commit daa3ea8

Browse files
committed
pi: allow user to set ttl from UI
1 parent c83e80f commit daa3ea8

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

statics/js/components/inject-form.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ Vue.component('inject-form', {
100100
<label for="inject-interval">Interval in milliseconds</label>\
101101
<input id="inject-interval" type="number" class="form-control input-sm" v-model.number="interval" min="0" />\
102102
</div>\
103+
<div class="form-group">\
104+
<label for="ttl">Time To Live (TTL)</label>\
105+
<input id="ttl" type="number" class="form-control input-sm" v-model.number="ttl" min="0" max="255" />\
106+
</div>\
103107
<button type="submit" id="inject" class="btn btn-primary">Inject</button>\
104108
<button type="button" class="btn btn-danger" @click="reset">Reset</button>\
105109
</form>\
@@ -127,6 +131,7 @@ Vue.component('inject-form', {
127131
mode: "random",
128132
payload: "",
129133
incrementPayload: 0,
134+
ttl: 64,
130135
};
131136
},
132137

@@ -242,6 +247,7 @@ Vue.component('inject-form', {
242247
this.srcMAC = this.dstMAC = "";
243248
this.mode = "random";
244249
this.payload = "";
250+
this.ttl = 64;
245251
},
246252

247253
inject: function() {
@@ -253,8 +259,8 @@ Vue.component('inject-form', {
253259
if (this.mode == "random") {
254260
this.payload = "x".repeat(this.payloadlength);
255261
}
256-
var ttl = this.interval*this.count;
257-
var headers = {"X-Resource-TTL": ttl + 5000 + "ms"};
262+
var requestTTL = this.interval*this.count;
263+
var headers = {"X-Resource-TTL": requestTTL + 5000 + "ms"};
258264
$.ajax({
259265
dataType: "json",
260266
url: '/api/injectpacket',
@@ -274,6 +280,7 @@ Vue.component('inject-form', {
274280
"Interval": this.interval,
275281
"Payload": this.payload,
276282
"IncrementPayload": this.incrementPayload,
283+
"TTL": this.ttl,
277284
}),
278285
headers: headers,
279286
contentType: "application/json; charset=utf-8",

0 commit comments

Comments
 (0)