Closed cuicanju closed 3 months ago
static int
hev_socks5_session_tcp_bind (HevSocks5 *self, int fd,
const struct sockaddr *dest)
{
HevConfigServer *srv;
unsigned int mark;
LOG_D ("%p socks5 session tcp bind", self);
srv = hev_config_get_socks5_server ();
mark = srv->mark;
if (mark) {
int res = 0;
#if defined(__linux__)
res = setsockopt (fd, SOL_SOCKET, SO_MARK, &mark, sizeof (mark));
#elif defined(__FreeBSD__)
res = setsockopt (fd, SOL_SOCKET, SO_USER_COOKIE, &mark, sizeof (mark));
#endif
if (res < 0)
return -1;
}
return 0;
}
And why is there no need to set a mark in the macOS environment here?
static int hev_socks5_session_tcp_bind (HevSocks5 *self, int fd, const struct sockaddr *dest) { HevConfigServer *srv; unsigned int mark; LOG_D ("%p socks5 session tcp bind", self); srv = hev_config_get_socks5_server (); mark = srv->mark; if (mark) { int res = 0; #if defined(__linux__) res = setsockopt (fd, SOL_SOCKET, SO_MARK, &mark, sizeof (mark)); #elif defined(__FreeBSD__) res = setsockopt (fd, SOL_SOCKET, SO_USER_COOKIE, &mark, sizeof (mark)); #endif if (res < 0) return -1; } return 0; }
And why is there no need to set a mark in the macOS environment here?
From freebsd manpage, that's for ipfw/dummynet
. macOS uses pf
which does not uses any kind of mark
.
SO_USER_COOKIE can be used to set the uint32_t so_user_cookie field in
the socket. The value is an uint32_t, and can be used in the kernel
code that manipulates traffic related to the socket. The default value
for the field is 0. As an example, the value can be used as the skipto
target or pipe number in ipfw/dummynet
Could you please advise on how to set up routing rules on macOS?
: see https://github.com/heiher/hev-socks5-tunnel/discussions/104
static int hev_socks5_session_tcp_bind (HevSocks5 *self, int fd, const struct sockaddr *dest) { HevConfigServer *srv; unsigned int mark; LOG_D ("%p socks5 session tcp bind", self); srv = hev_config_get_socks5_server (); mark = srv->mark; if (mark) { int res = 0; #if defined(__linux__) res = setsockopt (fd, SOL_SOCKET, SO_MARK, &mark, sizeof (mark)); #elif defined(__FreeBSD__) res = setsockopt (fd, SOL_SOCKET, SO_USER_COOKIE, &mark, sizeof (mark)); #endif if (res < 0) return -1; } return 0; }
And why is there no need to set a mark in the macOS environment here?
- From freebsd manpage, that's for
ipfw/dummynet
. macOS usespf
which does not uses any kind ofmark
.SO_USER_COOKIE can be used to set the uint32_t so_user_cookie field in the socket. The value is an uint32_t, and can be used in the kernel code that manipulates traffic related to the socket. The default value for the field is 0. As an example, the value can be used as the skipto target or pipe number in ipfw/dummynet
Could you please advise on how to set up routing rules on macOS?
: see get it to work on macOS #104
Thank you very much for your response and the discussions that helped solve the problem that has troubled me for a long time
Could you please advise on how to set up routing rules on macOS?