aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/peerserver
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-01-06 18:15:37 +0800
committerFelix Lange <fjl@twurst.com>2015-01-06 19:23:37 +0800
commit36e1e5f15142b37801844a072eb46ea67fbc8868 (patch)
tree5333f4c8a708ce22eaa584f06e891400d49f0082 /cmd/peerserver
parent4c8c115a7633e39b85738cd7919c7d3e3e722e7a (diff)
downloaddexon-36e1e5f15142b37801844a072eb46ea67fbc8868.tar.gz
dexon-36e1e5f15142b37801844a072eb46ea67fbc8868.tar.zst
dexon-36e1e5f15142b37801844a072eb46ea67fbc8868.zip
cmd/peerserver: add some command line switches
Diffstat (limited to 'cmd/peerserver')
-rw-r--r--cmd/peerserver/main.go17
1 files changed, 15 insertions, 2 deletions
diff --git a/cmd/peerserver/main.go b/cmd/peerserver/main.go
index 7a5d5708e..341c4dbb9 100644
--- a/cmd/peerserver/main.go
+++ b/cmd/peerserver/main.go
@@ -18,6 +18,7 @@ package main
import (
"crypto/elliptic"
+ "flag"
"log"
"os"
@@ -26,7 +27,19 @@ import (
"github.com/ethereum/go-ethereum/p2p"
)
+var (
+ natType = flag.String("nat", "", "NAT traversal implementation")
+ pmpGateway = flag.String("gateway", "", "gateway address for NAT-PMP")
+ listenAddr = flag.String("addr", ":30301", "listen address")
+)
+
func main() {
+ flag.Parse()
+ nat, err := p2p.ParseNAT(*natType, *pmpGateway)
+ if err != nil {
+ log.Fatal("invalid nat:", err)
+ }
+
logger.AddLogSystem(logger.NewStdLogSystem(os.Stdout, log.LstdFlags, logger.InfoLevel))
key, _ := crypto.GenerateKey()
marshaled := elliptic.Marshal(crypto.S256(), key.PublicKey.X, key.PublicKey.Y)
@@ -34,8 +47,8 @@ func main() {
srv := p2p.Server{
MaxPeers: 100,
Identity: p2p.NewSimpleClientIdentity("Ethereum(G)", "0.1", "Peer Server Two", marshaled),
- ListenAddr: ":30301",
- NAT: p2p.UPNP(),
+ ListenAddr: *listenAddr,
+ NAT: nat,
NoDial: true,
}
if err := srv.Start(); err != nil {