-
Notifications
You must be signed in to change notification settings - Fork 65
Description
I found an issue in subscriber.go the connAuxRequest() function where it incorrectly uses the local IP returned by opResponse(), instead of the original IP of the connection.
### Problem Explanation
The function incorrectly extracts ans use the local IP from the response buffer (buf), which does not always represent the original IP of the connection.
This leads to incorrect behavior when handling network requests, especially in cases where NAT or proxies are involved.
Instead of relying on the returned buf to extract the IP, the correct approach is to use the original connection IP, which can be retrieved from s.fc.dsn.addr.
### Proposed Fix
The correct approach is to use the original IP of the connection, extracted from s.fc.dsn.addr, instead of relying on the local IP from the response buffer:
func (s *Subscription) connAuxRequest() (int32, *netip.AddrPort, error) {
s.mu.Lock()
defer s.mu.Unlock()
s.fc.wp.opConnectRequest()
auxHandle, _, buf, err := s.fc.wp.opResponse()
if err != nil {
return -1, nil, err
}
port := binary.BigEndian.Uint16(buf[2:4])//Extract the ORIGINAL IP from the connection instead of using the local IP from buf
parsedAddrPort, _ := netip.ParseAddrPort(s.fc.dsn.addr)
ip := parsedAddrPort.Addr()
addrPort := netip.AddrPortFrom(ip, port)return auxHandle, &addrPort, nil
}
Expected Behavior
The function should return the original IP of the connection, ensuring correct routing and network operations.
This prevents issues where the local IP is incorrectly used in place of the original remote IP.
Additional Information
Package Version: [v0.9.14]
Would appreciate feedback or confirmation if this fix aligns with the intended behavior. Thanks!