diff --git a/.env.example b/.env.example index 3d58168..176f267 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,6 @@ ACTIVE_SIGNING_KEY=5K... ACCOUNT=acc... NODE_IP=... +# If your public ports are different from your node config.js ports (requires NAT/port forwarding) +#RPCNODEPORT=15000 +#P2PPORT=15001 diff --git a/witness_action.js b/witness_action.js index 4117a8c..1a584de 100644 --- a/witness_action.js +++ b/witness_action.js @@ -12,6 +12,10 @@ const { rpcNodePort, p2pPort, streamNodes, chainId, } = config; +// For external NATed-ports customization +const extRPCNodePort = Number(String(process.env.RPCNODEPORT)) || rpcNodePort; +const extP2PPort = Number(String(process.env.P2PPORT)) || p2pPort; + function broadcastWitnessAction(contractAction, contractPayload) { const client = new dhive.Client(streamNodes[0]); const transaction = { @@ -46,8 +50,8 @@ program .command('register') .action(() => broadcastWitnessAction('register', { IP: ip, - RPCPort: rpcNodePort, - P2PPort: p2pPort, + RPCPort: extRPCNodePort, + P2PPort: extP2PPort, signingKey: publicSigningKey, enabled: true, })); @@ -56,8 +60,8 @@ program .command('unregister') .action(() => broadcastWitnessAction('register', { IP: ip, - RPCPort: rpcNodePort, - P2PPort: p2pPort, + RPCPort: extRPCNodePort, + P2PPort: extP2PPort, signingKey: publicSigningKey, enabled: false, }));