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
c00b1dd5
Commit
c00b1dd5
authored
Feb 09, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Self connect on handshake
parent
0de31a38
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
9 deletions
+10
-9
peer.go
peer.go
+10
-9
No files found.
peer.go
View file @
c00b1dd5
...
...
@@ -128,7 +128,8 @@ func NewPeer(conn net.Conn, ethereum *Ethereum, inbound bool) *Peer {
}
func
NewOutboundPeer
(
addr
string
,
ethereum
*
Ethereum
,
caps
Caps
)
*
Peer
{
pubkey
,
_
:=
ethutil
.
Config
.
Db
.
Get
([]
byte
(
"Pubkey"
))
data
,
_
:=
ethutil
.
Config
.
Db
.
Get
([]
byte
(
"KeyRing"
))
pubkey
:=
ethutil
.
NewValueFromBytes
(
data
)
.
Get
(
2
)
.
Bytes
()
p
:=
&
Peer
{
outputQueue
:
make
(
chan
*
ethwire
.
Msg
,
outputBufferSize
),
...
...
@@ -382,14 +383,6 @@ func (p *Peer) Start() {
peerHost
,
peerPort
,
_
:=
net
.
SplitHostPort
(
p
.
conn
.
LocalAddr
()
.
String
())
servHost
,
servPort
,
_
:=
net
.
SplitHostPort
(
p
.
conn
.
RemoteAddr
()
.
String
())
pubkey
,
_
:=
ethutil
.
Config
.
Db
.
Get
([]
byte
(
"Pubkey"
))
if
bytes
.
Compare
(
pubkey
,
p
.
pubkey
)
==
0
{
log
.
Println
(
"self connect"
)
p
.
Stop
()
return
}
if
p
.
inbound
{
p
.
host
,
p
.
port
=
packAddr
(
peerHost
,
peerPort
)
}
else
{
...
...
@@ -468,6 +461,14 @@ func (p *Peer) handleHandshake(msg *ethwire.Msg) {
p
.
pubkey
=
c
.
Get
(
3
)
.
AsBytes
()
p
.
port
=
uint16
(
c
.
Get
(
5
)
.
AsUint
())
data
,
_
:=
ethutil
.
Config
.
Db
.
Get
([]
byte
(
"KeyRing"
))
pubkey
:=
ethutil
.
NewValueFromBytes
(
data
)
.
Get
(
2
)
.
Bytes
()
if
bytes
.
Compare
(
pubkey
,
p
.
pubkey
)
==
0
{
p
.
Stop
()
return
}
istr
=
"inbound"
}
else
{
msg
:=
ethwire
.
NewMessage
(
ethwire
.
MsgGetChainTy
,
[]
interface
{}{
p
.
ethereum
.
BlockManager
.
BlockChain
()
.
CurrentBlock
.
Hash
(),
uint64
(
100
)})
...
...
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