lib: Factor out getting IP address from net.Addr (#8538)
... and add fast paths for common cases.
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/syncthing/syncthing/lib/dialer"
|
||||
"github.com/syncthing/syncthing/lib/osutil"
|
||||
syncthingprotocol "github.com/syncthing/syncthing/lib/protocol"
|
||||
"github.com/syncthing/syncthing/lib/relay/protocol"
|
||||
)
|
||||
@@ -87,7 +88,7 @@ func (c *staticClient) serve(ctx context.Context) error {
|
||||
case protocol.SessionInvitation:
|
||||
ip := net.IP(msg.Address)
|
||||
if len(ip) == 0 || ip.IsUnspecified() {
|
||||
msg.Address = remoteIPBytes(c.conn)
|
||||
msg.Address, _ = osutil.IPFromAddr(c.conn.RemoteAddr())
|
||||
}
|
||||
select {
|
||||
case c.invitations <- msg:
|
||||
|
||||
Reference in New Issue
Block a user