Skip to content

Commit

Permalink
cmd/peerserver: add some command line switches
Browse files Browse the repository at this point in the history
  • Loading branch information
fjl committed Jan 6, 2015
1 parent 4c8c115 commit 36e1e5f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions cmd/peerserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package main

import (
"crypto/elliptic"
"flag"
"log"
"os"

Expand All @@ -26,16 +27,28 @@ 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", marshaled),
ListenAddr: ":30301",
NAT: p2p.UPNP(),
ListenAddr: *listenAddr,
NAT: nat,
NoDial: true,
}
if err := srv.Start(); err != nil {
Expand Down

0 comments on commit 36e1e5f

Please sign in to comment.