@@ -34,26 +34,26 @@ import (
3434 "bitbucket.org/kardianos/osext"
3535 "github.com/ethereum/go-ethereum/crypto"
3636 "github.com/ethereum/go-ethereum/logger"
37+ "github.com/ethereum/go-ethereum/p2p/nat"
3738 "github.com/ethereum/go-ethereum/vm"
3839)
3940
4041var (
4142 Identifier string
4243 KeyRing string
4344 KeyStore string
44- PMPGateway string
4545 StartRpc bool
4646 StartWebSockets bool
4747 RpcPort int
4848 WsPort int
49- NatType string
5049 OutboundPort string
5150 ShowGenesis bool
5251 AddPeer string
5352 MaxPeer int
5453 GenAddr bool
5554 BootNodes string
5655 NodeKey * ecdsa.PrivateKey
56+ NAT nat.Interface
5757 SecretFile string
5858 ExportDir string
5959 NonInteractive bool
@@ -117,7 +117,6 @@ func Init() {
117117 flag .BoolVar (& StartWebSockets , "ws" , false , "start websocket server" )
118118 flag .BoolVar (& NonInteractive , "y" , false , "non-interactive mode (say yes to confirmations)" )
119119 flag .BoolVar (& GenAddr , "genaddr" , false , "create a new priv/pub key" )
120- flag .StringVar (& NatType , "nat" , "" , "NAT support (UPNP|PMP) (none)" )
121120 flag .StringVar (& SecretFile , "import" , "" , "imports the file given (hex or mnemonic formats)" )
122121 flag .StringVar (& ExportDir , "export" , "" , "exports the session keyring to files in the directory given" )
123122 flag .StringVar (& LogFile , "logfile" , "" , "log file (defaults to standard output)" )
@@ -132,15 +131,18 @@ func Init() {
132131 var (
133132 nodeKeyFile = flag .String ("nodekey" , "" , "network private key file" )
134133 nodeKeyHex = flag .String ("nodekeyhex" , "" , "network private key (for testing)" )
134+ natstr = flag .String ("nat" , "any" , "port mapping mechanism (any|none|upnp|pmp|extip:<IP>)" )
135135 )
136136 flag .StringVar (& OutboundPort , "port" , "30303" , "listening port" )
137- flag .StringVar (& PMPGateway , "pmp" , "" , "Gateway IP for NAT-PMP" )
138137 flag .StringVar (& BootNodes , "bootnodes" , "" , "space-separated node URLs for discovery bootstrap" )
139138 flag .IntVar (& MaxPeer , "maxpeer" , 30 , "maximum desired peers" )
140139
141140 flag .Parse ()
142141
143142 var err error
143+ if NAT , err = nat .Parse (* natstr ); err != nil {
144+ log .Fatalf ("-nat: %v" , err )
145+ }
144146 switch {
145147 case * nodeKeyFile != "" && * nodeKeyHex != "" :
146148 log .Fatal ("Options -nodekey and -nodekeyhex are mutually exclusive" )
0 commit comments