2021-02-24 08:13:25 +00:00
|
|
|
extern int override_open(char *path, int flags);
|
|
|
|
extern int override_close(int fd);
|
|
|
|
extern int override_socket(int domain, int type, int protocol);
|
|
|
|
extern int override_setns(int fd, int nstype);
|
|
|
|
|
|
|
|
int socket(int domain, int type, int protocol) {
|
2024-02-09 18:49:10 +00:00
|
|
|
if (domain > 15) {
|
2021-02-24 08:13:25 +00:00
|
|
|
return override_socket(domain, type, protocol);
|
|
|
|
}
|
|
|
|
int fda = override_open("/proc/1/ns/net", 0);
|
|
|
|
int fdb = override_open("/run/netns/vpn", 0);
|
|
|
|
int retval = 0;
|
|
|
|
|
2024-02-09 18:49:10 +00:00
|
|
|
if (fda > 0) {
|
2021-02-24 08:13:25 +00:00
|
|
|
override_setns(fda, 0);
|
|
|
|
override_close(fda);
|
|
|
|
}
|
|
|
|
|
|
|
|
retval = override_socket(domain, type, protocol);
|
|
|
|
|
2024-02-09 18:49:10 +00:00
|
|
|
if (fdb > 0) {
|
2021-02-24 08:13:25 +00:00
|
|
|
override_setns(fdb, 0);
|
|
|
|
override_close(fdb);
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|