Skip to content

Can not get the real ip address and port with Packet Filter TCP redirection in MacOS 12.3.1(Intel) #231

@BigSully

Description

@BigSully

When I tried to set up transparent proxy in macos, go-shadowsocks could not get the real ip address and port with Packet Filter TCP redirection in MacOS 12.3.1(Intel).
The error returned is invalid argument, which is reported by the following code.

if _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), DIOCNATLOOK, uintptr(unsafe.Pointer(&nl))); errno != 0 {
    return nil, errno
}

https://github.com/shadowsocks/go-shadowsocks2/blob/v0.1.5/pfutil/pf_darwin.go#L44

And I noticed that when run as transparent proxy, mitmproxy takes a different way, which is to parse real ip address and port from output of sudo -n /sbin/pfctl -s state, instead of using DIOCNATLOOK on the pf device /dev/pf.

https://github.com/mitmproxy/mitmproxy/blob/v8.1.0/mitmproxy/platform/osx.py#L6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions