good morning!!!!

Skip to content
Snippets Groups Projects
Commit c00b1dd5 authored by Jeffrey Wilcke's avatar Jeffrey Wilcke
Browse files

Self connect on handshake

parent 0de31a38
No related branches found
No related tags found
No related merge requests found
......@@ -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)})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment