Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
4082c8b6
Commit
4082c8b6
authored
Dec 10, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added simple peer server
parent
dda778ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
main.go
cmd/peerserver/main.go
+40
-0
No files found.
cmd/peerserver/main.go
0 → 100644
View file @
4082c8b6
package
main
import
(
"crypto/elliptic"
"fmt"
"log"
"net"
"os"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/p2p"
)
func
main
()
{
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
:
10
,
Identity
:
p2p
.
NewSimpleClientIdentity
(
"Ethereum(G)"
,
"0.1"
,
"Peer Server Two"
,
string
(
marshaled
)),
ListenAddr
:
":30301"
,
NAT
:
p2p
.
UPNP
(),
}
if
err
:=
srv
.
Start
();
err
!=
nil
{
fmt
.
Println
(
"could not start server:"
,
err
)
os
.
Exit
(
1
)
}
// add seed peers
seed
,
err
:=
net
.
ResolveTCPAddr
(
"tcp"
,
"poc-7.ethdev.com:30300"
)
if
err
!=
nil
{
fmt
.
Println
(
"couldn't resolve:"
,
err
)
os
.
Exit
(
1
)
}
srv
.
SuggestPeer
(
seed
.
IP
,
seed
.
Port
,
nil
)
select
{}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment