-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add SRC-MAC
rule
#1406
base: Alpha
Are you sure you want to change the base?
feat: add SRC-MAC
rule
#1406
Conversation
@mlkt 不会合并这种采用cmd输出解析的实现方式,linux和win上均有原生api可以实现获取的方式 |
之前用C写过通过请求连接的fd获取mac的 u_int64_t getpeermac(int sockfd, const char* dev_name) {
u_int64_t mac = 0;
struct arpreq arpreq;
struct sockaddr_in dstadd_in;
bzero(&arpreq, sizeof(arpreq)), bzero(&dstadd_in, sizeof(dstadd_in));
socklen_t len = sizeof(struct sockaddr_in);
if (getpeername(sockfd, (struct sockaddr*) &dstadd_in, &len) == 0) {
memcpy(&arpreq.arp_pa, &dstadd_in, len);
strcpy(arpreq.arp_dev, dev_name);
arpreq.arp_pa.sa_family = AF_INET;
arpreq.arp_ha.sa_family = AF_UNSPEC;
if (ioctl(sockfd, SIOCGARP, &arpreq) == 0) {
memcpy(&mac, arpreq.arp_ha.sa_data, ETH_ALEN);
}
}
return mac;
} 但是go无法直接获取请求的socket,只能根据IP去查ARP表,我查了下windows要用 linux没找到可以直接用的接口,然后我去查了 现在这样直接调命令的方式其实是最简单的了... |
实际上你需要的 |
6,原来还有这种东西,那我再研究一下 |
c5a4a91
to
c830b8a
Compare
src-mac 没必要支持 linux/mac 之外的 os,它的意义应该仅限于路由系统。 |
运行在Windows上时,如果通过socks等入站连接,这个规则也是有意义的。 |
7b03fdc
to
7fd0467
Compare
c6cff7f
to
9cf3eb3
Compare
15365f5
to
6306c6b
Compare
32caa6f
to
a2273e2
Compare
65fea35
to
ecbbf9d
Compare
22addc6
to
5772507
Compare
Add
SRC-MAC
matching rule.It can match the MAC address of the device from which the request originates to carry out the diversion, and set different rules for different devices in the router.
The MAC address separator can be either
:
or-
IPv4 and IPv6 are supported.
增加
SRC-MAC
匹配规则。可以匹配请求来源设备MAC地址来进行分流,比如若用在路由器中可对不同设备设置不同的规则。
MAC地址分隔符用
:
或-
均可。支持 Linux & Windows,支持IPv4 & IPv6。