Skip to content

fbEvent.Subscribe - Incorrect IP extraction in connAuxRequest() prevents connection to the server's original IP to listen events #186

@Acacio2000

Description

@Acacio2000

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions