mirror of
https://github.com/PeernetOfficial/core.git
synced 2026-07-17 02:47:51 +01:00
Record BlockchainHeight and BlockchainVersion for each peer. New function IsPortForward.
This commit is contained in:
@@ -64,6 +64,11 @@ func (c *Connection) IsBehindNAT() bool {
|
||||
return c.PortInternal > 0 && c.Address.Port != int(c.PortInternal)
|
||||
}
|
||||
|
||||
// IsPortForward checks if the remote peer uses port forwarding on the connection
|
||||
func (c *Connection) IsPortForward() bool {
|
||||
return c.PortExternal > 0
|
||||
}
|
||||
|
||||
// GetConnections returns the list of connections
|
||||
func (peer *PeerInfo) GetConnections(active bool) (connections []*Connection) {
|
||||
peer.RLock()
|
||||
@@ -284,6 +289,26 @@ func (peer *PeerInfo) IsBehindNAT() (result bool) {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsPortForward checks if the peer uses port forwarding
|
||||
func (peer *PeerInfo) IsPortForward() (result bool) {
|
||||
peer.Lock()
|
||||
defer peer.Unlock()
|
||||
|
||||
for _, connection := range peer.connectionActive {
|
||||
if connection.IsPortForward() {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
for _, connection := range peer.connectionInactive {
|
||||
if connection.IsPortForward() {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// ---- sending code ----
|
||||
|
||||
// send sends the packet to the peer on the connection
|
||||
|
||||
Reference in New Issue
Block a user