-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtraceroute.uc
More file actions
executable file
·71 lines (63 loc) · 1.78 KB
/
Copy pathtraceroute.uc
File metadata and controls
executable file
·71 lines (63 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import * as message from "message";
import * as router from "router";
import * as node from "node";
const ROUTE_SIZE = 8;
export function setup(config)
{
};
export function tick()
{
};
export function process(msg)
{
if (msg.data?.traceroute) {
const traceroute = msg.data.traceroute;
let routes;
let snrs;
if (msg.data.request_id) {
// Back
routes = traceroute.route_back;
snrs = traceroute.snr_back;
}
else {
// Toward
routes = traceroute.route;
snrs = traceroute.snr_towards;
}
// Fill in missing traceroute pieces (from nodes which dont support this?)
if (msg.hop_start && msg.hop_limit && msg.hop_limit <= msg.hop_start) {
const rdiff = msg.hop_start - msg.hop_limit - length(routes);
for (let i = 0; i < rdiff; i++) {
if (length(routes) < ROUTE_SIZE) {
push(routes, node.BROADCAST);
}
}
const sdiff = length(routes) - length(snrs);
for (let i = 0; i < sdiff; i++) {
if (length(snrs) < ROUTE_SIZE) {
push(snrs, -128);
}
}
}
if (length(snrs) < ROUTE_SIZE) {
push(snrs, 0); // snr == 0
}
if (!node.toMe(msg)) {
if (length(routes) < ROUTE_SIZE) {
push(routes, node.id());
}
}
else {
router.queue(
message.createMessage(msg.from, msg.to, msg.namekey, "traceroute", traceroute, {
data: {
request_id: msg.id
}
})
);
}
}
};
export function cmd(msg, reply)
{
};