@@ 7,7 7,8 @@ import std/asyncdispatch, std/httpclient, std/json
const spofNodeList* = "https://nodes.tox.chat/json"
-proc bootstrapFromSpof*(tox: Tox) {.async.} =
+proc bootstrapFromSpof*(tox: Tox; ipv4 = true; ipv6 = true) {.async.} =
+ assert(ipv4 or ipv6)
let
http = newAsyncHttpClient()
txt = await http.getContent(spofNodeList)
@@ 16,13 17,13 @@ proc bootstrapFromSpof*(tox: Tox) {.async.} =
for num, node in js.pairs:
try:
let
- ipv4 = node["ipv4"].getStr("-")
- ipv6 = node["ipv6"].getStr("-")
+ ip4 = node["ipv4"].getStr("-")
+ ip6 = node["ipv6"].getStr("-")
port = node["port"].getInt(toxcore.defaultPort.int).uint16
key = node["public_key"].getStr.toPublicKey
- if ipv4 != "-":
- tox.bootstrap(ipv4, key, port)
- if ipv6 != "-":
- tox.bootstrap(ipv6, key, port)
+ if ipv4 and ip4 != "-":
+ tox.bootstrap(ip4, key, port)
+ if ipv6 and ip6 != "-":
+ tox.bootstrap(ip6, key, port)
except:
discard