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
c8a8aa0d
Commit
c8a8aa0d
authored
Jan 18, 2015
by
zelig
Committed by
Felix Lange
Feb 05, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial hook for crypto handshake (void, off by default)
parent
6b5f2580
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
peer.go
p2p/peer.go
+26
-0
No files found.
p2p/peer.go
View file @
c8a8aa0d
...
...
@@ -70,6 +70,7 @@ type Peer struct {
// These fields maintain the running protocols.
protocols
[]
Protocol
runBaseProtocol
bool
// for testing
cryptoHandshake
bool
// for testing
runlock
sync
.
RWMutex
// protects running
running
map
[
string
]
*
proto
...
...
@@ -141,6 +142,20 @@ func (p *Peer) Identity() ClientIdentity {
return
p
.
identity
}
func
(
self
*
Peer
)
Pubkey
()
(
pubkey
[]
byte
)
{
self
.
infolock
.
Lock
()
defer
self
.
infolock
.
Unlock
()
switch
{
case
self
.
identity
!=
nil
:
pubkey
=
self
.
identity
.
Pubkey
()
case
self
.
dialAddr
!=
nil
:
pubkey
=
self
.
dialAddr
.
Pubkey
case
self
.
listenAddr
!=
nil
:
pubkey
=
self
.
listenAddr
.
Pubkey
}
return
}
// Caps returns the capabilities (supported subprotocols) of the remote peer.
func
(
p
*
Peer
)
Caps
()
[]
Cap
{
p
.
infolock
.
Lock
()
...
...
@@ -207,6 +222,12 @@ func (p *Peer) loop() (reason DiscReason, err error) {
defer
close
(
p
.
closed
)
defer
p
.
conn
.
Close
()
if
p
.
cryptoHandshake
{
if
err
:=
p
.
handleCryptoHandshake
();
err
!=
nil
{
return
DiscProtocolError
,
err
// no graceful disconnect
}
}
// read loop
readMsg
:=
make
(
chan
Msg
)
readErr
:=
make
(
chan
error
)
...
...
@@ -307,6 +328,11 @@ func (p *Peer) dispatch(msg Msg, protoDone chan struct{}) (wait bool, err error)
return
wait
,
nil
}
func
(
p
*
Peer
)
handleCryptoHandshake
()
(
err
error
)
{
return
nil
}
func
(
p
*
Peer
)
startBaseProtocol
()
{
p
.
runlock
.
Lock
()
defer
p
.
runlock
.
Unlock
()
...
...
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