allow setting advertised external ip

* detect it in start.sh
This commit is contained in:
Jacek Sieka 2019-03-18 21:57:19 -06:00 committed by zah
parent 2bc632c29b
commit d7f972a47e
3 changed files with 16 additions and 2 deletions

View File

@ -60,6 +60,10 @@ type
desc: "UDP listening port",
defaultValue: config.defaultPort().}: int
nat* {.
desc: "Specify method to use for determining public address. Must be one of: any, extip:<IP>"
defaultValue: "any" .}: string
validators* {.
required
desc: "Path to a validator private key, as generated by validator_keygen"

View File

@ -1,5 +1,5 @@
import
options, chronos, json_serialization,
options, chronos, json_serialization, strutils,
spec/digest, version, conf
const
@ -19,6 +19,14 @@ when useRLPx:
template libp2pProtocol*(name, version: string) {.pragma.}
func parseNat(nat: string): IpAddress =
# TODO we should try to discover the actual external IP, in case we're
# behind a nat / upnp / etc..
if nat.startsWith("extip:"):
parseIpAddress(nat[6..^1])
else:
parseIpAddress("127.0.0.1")
proc writeValue*(writer: var JsonWriter, value: BootstrapAddr) {.inline.} =
writer.writeValue $value
@ -36,7 +44,7 @@ when useRLPx:
let
keys = KeyPair(seckey: privKey, pubkey: privKey.getPublicKey())
address = Address(ip: parseIpAddress("127.0.0.1"),
address = Address(ip: parseNat(conf.nat),
tcpPort: Port conf.tcpPort,
udpPort: Port conf.udpPort)

View File

@ -14,6 +14,7 @@ DATA_DIR=$SIMULATION_DIR/node-${1}
V_PREFIX="$VALIDATORS_DIR/v$(printf '%06d' ${1})"
PORT=$(printf '5%04d' ${1})
MYIP=$(curl -s ifconfig.me)
$BEACON_NODE_BIN \
--network:ephemeralNetwork \
@ -30,5 +31,6 @@ $BEACON_NODE_BIN \
--validator:${V_PREFIX}9.privkey \
--tcpPort:$PORT \
--udpPort:$PORT \
--nat:extip:$MYIP \
--stateSnapshot:$SNAPSHOT_FILE \
$BOOTSTRAP_NODES_FLAG