1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-14 19:41:51 +00:00

Better patch for dsvpn

This commit is contained in:
Ycarus (Yannick Chabanois) 2019-08-26 21:06:55 +02:00
parent 6c4c56a439
commit 86d755cf10
2 changed files with 37 additions and 59 deletions

View file

@ -25,11 +25,12 @@ URL:=https://github.com/jedisct1/dsvpn
SUBMENU:=VPN SUBMENU:=VPN
endef endef
define Package/$(PKG_NAME)/conffiles define Package/$(PKG_NAME)/conffiles
/etc/config/dsvpn /etc/config/dsvpn
endef endef
TARGET_CFLAGS += -DOPENWRT_BUILD
define Package/$(PKG_NAME)/install define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/dsvpn $(1)/usr/sbin/$(PKG_NAME) $(INSTALL_BIN) $(PKG_BUILD_DIR)/dsvpn $(1)/usr/sbin/$(PKG_NAME)

View file

@ -1,58 +1,35 @@
diff --git a/src/vpn.c b/src/vpn.c diff --git a/src/os.c b/src/os.c
index 8064d62..0142f63 100644 index fda9d81..d10d045 100644
--- a/src/vpn.c --- a/src/os.c
+++ b/src/vpn.c +++ b/src/os.c
@@ -297,6 +297,7 @@ static int client_connect(Context *context) @@ -441,7 +441,15 @@ int shell_cmd(const char *substs[][2], const char *args_str, int silent)
Cmds firewall_rules_cmds(int is_server)
context->client_buf.pos = 0; {
memset(context->client_buf.data, 0, sizeof context->client_buf.data); if (is_server) {
+ /* -#ifdef __linux__
if (context->wanted_ext_gw_ip == NULL && (ext_gw_ip = get_default_gw_ip()) != NULL && +#ifdef defined(OPENWRT_BUILD)
strcmp(ext_gw_ip, context->ext_gw_ip) != 0) { + static const char
printf("Gateway changed from [%s] to [%s]\n", context->ext_gw_ip, ext_gw_ip); + *set_cmds[] =
@@ -304,6 +305,7 @@ static int client_connect(Context *context) + { "ip addr add $LOCAL_TUN_IP peer $REMOTE_TUN_IP dev $IF_NAME",
snprintf(context->ext_gw_ip, sizeof context->ext_gw_ip, "%s", ext_gw_ip); + "ip -6 addr add $LOCAL_TUN_IP6 peer $REMOTE_TUN_IP6/96 dev $IF_NAME",
firewall_rules(context, 1, 0); + "ip link set dev $IF_NAME up",
} + NULL },
+ */ + *unset_cmds[] = { NULL, NULL };
memset(context->uc_st, 0, sizeof context->uc_st); +#elif __linux__
context->uc_st[context->is_server][0] ^= 1; static const char
context->client_fd = tcp_client(context->server_ip, context->server_port); *set_cmds[] =
@@ -319,7 +321,7 @@ static int client_connect(Context *context) { "sysctl net.ipv4.ip_forward=1",
sleep(1); @@ -487,6 +495,13 @@ Cmds firewall_rules_cmds(int is_server)
return -1; "route delete 128/1", "route delete -inet6 0000::/1",
} "route delete -inet6 8000::/1", NULL
- firewall_rules(context, 1, 0); };
+ //firewall_rules(context, 1, 0); +#elif defined(OPENWRT_BUILD)
context->fds[POLLFD_CLIENT] = + static const char
(struct pollfd){ .fd = context->client_fd, .events = POLLIN, .revents = 0 }; + *set_cmds[] = { "ip link set dev $IF_NAME up",
puts("Connected"); + "ip addr add $LOCAL_TUN_IP peer $REMOTE_TUN_IP dev $IF_NAME",
@@ -597,22 +599,26 @@ int main(int argc, char *argv[]) + "ip -6 addr add $LOCAL_TUN_IP6 peer $REMOTE_TUN_IP6/96 dev $IF_NAME",
#ifdef __OpenBSD__ + NULL },
pledge("stdio proc exec dns inet", NULL); + *unset_cmds[] = { NULL, NULL };
#endif #elif defined(__linux__)
- context.firewall_rules_set = -1; static const char
+ //context.firewall_rules_set = -1; *set_cmds[] = { "sysctl net.ipv4.tcp_congestion_control=bbr",
if (context.server_ip_or_name != NULL &&
resolve_ip(context.server_ip, sizeof context.server_ip, context.server_ip_or_name) != 0) {
- firewall_rules(&context, 0, 1);
+ //firewall_rules(&context, 0, 1);
return 1;
}
if (context.is_server) {
+ /*
if (firewall_rules(&context, 1, 0) != 0) {
return -1;
}
+ */
#ifdef __OpenBSD__
printf("\nAdd the following rule to /etc/pf.conf:\npass out from %s nat-to egress\n\n",
context.remote_tun_ip);
#endif
+/*
} else {
firewall_rules(&context, 0, 1);
+*/
}
signal(SIGINT, signal_handler);
signal(SIGTERM, signal_handler);