Need a quick route to a particular destination? I’ve created a script that’ll give you the directions.
No more feeling like a lost tourist looking for a node again.
Начиная
This is something of a shortcut to finding some of those harder-to-reach nodes.
You might think your version 2 of the scan-analyzer might give you a way to directly connect to every node… подумай еще раз.
The scanner only goes to a range of 10 nodes and no further, which means finding the more distant nodes (до *13* hops from home!) requires actually going a bit into the wilds and connecting further in before attempting that scan again.
I created this utility to find a path to those distant places, and to make it easier, even create a string you can cut and paste right into your terminal to take you right there.
Примечание, I’m not going to give away server names here.. that’s more an exercise for the reader.
Сценарий
/** @парам {НС} нс **/ экспортировать асинхронную функцию main(нс) { ns.disableLog("ВСЕ"); нс.хвост(); var src = ns.getHostname(); var tgt = ns.args[0]; var servers = {}; var queue = [src]; var route = [tgt]; var ptr = tgt; серверы[src] = "START"; пока (queue.length) { var s = queue.pop(); var links = ns.scan(с); для (были в = 0; я < links.length; я++) { если (!серверы[ссылки[я]]) { queue.push(ссылки); серверы[ссылки[я]] = s; } }; } пока (ptr != src) { ptr = servers[ptr]; route.push(ptr); } route.pop(); нс.принт("соединять " + route.reverse().присоединиться("; соединять ")); }[/код]
Example Usage
From home to omega-net,
[home ~/]> run find.ns omega-net
It will give you this in a window:
connect harakiri-sushi; connect max-hardware; connect omega-net
Это все, чем мы делимся сегодня для этого. Битбернер гид. Это руководство было первоначально создано и написано WhiskeyFur. На случай, если нам не удастся обновить это руководство, вы можете найти последнее обновление, следуя этому связь.
Should be
queue.толкать(ссылки[я]);