diff --git a/.pinned b/.pinned index f85d7a2..3397fbb 100644 --- a/.pinned +++ b/.pinned @@ -1,16 +1,16 @@ -bearssl;https://github.com/status-im/nim-bearssl@#25009951ff8e0006171d566e3c7dc73a8231c2ed +bearssl;https://github.com/status-im/nim-bearssl@#f4c4233de453cb7eac0ce3f3ffad6496295f83ab chronicles;https://github.com/status-im/nim-chronicles@#32ac8679680ea699f7dbc046e8e0131cac97d41a -chronos;https://github.com/status-im/nim-chronos@#41b82cdea34744148600b67a9154331b76181189 -dnsclient;https://github.com/ba0f3/dnsclient.nim@#4960de2b345f567b12f09a08e9967af104ab39a3 -faststreams;https://github.com/status-im/nim-faststreams@#49e2c52eb5dda46b1c9c10d079abe7bffe6cea89 -httputils;https://github.com/status-im/nim-http-utils@#f83fbce4d6ec7927b75be3f85e4fa905fcb69788 +chronos;https://github.com/status-im/nim-chronos@#9df76c39df254c7ff0cec6dec5c9f345f2819c91 +dnsclient;https://github.com/ba0f3/dnsclient.nim@#6647ca8bd9ffcc13adaecb9cb6453032063967db +faststreams;https://github.com/status-im/nim-faststreams@#6112432b3a81d9db116cd5d64c39648881cfff29 +httputils;https://github.com/status-im/nim-http-utils@#e88e231dfcef4585fe3b2fbd9b664dbd28a88040 json_serialization;https://github.com/status-im/nim-json-serialization@#e5b18fb710c3d0167ec79f3b892f5a7a1bc6d1a4 -metrics;https://github.com/status-im/nim-metrics@#9070af9c830e93e5239ddc488cd65aa6f609ba73 +metrics;https://github.com/status-im/nim-metrics@#0a6477268e850d7bc98347b3875301524871765f nimcrypto;https://github.com/cheatfate/nimcrypto@#24e006df85927f64916e60511620583b11403178 -secp256k1;https://github.com/status-im/nim-secp256k1@#5340cf188168d6afcafc8023770d880f067c0b2f +secp256k1;https://github.com/status-im/nim-secp256k1@#c7f1a37d9b0f17292649bfed8bf6cef83cf4221f serialization;https://github.com/status-im/nim-serialization@#493d18b8292fc03aa4f835fd825dea1183f97466 -stew;https://github.com/status-im/nim-stew@#598246620da5c41d0e92a8dd6aab0755381b21cd +stew;https://github.com/status-im/nim-stew@#f2e58ba4c8da65548c824e4fa8732db9739f6505 testutils;https://github.com/status-im/nim-testutils@#dfc4c1b39f9ded9baf6365014de2b4bfb4dafc34 unittest2;https://github.com/status-im/nim-unittest2@#f180f596c88dfd266f746ed6f8dbebce39c824db -websock;https://github.com/status-im/nim-websock@#8a72c0f7690802753b1d59887745b1ce1f0c8b3d +websock;https://github.com/status-im/nim-websock@#2424f2b215c0546f97d8b147e21544521c7545b0 zlib;https://github.com/status-im/nim-zlib@#6a6670afba6b97b29b920340e2641978c05ab4d8 \ No newline at end of file diff --git a/libp2p.nimble b/libp2p.nimble index bc83ef8..eb661d8 100644 --- a/libp2p.nimble +++ b/libp2p.nimble @@ -9,7 +9,7 @@ skipDirs = @["tests", "examples", "Nim", "tools", "scripts", "docs"] requires "nim >= 1.2.0", "nimcrypto >= 0.4.1", - "dnsclient >= 0.1.2", + "dnsclient >= 0.3.0 & < 0.4.0", "bearssl >= 0.1.4", "chronicles >= 0.10.2", "chronos >= 3.0.6", diff --git a/libp2p/nameresolving/dnsresolver.nim b/libp2p/nameresolving/dnsresolver.nim index 51be456..a638b25 100644 --- a/libp2p/nameresolving/dnsresolver.nim +++ b/libp2p/nameresolving/dnsresolver.nim @@ -14,7 +14,7 @@ else: import std/[streams, strutils, sets, sequtils], - chronos, chronicles, + chronos, chronicles, stew/byteutils, dnsclientpkg/[protocol, types] import @@ -76,15 +76,11 @@ proc getDnsResponse( if not receivedDataFuture.finished: raise newException(IOError, "DNS server timeout") - var - rawResponse = sock.getMessage() - dataStream = newStringStream() - dataStream.writeData(addr rawResponse[0], rawResponse.len) - dataStream.setPosition(0) + let rawResponse = sock.getMessage() # parseResponse can has a raises: [Exception, ..] because of # https://github.com/nim-lang/Nim/commit/035134de429b5d99c5607c5fae912762bebb6008 # it can't actually raise though - return parseResponse(dataStream) + return parseResponse(string.fromBytes(rawResponse)) except CatchableError as exc: raise exc except Exception as exc: raiseAssert exc.msg finally: @@ -118,7 +114,14 @@ method resolveIp*( try: let resp = await fut for answer in resp.answers: - resolvedAddresses.incl(answer.toString()) + # toString can has a raises: [Exception, ..] because of + # https://github.com/nim-lang/Nim/commit/035134de429b5d99c5607c5fae912762bebb6008 + # it can't actually raise though + resolvedAddresses.incl( + try: answer.toString() + except CatchableError as exc: raise exc + except Exception as exc: raiseAssert exc.msg + ) except CancelledError as e: raise e except ValueError as e: @@ -158,6 +161,11 @@ method resolveTxt*( self.nameServers.add(self.nameServers[0]) self.nameServers.delete(0) continue + except Exception as e: + # toString can has a raises: [Exception, ..] because of + # https://github.com/nim-lang/Nim/commit/035134de429b5d99c5607c5fae912762bebb6008 + # it can't actually raise though + raiseAssert e.msg debug "Failed to resolve TXT, returning empty set" return @[]