mirror of
				https://github.com/Ysurac/openmptcprouter-feeds.git
				synced 2025-03-09 15:40:03 +00:00 
			
		
		
		
	Better patch for dsvpn
This commit is contained in:
		
							parent
							
								
									6c4c56a439
								
							
						
					
					
						commit
						86d755cf10
					
				
					 2 changed files with 37 additions and 59 deletions
				
			
		|  | @ -25,11 +25,12 @@ URL:=https://github.com/jedisct1/dsvpn | |||
| SUBMENU:=VPN | ||||
| endef | ||||
| 
 | ||||
| 
 | ||||
| define Package/$(PKG_NAME)/conffiles | ||||
| /etc/config/dsvpn | ||||
| endef | ||||
| 
 | ||||
| TARGET_CFLAGS += -DOPENWRT_BUILD | ||||
| 
 | ||||
| define Package/$(PKG_NAME)/install | ||||
| 	$(INSTALL_DIR) $(1)/usr/sbin | ||||
| 	$(INSTALL_BIN) $(PKG_BUILD_DIR)/dsvpn $(1)/usr/sbin/$(PKG_NAME) | ||||
|  |  | |||
|  | @ -1,58 +1,35 @@ | |||
| diff --git a/src/vpn.c b/src/vpn.c
 | ||||
| index 8064d62..0142f63 100644
 | ||||
| --- a/src/vpn.c
 | ||||
| +++ b/src/vpn.c
 | ||||
| @@ -297,6 +297,7 @@ static int client_connect(Context *context)
 | ||||
|   | ||||
|      context->client_buf.pos = 0; | ||||
|      memset(context->client_buf.data, 0, sizeof context->client_buf.data); | ||||
| +    /*
 | ||||
|      if (context->wanted_ext_gw_ip == NULL && (ext_gw_ip = get_default_gw_ip()) != NULL && | ||||
|          strcmp(ext_gw_ip, context->ext_gw_ip) != 0) { | ||||
|          printf("Gateway changed from [%s] to [%s]\n", context->ext_gw_ip, ext_gw_ip); | ||||
| @@ -304,6 +305,7 @@ static int client_connect(Context *context)
 | ||||
|          snprintf(context->ext_gw_ip, sizeof context->ext_gw_ip, "%s", ext_gw_ip); | ||||
|          firewall_rules(context, 1, 0); | ||||
|      } | ||||
| +    */
 | ||||
|      memset(context->uc_st, 0, sizeof context->uc_st); | ||||
|      context->uc_st[context->is_server][0] ^= 1; | ||||
|      context->client_fd = tcp_client(context->server_ip, context->server_port); | ||||
| @@ -319,7 +321,7 @@ static int client_connect(Context *context)
 | ||||
|          sleep(1); | ||||
|          return -1; | ||||
|      } | ||||
| -    firewall_rules(context, 1, 0);
 | ||||
| +    //firewall_rules(context, 1, 0);
 | ||||
|      context->fds[POLLFD_CLIENT] = | ||||
|          (struct pollfd){ .fd = context->client_fd, .events = POLLIN, .revents = 0 }; | ||||
|      puts("Connected"); | ||||
| @@ -597,22 +599,26 @@ int main(int argc, char *argv[])
 | ||||
|  #ifdef __OpenBSD__ | ||||
|      pledge("stdio proc exec dns inet", NULL); | ||||
|  #endif | ||||
| -    context.firewall_rules_set = -1;
 | ||||
| +    //context.firewall_rules_set = -1;
 | ||||
|      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); | ||||
| diff --git a/src/os.c b/src/os.c
 | ||||
| index fda9d81..d10d045 100644
 | ||||
| --- a/src/os.c
 | ||||
| +++ b/src/os.c
 | ||||
| @@ -441,7 +441,15 @@ int shell_cmd(const char *substs[][2], const char *args_str, int silent)
 | ||||
|  Cmds firewall_rules_cmds(int is_server) | ||||
|  { | ||||
|      if (is_server) { | ||||
| -#ifdef __linux__
 | ||||
| +#ifdef defined(OPENWRT_BUILD)
 | ||||
| +        static const char
 | ||||
| +            *set_cmds[] =
 | ||||
| +                { "ip addr add $LOCAL_TUN_IP peer $REMOTE_TUN_IP dev $IF_NAME",
 | ||||
| +                  "ip -6 addr add $LOCAL_TUN_IP6 peer $REMOTE_TUN_IP6/96 dev $IF_NAME",
 | ||||
| +                  "ip link set dev $IF_NAME up",
 | ||||
| +                  NULL },
 | ||||
| +            *unset_cmds[] = { NULL, NULL };
 | ||||
| +#elif __linux__
 | ||||
|          static const char | ||||
|              *set_cmds[] = | ||||
|                  { "sysctl net.ipv4.ip_forward=1", | ||||
| @@ -487,6 +495,13 @@ Cmds firewall_rules_cmds(int is_server)
 | ||||
|                                "route delete 128/1",           "route delete -inet6 0000::/1", | ||||
|                                "route delete -inet6 8000::/1", NULL | ||||
|                            }; | ||||
| +#elif defined(OPENWRT_BUILD)
 | ||||
| +        static const char
 | ||||
| +            *set_cmds[]   = { "ip link set dev $IF_NAME up",
 | ||||
| +                            "ip addr add $LOCAL_TUN_IP peer $REMOTE_TUN_IP dev $IF_NAME",
 | ||||
| +                            "ip -6 addr add $LOCAL_TUN_IP6 peer $REMOTE_TUN_IP6/96 dev $IF_NAME",
 | ||||
| +                            NULL },
 | ||||
| +            *unset_cmds[] = { NULL, NULL };
 | ||||
|  #elif defined(__linux__) | ||||
|          static const char | ||||
|              *set_cmds[]   = { "sysctl net.ipv4.tcp_congestion_control=bbr", | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue