-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Notice that I had to adapt to use 'rlpx_connected_peers' instead of 'connected_peers' in 'wakunode1.nim' because due to the update of the 'vendor/nim-eth', which adds the dependency-break with 'confutils' but also includes another changes. Aside note: we cannot have 'confutils' dependency in 'nim-eth' because that will prevent the generation of any waku dynamic library.
- Loading branch information
1 parent
e1e4ff3
commit aabfc4c
Showing
12 changed files
with
100 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule nim-eth
updated
67 files
Submodule nim-secp256k1
updated
20 files
+0 −41 | .appveyor.yml | |
+1 −1 | .github/workflows/ci.yml | |
+2 −0 | .gitignore | |
+2 −2 | .gitmodules | |
+0 −27 | .travis.yml | |
+0 −2 | README.md | |
+14 −18 | ci/Jenkinsfile | |
+0 −25 | nimble.lock | |
+171 −28 | secp256k1.nim | |
+4 −3 | secp256k1.nimble | |
+231 −24 | secp256k1/abi.nim | |
+0 −347 | secp256k1_wrapper/README.md | |
+0 −1,163 | secp256k1_wrapper/ecmult_static_context.h | |
+0 −13 | secp256k1_wrapper/gen.sh | |
+0 −118 | secp256k1_wrapper/libsecp256k1-config.h | |
+0 −1 | secp256k1_wrapper/secp256k1 | |
+50 −1 | tests/test_secp256k1.nim | |
+14 −0 | tests/test_secp256k1_abi.nim | |
+3 −0 | vendor/README.md | |
+1 −0 | vendor/secp256k1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,67 @@ | ||
|
||
when (NimMajor, NimMinor) < (1, 4): | ||
{.push raises: [Defect].} | ||
else: | ||
{.push raises: [].} | ||
|
||
import | ||
std/[strutils, options], | ||
chronicles, stew/shims/net as stewNet, | ||
eth/net/nat | ||
std/[options, strutils] | ||
import | ||
chronicles, | ||
eth/net/nat, | ||
stew/results, | ||
stew/shims/net, | ||
nativesockets | ||
|
||
logScope: | ||
topics = "nat" | ||
|
||
proc setupNat*(natConf, clientId: string, tcpPort, udpPort: Port): | ||
tuple[ip: Option[ValidIpAddress], | ||
tcpPort: Option[Port], | ||
udpPort: Option[Port]] {.gcsafe, deprecated: | ||
"Unsafe: this proc quits the app if something is not ok".} = | ||
proc setupNat*(natConf, clientId: string, | ||
tcpPort, udpPort: Port): | ||
Result[tuple[ip: Option[ValidIpAddress], | ||
tcpPort: Option[Port], | ||
udpPort: Option[Port]], string] | ||
{.gcsafe.} = | ||
|
||
var | ||
endpoint: tuple[ip: Option[ValidIpAddress], | ||
tcpPort: Option[Port], | ||
udpPort: Option[Port]] | ||
nat: NatStrategy | ||
let strategy = case natConf.toLowerAscii(): | ||
of "any": NatAny | ||
of "none": NatNone | ||
of "upnp": NatUpnp | ||
of "pmp": NatPmp | ||
else: NatNone | ||
|
||
case natConf.toLowerAscii: | ||
of "any": | ||
nat = NatAny | ||
of "none": | ||
nat = NatNone | ||
of "upnp": | ||
nat = NatUpnp | ||
of "pmp": | ||
nat = NatPmp | ||
else: | ||
if natConf.startsWith("extip:"): | ||
try: | ||
# any required port redirection is assumed to be done by hand | ||
endpoint.ip = some(ValidIpAddress.init(natConf[6..^1])) | ||
nat = NatNone | ||
except ValueError: | ||
error "not a valid IP address", address = natConf[6..^1] | ||
quit QuitFailure | ||
else: | ||
error "not a valid NAT mechanism", value = natConf | ||
quit QuitFailure | ||
var endpoint: tuple[ip: Option[ValidIpAddress], tcpPort: Option[Port], udpPort: Option[Port]] | ||
|
||
if nat != NatNone: | ||
let extIp = getExternalIP(nat) | ||
if extIP.isSome: | ||
endpoint.ip = some(ValidIpAddress.init extIp.get) | ||
# TODO redirectPorts in considered a gcsafety violation | ||
if strategy != NatNone: | ||
let extIp = getExternalIP(strategy) | ||
if extIP.isSome(): | ||
endpoint.ip = some(ValidIpAddress.init(extIp.get())) | ||
# RedirectPorts in considered a gcsafety violation | ||
# because it obtains the address of a non-gcsafe proc? | ||
var extPorts: Option[(Port, Port)] | ||
try: | ||
extPorts = ({.gcsafe.}: | ||
redirectPorts(tcpPort = tcpPort, | ||
udpPort = udpPort, | ||
description = clientId)) | ||
except Exception: | ||
# @TODO: nat.nim Error: can raise an unlisted exception: Exception. Isolate here for now. | ||
extPorts = ({.gcsafe.}: redirectPorts(tcpPort = tcpPort, | ||
udpPort = udpPort, | ||
description = clientId)) | ||
except CatchableError: | ||
# TODO: nat.nim Error: can raise an unlisted exception: Exception. Isolate here for now. | ||
error "unable to determine external ports" | ||
extPorts = none((Port, Port)) | ||
|
||
if extPorts.isSome: | ||
if extPorts.isSome(): | ||
let (extTcpPort, extUdpPort) = extPorts.get() | ||
endpoint.tcpPort = some(extTcpPort) | ||
endpoint.udpPort = some(extUdpPort) | ||
|
||
return endpoint | ||
else: # NatNone | ||
if not natConf.startsWith("extip:"): | ||
return err("not a valid NAT mechanism: " & $natConf) | ||
|
||
try: | ||
# any required port redirection is assumed to be done by hand | ||
endpoint.ip = some(ValidIpAddress.init(natConf[6..^1])) | ||
except ValueError: | ||
return err("not a valid IP address: " & $natConf[6..^1]) | ||
|
||
return ok(endpoint) | ||
|
Oops, something went wrong.