aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/peerserver/main.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-01-06 20:13:16 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-01-06 20:13:16 +0800
commit3b8725e0f5622733dcb6c3ec142a83ddbb94bd6c (patch)
treecf9e8919920cfc3a3ea776bfd1d04442d05efdaf /cmd/peerserver/main.go
parent117f66e82375b752cc6a9ff22aa0d398ac337bb4 (diff)
parent3caa4ad1baba3019c06733e1a80d78d9a57137bb (diff)
downloaddexon-3b8725e0f5622733dcb6c3ec142a83ddbb94bd6c.tar
dexon-3b8725e0f5622733dcb6c3ec142a83ddbb94bd6c.tar.gz
dexon-3b8725e0f5622733dcb6c3ec142a83ddbb94bd6c.tar.bz2
dexon-3b8725e0f5622733dcb6c3ec142a83ddbb94bd6c.tar.lz
dexon-3b8725e0f5622733dcb6c3ec142a83ddbb94bd6c.tar.xz
dexon-3b8725e0f5622733dcb6c3ec142a83ddbb94bd6c.tar.zst
dexon-3b8725e0f5622733dcb6c3ec142a83ddbb94bd6c.zip
Merge pull request #239 from fjl/grab-bag
Grab bag of fixes
Diffstat (limited to 'cmd/peerserver/main.go')
-rw-r--r--cmd/peerserver/main.go34
1 files changed, 18 insertions, 16 deletions
diff --git a/cmd/peerserver/main.go b/cmd/peerserver/main.go
index eb0900f8b..341c4dbb9 100644
--- a/cmd/peerserver/main.go
+++ b/cmd/peerserver/main.go
@@ -18,9 +18,8 @@ package main
import (
"crypto/elliptic"
- "fmt"
+ "flag"
"log"
- "net"
"os"
"github.com/ethereum/go-ethereum/crypto"
@@ -28,29 +27,32 @@ 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)
srv := p2p.Server{
MaxPeers: 100,
- Identity: p2p.NewSimpleClientIdentity("Ethereum(G)", "0.1", "Peer Server Two", string(marshaled)),
- ListenAddr: ":30301",
- NAT: p2p.UPNP(),
+ Identity: p2p.NewSimpleClientIdentity("Ethereum(G)", "0.1", "Peer Server Two", marshaled),
+ ListenAddr: *listenAddr,
+ NAT: nat,
+ NoDial: true,
}
if err := srv.Start(); err != nil {
- fmt.Println("could not start server:", err)
- os.Exit(1)
+ log.Fatal("could not start server:", err)
}
-
- // add seed peers
- seed, err := net.ResolveTCPAddr("tcp", "poc-8.ethdev.com:30303")
- if err != nil {
- fmt.Println("couldn't resolve:", err)
- } else {
- srv.SuggestPeer(seed.IP, seed.Port, nil)
- }
-
select {}
}