mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-03 23:02:27 +00:00
network: add ability to specify port for P2P version exchange
This commit is contained in:
parent
5924123927
commit
09bb162de0
3 changed files with 13 additions and 2 deletions
|
@ -1278,8 +1278,14 @@ func (s *Server) broadcastTxLoop() {
|
|||
}
|
||||
}
|
||||
|
||||
// Port returns actual server port. It may differs from that of server.Config.
|
||||
// Port returns a server port that should be used in P2P version exchange. In
|
||||
// case if `AnnouncedPort` is set in the server.Config, the announced node port
|
||||
// will be returned (e.g. consider the node running behind NAT). If `AnnouncedPort`
|
||||
// isn't set, the port returned may still differs from that of server.Config.
|
||||
func (s *Server) Port() (uint16, error) {
|
||||
if s.AnnouncedPort != 0 {
|
||||
return s.ServerConfig.AnnouncedPort, nil
|
||||
}
|
||||
var port uint16
|
||||
_, portStr, err := net.SplitHostPort(s.transport.Address())
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue