1 |
jpp |
1.1 |
diff --git a/src/Cedar/IPsec.c b/src/Cedar/IPsec.c |
2 |
|
|
index ea6443669..535c044d3 100644 |
3 |
|
|
--- a/src/Cedar/IPsec.c |
4 |
|
|
+++ b/src/Cedar/IPsec.c |
5 |
|
|
@@ -545,6 +545,8 @@ void IPsecServerSetServices(IPSEC_SERVER *s, IPSEC_SERVICES *sl) |
6 |
|
|
{ |
7 |
|
|
Copy(&s->Services, sl, sizeof(IPSEC_SERVICES)); |
8 |
|
|
|
9 |
|
|
+ Copy(&s->UdpListener->ListenIP, &s->Cedar->Server->ListenIP, sizeof(IP)); |
10 |
|
|
+ |
11 |
|
|
if (sl->L2TP_Raw) |
12 |
|
|
{ |
13 |
|
|
AddPortToUdpListener(s->UdpListener, IPSEC_PORT_L2TP); |
14 |
|
|
@@ -782,7 +784,7 @@ IPSEC_SERVER *NewIPsecServer(CEDAR *cedar) |
15 |
|
|
s->Ike = NewIKEServer(cedar, s); |
16 |
|
|
StrCpy(s->Ike->Secret, sizeof(s->Ike->Secret), IPSEC_DEFAULT_SECRET); |
17 |
|
|
|
18 |
|
|
- s->UdpListener = NewUdpListener(IPsecServerUdpPacketRecvProc, s); |
19 |
|
|
+ s->UdpListener = NewUdpListener(IPsecServerUdpPacketRecvProc, s, &cedar->Server->ListenIP); |
20 |
|
|
|
21 |
|
|
s->EtherIPIdList = NewList(CmpEtherIPId); |
22 |
|
|
|
23 |
|
|
diff --git a/src/Cedar/Interop_OpenVPN.c b/src/Cedar/Interop_OpenVPN.c |
24 |
|
|
index afd8b4b36..69f501097 100644 |
25 |
|
|
--- a/src/Cedar/Interop_OpenVPN.c |
26 |
|
|
+++ b/src/Cedar/Interop_OpenVPN.c |
27 |
|
|
@@ -2695,7 +2695,7 @@ OPENVPN_SERVER_UDP *NewOpenVpnServerUdp(CEDAR *cedar) |
28 |
|
|
AddRef(u->Cedar->ref); |
29 |
|
|
|
30 |
|
|
// Create a UDP listener |
31 |
|
|
- u->UdpListener = NewUdpListener(OpenVpnServerUdpListenerProc, u); |
32 |
|
|
+ u->UdpListener = NewUdpListener(OpenVpnServerUdpListenerProc, u, &cedar->Server->ListenIP); |
33 |
|
|
|
34 |
|
|
// Create an OpenVPN server |
35 |
|
|
u->OpenVpnServer = NewOpenVpnServer(cedar, u->UdpListener->Interrupts, u->UdpListener->Event); |
36 |
|
|
@@ -2704,7 +2704,7 @@ OPENVPN_SERVER_UDP *NewOpenVpnServerUdp(CEDAR *cedar) |
37 |
|
|
} |
38 |
|
|
|
39 |
|
|
// Apply the port list to the OpenVPN server |
40 |
|
|
-void OvsApplyUdpPortList(OPENVPN_SERVER_UDP *u, char *port_list) |
41 |
|
|
+void OvsApplyUdpPortList(OPENVPN_SERVER_UDP *u, char *port_list, IP *listen_ip) |
42 |
|
|
{ |
43 |
|
|
LIST *o; |
44 |
|
|
UINT i; |
45 |
|
|
@@ -2716,6 +2716,11 @@ void OvsApplyUdpPortList(OPENVPN_SERVER_UDP *u, char *port_list) |
46 |
|
|
|
47 |
|
|
DeleteAllPortFromUdpListener(u->UdpListener); |
48 |
|
|
|
49 |
|
|
+ if (u->UdpListener != NULL && listen_ip != NULL) |
50 |
|
|
+ { |
51 |
|
|
+ Copy(&u->UdpListener->ListenIP, listen_ip, sizeof(IP)); |
52 |
|
|
+ } |
53 |
|
|
+ |
54 |
|
|
o = StrToIntList(port_list, true); |
55 |
|
|
|
56 |
|
|
for (i = 0;i < LIST_NUM(o);i++) |
57 |
|
|
diff --git a/src/Cedar/Interop_OpenVPN.h b/src/Cedar/Interop_OpenVPN.h |
58 |
|
|
index bb82288bf..cef7b8839 100644 |
59 |
|
|
--- a/src/Cedar/Interop_OpenVPN.h |
60 |
|
|
+++ b/src/Cedar/Interop_OpenVPN.h |
61 |
|
|
@@ -319,7 +319,7 @@ struct OPENVPN_SERVER_UDP |
62 |
|
|
OPENVPN_SERVER_UDP *NewOpenVpnServerUdp(CEDAR *cedar); |
63 |
|
|
void FreeOpenVpnServerUdp(OPENVPN_SERVER_UDP *u); |
64 |
|
|
void OpenVpnServerUdpListenerProc(UDPLISTENER *u, LIST *packet_list); |
65 |
|
|
-void OvsApplyUdpPortList(OPENVPN_SERVER_UDP *u, char *port_list); |
66 |
|
|
+void OvsApplyUdpPortList(OPENVPN_SERVER_UDP *u, char *port_list, IP *listen_ip); |
67 |
|
|
|
68 |
|
|
OPENVPN_SERVER *NewOpenVpnServer(CEDAR *cedar, INTERRUPT_MANAGER *interrupt, SOCK_EVENT *sock_event); |
69 |
|
|
void FreeOpenVpnServer(OPENVPN_SERVER *s); |
70 |
|
|
diff --git a/src/Cedar/Listener.c b/src/Cedar/Listener.c |
71 |
|
|
index 0e158e507..3f586f69c 100644 |
72 |
|
|
--- a/src/Cedar/Listener.c |
73 |
|
|
+++ b/src/Cedar/Listener.c |
74 |
|
|
@@ -356,7 +356,7 @@ void ListenerUDPMainLoop(LISTENER *r) |
75 |
|
|
} |
76 |
|
|
|
77 |
|
|
Debug("NewUDP()\n"); |
78 |
|
|
- r->Sock = NewUDP(r->Port); |
79 |
|
|
+ r->Sock = NewUDPEx2(r->Port, false, &r->Cedar->Server->ListenIP); |
80 |
|
|
if (r->Sock != NULL) |
81 |
|
|
{ |
82 |
|
|
// Wait success |
83 |
|
|
@@ -465,7 +465,7 @@ void ListenerTCPMainLoop(LISTENER *r) |
84 |
|
|
{ |
85 |
|
|
if (r->ShadowIPv6 == false) |
86 |
|
|
{ |
87 |
|
|
- s = ListenEx2(r->Port, r->LocalOnly, r->EnableConditionalAccept); |
88 |
|
|
+ s = ListenEx2(r->Port, r->LocalOnly, r->EnableConditionalAccept, &r->Cedar->Server->ListenIP); |
89 |
|
|
} |
90 |
|
|
else |
91 |
|
|
{ |
92 |
|
|
@@ -478,7 +478,7 @@ void ListenerTCPMainLoop(LISTENER *r) |
93 |
|
|
} |
94 |
|
|
else if (r->Protocol == LISTENER_RUDP) |
95 |
|
|
{ |
96 |
|
|
- s = ListenRUDPEx(VPN_RUDP_SVC_NAME, NULL, ListenerRUDPRpcRecvProc, NULL, 0, false, false, r->NatTGlobalUdpPort, r->RandPortId); |
97 |
|
|
+ s = ListenRUDPEx(VPN_RUDP_SVC_NAME, NULL, ListenerRUDPRpcRecvProc, NULL, 0, false, false, r->NatTGlobalUdpPort, r->RandPortId, &r->Cedar->Server->ListenIP); |
98 |
|
|
} |
99 |
|
|
else if (r->Protocol == LISTENER_ICMP) |
100 |
|
|
{ |
101 |
|
|
diff --git a/src/Cedar/Logging.c b/src/Cedar/Logging.c |
102 |
|
|
index eb18d7555..42e895587 100644 |
103 |
|
|
--- a/src/Cedar/Logging.c |
104 |
|
|
+++ b/src/Cedar/Logging.c |
105 |
|
|
@@ -227,13 +227,13 @@ void SetSysLog(SLOG *g, char *hostname, UINT port) |
106 |
|
|
} |
107 |
|
|
|
108 |
|
|
// Create a syslog client |
109 |
|
|
-SLOG *NewSysLog(char *hostname, UINT port) |
110 |
|
|
+SLOG *NewSysLog(char *hostname, UINT port, IP *ip) |
111 |
|
|
{ |
112 |
|
|
// Validate arguments |
113 |
|
|
SLOG *g = ZeroMalloc(sizeof(SLOG)); |
114 |
|
|
|
115 |
|
|
g->lock = NewLock(); |
116 |
|
|
- g->Udp = NewUDP(0); |
117 |
|
|
+ g->Udp = NewUDPEx2(0, false, ip); |
118 |
|
|
|
119 |
|
|
SetSysLog(g, hostname, port); |
120 |
|
|
|
121 |
|
|
diff --git a/src/Cedar/Logging.h b/src/Cedar/Logging.h |
122 |
|
|
index c08285484..997a9f522 100644 |
123 |
|
|
--- a/src/Cedar/Logging.h |
124 |
|
|
+++ b/src/Cedar/Logging.h |
125 |
|
|
@@ -263,7 +263,7 @@ LIST *GenerateEraseFileList(ERASER *e); |
126 |
|
|
void FreeEraseFileList(LIST *o); |
127 |
|
|
void PrintEraseFileList(LIST *o); |
128 |
|
|
void EnumEraseFile(LIST *o, char *dirname); |
129 |
|
|
-SLOG *NewSysLog(char *hostname, UINT port); |
130 |
|
|
+SLOG *NewSysLog(char *hostname, UINT port, IP *ip); |
131 |
|
|
void SetSysLog(SLOG *g, char *hostname, UINT port); |
132 |
|
|
void FreeSysLog(SLOG *g); |
133 |
|
|
void SendSysLog(SLOG *g, wchar_t *str); |
134 |
|
|
diff --git a/src/Cedar/Server.c b/src/Cedar/Server.c |
135 |
|
|
index e5e2aff59..b6899514b 100644 |
136 |
|
|
--- a/src/Cedar/Server.c |
137 |
|
|
+++ b/src/Cedar/Server.c |
138 |
|
|
@@ -159,11 +159,11 @@ void SiSetOpenVPNAndSSTPConfig(SERVER *s, OPENVPN_SSTP_CONFIG *c) |
139 |
|
|
{ |
140 |
|
|
if (s->DisableOpenVPNServer) |
141 |
|
|
{ |
142 |
|
|
- OvsApplyUdpPortList(s->OpenVpnServerUdp, ""); |
143 |
|
|
+ OvsApplyUdpPortList(s->OpenVpnServerUdp, "", NULL); |
144 |
|
|
} |
145 |
|
|
else |
146 |
|
|
{ |
147 |
|
|
- OvsApplyUdpPortList(s->OpenVpnServerUdp, s->OpenVpnServerUdpPorts); |
148 |
|
|
+ OvsApplyUdpPortList(s->OpenVpnServerUdp, s->OpenVpnServerUdpPorts, &s->ListenIP); |
149 |
|
|
} |
150 |
|
|
} |
151 |
|
|
} |
152 |
|
|
@@ -5816,6 +5816,7 @@ void SiLoadServerCfg(SERVER *s, FOLDER *f) |
153 |
|
|
} |
154 |
|
|
|
155 |
|
|
s->DontBackupConfig = CfgGetBool(f, "DontBackupConfig"); |
156 |
|
|
+ CfgGetIp(f, "ListenIP", &s->ListenIP); |
157 |
|
|
|
158 |
|
|
if (CfgIsItem(f, "BackupConfigOnlyWhenModified")) |
159 |
|
|
{ |
160 |
|
|
@@ -6259,6 +6260,7 @@ void SiWriteServerCfg(FOLDER *f, SERVER *s) |
161 |
|
|
CfgAddBool(f, "DontBackupConfig", s->DontBackupConfig); |
162 |
|
|
CfgAddBool(f, "BackupConfigOnlyWhenModified", s->BackupConfigOnlyWhenModified); |
163 |
|
|
|
164 |
|
|
+ CfgAddIp(f, "ListenIP", &s->ListenIP); |
165 |
|
|
if (s->Logger != NULL) |
166 |
|
|
{ |
167 |
|
|
CfgAddInt(f, "ServerLogSwitchType", s->Logger->SwitchType); |
168 |
|
|
@@ -10928,8 +10930,6 @@ SERVER *SiNewServerEx(bool bridge, bool in_client_inner_server, bool relay_serve |
169 |
|
|
s->Cedar->CheckExpires = true; |
170 |
|
|
s->ServerListenerList = NewList(CompareServerListener); |
171 |
|
|
s->StartTime = SystemTime64(); |
172 |
|
|
- s->Syslog = NewSysLog(NULL, 0); |
173 |
|
|
- s->SyslogLock = NewLock(); |
174 |
|
|
s->TasksFromFarmControllerLock = NewLock(); |
175 |
|
|
|
176 |
|
|
if (bridge) |
177 |
|
|
@@ -10961,6 +10961,9 @@ SERVER *SiNewServerEx(bool bridge, bool in_client_inner_server, bool relay_serve |
178 |
|
|
// Initialize the configuration |
179 |
|
|
SiInitConfiguration(s); |
180 |
|
|
|
181 |
|
|
+ s->Syslog = NewSysLog(NULL, 0, &s->Cedar->Server->ListenIP); |
182 |
|
|
+ s->SyslogLock = NewLock(); |
183 |
|
|
+ |
184 |
|
|
SetFifoCurrentReallocMemSize(MEM_FIFO_REALLOC_MEM_SIZE); |
185 |
|
|
|
186 |
|
|
|
187 |
|
|
diff --git a/src/Mayaqua/Network.c b/src/Mayaqua/Network.c |
188 |
|
|
index def2f45e6..aec224148 100644 |
189 |
|
|
--- a/src/Mayaqua/Network.c |
190 |
|
|
+++ b/src/Mayaqua/Network.c |
191 |
|
|
@@ -2724,16 +2724,16 @@ void RUDPBulkSend(RUDP_STACK *r, RUDP_SESSION *se, void *data, UINT data_size) |
192 |
|
|
// Start a socket for R-UDP Listening |
193 |
|
|
SOCK *ListenRUDP(char *svc_name, RUDP_STACK_INTERRUPTS_PROC *proc_interrupts, RUDP_STACK_RPC_RECV_PROC *proc_rpc_recv, void *param, UINT port, bool no_natt_register, bool over_dns_mode) |
194 |
|
|
{ |
195 |
|
|
- return ListenRUDPEx(svc_name, proc_interrupts, proc_rpc_recv, param, port, no_natt_register, over_dns_mode, NULL, 0); |
196 |
|
|
+ return ListenRUDPEx(svc_name, proc_interrupts, proc_rpc_recv, param, port, no_natt_register, over_dns_mode, NULL, 0, NULL); |
197 |
|
|
} |
198 |
|
|
SOCK *ListenRUDPEx(char *svc_name, RUDP_STACK_INTERRUPTS_PROC *proc_interrupts, RUDP_STACK_RPC_RECV_PROC *proc_rpc_recv, void *param, UINT port, bool no_natt_register, bool over_dns_mode, |
199 |
|
|
- volatile UINT *natt_global_udp_port, UCHAR rand_port_id) |
200 |
|
|
+ volatile UINT *natt_global_udp_port, UCHAR rand_port_id, IP *listen_ip) |
201 |
|
|
{ |
202 |
|
|
SOCK *s; |
203 |
|
|
RUDP_STACK *r; |
204 |
|
|
|
205 |
|
|
// Creating a R-UDP stack |
206 |
|
|
- r = NewRUDPServer(svc_name, proc_interrupts, proc_rpc_recv, param, port, no_natt_register, over_dns_mode, natt_global_udp_port, rand_port_id); |
207 |
|
|
+ r = NewRUDPServer(svc_name, proc_interrupts, proc_rpc_recv, param, port, no_natt_register, over_dns_mode, natt_global_udp_port, rand_port_id, listen_ip); |
208 |
|
|
if (r == NULL) |
209 |
|
|
{ |
210 |
|
|
return NULL; |
211 |
|
|
@@ -5259,7 +5259,7 @@ SOCK *NewRUDPClientDirect(char *svc_name, IP *ip, UINT port, UINT *error_code, U |
212 |
|
|
return NULL; |
213 |
|
|
} |
214 |
|
|
|
215 |
|
|
- r = NewRUDP(false, svc_name, NULL, NULL, NULL, local_port, sock, sock_event, false, over_dns_mode, ip, NULL, 0); |
216 |
|
|
+ r = NewRUDP(false, svc_name, NULL, NULL, NULL, local_port, sock, sock_event, false, over_dns_mode, ip, NULL, 0, NULL); |
217 |
|
|
if (r == NULL) |
218 |
|
|
{ |
219 |
|
|
*error_code = RUDP_ERROR_UNKNOWN; |
220 |
|
|
@@ -5318,7 +5318,7 @@ SOCK *NewRUDPClientDirect(char *svc_name, IP *ip, UINT port, UINT *error_code, U |
221 |
|
|
} |
222 |
|
|
|
223 |
|
|
// Creating a R-UDP server |
224 |
|
|
-RUDP_STACK *NewRUDPServer(char *svc_name, RUDP_STACK_INTERRUPTS_PROC *proc_interrupts, RUDP_STACK_RPC_RECV_PROC *proc_rpc_recv, void *param, UINT port, bool no_natt_register, bool over_dns_mode, volatile UINT *natt_global_udp_port, UCHAR rand_port_id) |
225 |
|
|
+RUDP_STACK *NewRUDPServer(char *svc_name, RUDP_STACK_INTERRUPTS_PROC *proc_interrupts, RUDP_STACK_RPC_RECV_PROC *proc_rpc_recv, void *param, UINT port, bool no_natt_register, bool over_dns_mode, volatile UINT *natt_global_udp_port, UCHAR rand_port_id, IP *listen_ip) |
226 |
|
|
{ |
227 |
|
|
RUDP_STACK *r; |
228 |
|
|
// Validate arguments |
229 |
|
|
@@ -5334,7 +5334,7 @@ RUDP_STACK *NewRUDPServer(char *svc_name, RUDP_STACK_INTERRUPTS_PROC *proc_inter |
230 |
|
|
|
231 |
|
|
ListenTcpForPopupFirewallDialog(); |
232 |
|
|
|
233 |
|
|
- r = NewRUDP(true, svc_name, proc_interrupts, proc_rpc_recv, param, port, NULL, NULL, no_natt_register, over_dns_mode, NULL, natt_global_udp_port, rand_port_id); |
234 |
|
|
+ r = NewRUDP(true, svc_name, proc_interrupts, proc_rpc_recv, param, port, NULL, NULL, no_natt_register, over_dns_mode, NULL, natt_global_udp_port, rand_port_id, listen_ip); |
235 |
|
|
|
236 |
|
|
if (r == NULL) |
237 |
|
|
{ |
238 |
|
|
@@ -5345,7 +5345,7 @@ RUDP_STACK *NewRUDPServer(char *svc_name, RUDP_STACK_INTERRUPTS_PROC *proc_inter |
239 |
|
|
} |
240 |
|
|
|
241 |
|
|
// Creating a R-UDP |
242 |
|
|
-RUDP_STACK *NewRUDP(bool server_mode, char *svc_name, RUDP_STACK_INTERRUPTS_PROC *proc_interrupts, RUDP_STACK_RPC_RECV_PROC *proc_rpc_recv, void *param, UINT port, SOCK *sock, SOCK_EVENT *sock_event, bool server_no_natt_register, bool over_dns_mode, IP *client_target_ip, volatile UINT *natt_global_udp_port, UCHAR rand_port_id) |
243 |
|
|
+RUDP_STACK *NewRUDP(bool server_mode, char *svc_name, RUDP_STACK_INTERRUPTS_PROC *proc_interrupts, RUDP_STACK_RPC_RECV_PROC *proc_rpc_recv, void *param, UINT port, SOCK *sock, SOCK_EVENT *sock_event, bool server_no_natt_register, bool over_dns_mode, IP *client_target_ip, volatile UINT *natt_global_udp_port, UCHAR rand_port_id, IP *listen_ip) |
244 |
|
|
{ |
245 |
|
|
RUDP_STACK *r; |
246 |
|
|
char tmp[MAX_SIZE]; |
247 |
|
|
@@ -5371,11 +5371,11 @@ RUDP_STACK *NewRUDP(bool server_mode, char *svc_name, RUDP_STACK_INTERRUPTS_PROC |
248 |
|
|
{ |
249 |
|
|
if (rand_port_id == 0) |
250 |
|
|
{ |
251 |
|
|
- sock = NewUDP(port); |
252 |
|
|
+ sock = NewUDPEx2(port, false, listen_ip); |
253 |
|
|
} |
254 |
|
|
else |
255 |
|
|
{ |
256 |
|
|
- sock = NewUDPEx2RandMachineAndExePath(false, NULL, 0, rand_port_id); |
257 |
|
|
+ sock = NewUDPEx2RandMachineAndExePath(false, listen_ip, 0, rand_port_id); |
258 |
|
|
} |
259 |
|
|
} |
260 |
|
|
|
261 |
|
|
@@ -14202,9 +14202,9 @@ SOCK *Listen(UINT port) |
262 |
|
|
} |
263 |
|
|
SOCK *ListenEx(UINT port, bool local_only) |
264 |
|
|
{ |
265 |
|
|
- return ListenEx2(port, local_only, false); |
266 |
|
|
+ return ListenEx2(port, local_only, false, NULL); |
267 |
|
|
} |
268 |
|
|
-SOCK *ListenEx2(UINT port, bool local_only, bool enable_ca) |
269 |
|
|
+SOCK *ListenEx2(UINT port, bool local_only, bool enable_ca, IP *listen_ip) |
270 |
|
|
{ |
271 |
|
|
SOCKET s; |
272 |
|
|
SOCK *sock; |
273 |
|
|
@@ -14233,7 +14233,14 @@ SOCK *ListenEx2(UINT port, bool local_only, bool enable_ca) |
274 |
|
|
SetIP(&localhost, 127, 0, 0, 1); |
275 |
|
|
|
276 |
|
|
addr.sin_port = htons((UINT)port); |
277 |
|
|
- *((UINT *)&addr.sin_addr) = htonl(INADDR_ANY); |
278 |
|
|
+ if (listen_ip == NULL) |
279 |
|
|
+ { |
280 |
|
|
+ *((UINT *)&addr.sin_addr) = htonl(INADDR_ANY); |
281 |
|
|
+ } |
282 |
|
|
+ else |
283 |
|
|
+ { |
284 |
|
|
+ IPToInAddr(&addr.sin_addr, listen_ip); |
285 |
|
|
+ } |
286 |
|
|
addr.sin_family = AF_INET; |
287 |
|
|
|
288 |
|
|
if (local_only) |
289 |
|
|
@@ -20019,6 +20026,11 @@ void UdpListenerThread(THREAD *thread, void *param) |
290 |
|
|
{ |
291 |
|
|
IP *ip = LIST_DATA(iplist, i); |
292 |
|
|
|
293 |
|
|
+ if (CmpIpAddr(ip, &u->ListenIP) != 0) |
294 |
|
|
+ { |
295 |
|
|
+ continue; |
296 |
|
|
+ } |
297 |
|
|
+ |
298 |
|
|
WriteBuf(ip_list_buf_new, ip, sizeof(IP)); |
299 |
|
|
|
300 |
|
|
for (j = 0;j < LIST_NUM(u->PortList);j++) |
301 |
|
|
@@ -20534,7 +20546,7 @@ void UdpListenerSendPacket(UDPLISTENER *u, UDPPACKET *packet) |
302 |
|
|
} |
303 |
|
|
|
304 |
|
|
// Creating a UDP listener |
305 |
|
|
-UDPLISTENER *NewUdpListener(UDPLISTENER_RECV_PROC *recv_proc, void *param) |
306 |
|
|
+UDPLISTENER *NewUdpListener(UDPLISTENER_RECV_PROC *recv_proc, void *param, IP *listen_ip) |
307 |
|
|
{ |
308 |
|
|
UDPLISTENER *u; |
309 |
|
|
// Validate arguments |
310 |
|
|
@@ -20550,6 +20562,11 @@ UDPLISTENER *NewUdpListener(UDPLISTENER_RECV_PROC *recv_proc, void *param) |
311 |
|
|
u->PortList = NewList(NULL); |
312 |
|
|
u->Event = NewSockEvent(); |
313 |
|
|
|
314 |
|
|
+ if (listen_ip) |
315 |
|
|
+ { |
316 |
|
|
+ Copy(&u->ListenIP, listen_ip, sizeof(IP)); |
317 |
|
|
+ } |
318 |
|
|
+ |
319 |
|
|
u->RecvProc = recv_proc; |
320 |
|
|
u->SendPacketList = NewList(NULL); |
321 |
|
|
|
322 |
|
|
diff --git a/src/Mayaqua/Network.h b/src/Mayaqua/Network.h |
323 |
|
|
index 6f51bedf0..158485e64 100644 |
324 |
|
|
--- a/src/Mayaqua/Network.h |
325 |
|
|
+++ b/src/Mayaqua/Network.h |
326 |
|
|
@@ -599,6 +599,7 @@ struct UDPLISTENER |
327 |
|
|
bool IsEspRawPortOpened; // Whether the raw port opens |
328 |
|
|
bool PollMyIpAndPort; // Examine whether the global IP and the port number of its own |
329 |
|
|
QUERYIPTHREAD *GetNatTIpThread; // NAT-T IP address acquisition thread |
330 |
|
|
+ IP ListenIP; // Listen IP |
331 |
|
|
}; |
332 |
|
|
|
333 |
|
|
#define QUERYIPTHREAD_INTERVAL_LAST_OK (3 * 60 * 60 * 1000) |
334 |
|
|
@@ -1067,9 +1068,9 @@ void ConnectThreadForTcp(THREAD *thread, void *param); |
335 |
|
|
void ConnectThreadForRUDP(THREAD *thread, void *param); |
336 |
|
|
void ConnectThreadForOverDnsOrIcmp(THREAD *thread, void *param); |
337 |
|
|
SOCK *NewRUDPClientNatT(char *svc_name, IP *ip, UINT *error_code, UINT timeout, bool *cancel, char *hint_str, char *target_hostname); |
338 |
|
|
-RUDP_STACK *NewRUDPServer(char *svc_name, RUDP_STACK_INTERRUPTS_PROC *proc_interrupts, RUDP_STACK_RPC_RECV_PROC *proc_rpc_recv, void *param, UINT port, bool no_natt_register, bool over_dns_mode, volatile UINT *natt_global_udp_port, UCHAR rand_port_id); |
339 |
|
|
+RUDP_STACK *NewRUDPServer(char *svc_name, RUDP_STACK_INTERRUPTS_PROC *proc_interrupts, RUDP_STACK_RPC_RECV_PROC *proc_rpc_recv, void *param, UINT port, bool no_natt_register, bool over_dns_mode, volatile UINT *natt_global_udp_port, UCHAR rand_port_id, IP *listen_ip); |
340 |
|
|
SOCK *NewRUDPClientDirect(char *svc_name, IP *ip, UINT port, UINT *error_code, UINT timeout, bool *cancel, SOCK *sock, SOCK_EVENT *sock_event, UINT local_port, bool over_dns_mode); |
341 |
|
|
-RUDP_STACK *NewRUDP(bool server_mode, char *svc_name, RUDP_STACK_INTERRUPTS_PROC *proc_interrupts, RUDP_STACK_RPC_RECV_PROC *proc_rpc_recv, void *param, UINT port, SOCK *sock, SOCK_EVENT *sock_event, bool server_no_natt_register, bool over_dns_mode, IP *client_target_ip, volatile UINT *natt_global_udp_port, UCHAR rand_port_id); |
342 |
|
|
+RUDP_STACK *NewRUDP(bool server_mode, char *svc_name, RUDP_STACK_INTERRUPTS_PROC *proc_interrupts, RUDP_STACK_RPC_RECV_PROC *proc_rpc_recv, void *param, UINT port, SOCK *sock, SOCK_EVENT *sock_event, bool server_no_natt_register, bool over_dns_mode, IP *client_target_ip, volatile UINT *natt_global_udp_port, UCHAR rand_port_id, IP *listen_ip); |
343 |
|
|
void FreeRUDP(RUDP_STACK *r); |
344 |
|
|
void RUDPMainThread(THREAD *thread, void *param); |
345 |
|
|
void RUDPRecvProc(RUDP_STACK *r, UDPPACKET *p); |
346 |
|
|
@@ -1096,7 +1097,7 @@ UINT64 RUDPGetCurrentSendingMinSeqNo(RUDP_SESSION *se); |
347 |
|
|
UINT64 RUDPGetCurrentSendingMaxSeqNo(RUDP_SESSION *se); |
348 |
|
|
SOCK *ListenRUDP(char *svc_name, RUDP_STACK_INTERRUPTS_PROC *proc_interrupts, RUDP_STACK_RPC_RECV_PROC *proc_rpc_recv, void *param, UINT port, bool no_natt_register, bool over_dns_mode); |
349 |
|
|
SOCK *ListenRUDPEx(char *svc_name, RUDP_STACK_INTERRUPTS_PROC *proc_interrupts, RUDP_STACK_RPC_RECV_PROC *proc_rpc_recv, void *param, UINT port, bool no_natt_register, bool over_dns_mode, |
350 |
|
|
- volatile UINT *natt_global_udp_port, UCHAR rand_port_id); |
351 |
|
|
+ volatile UINT *natt_global_udp_port, UCHAR rand_port_id, IP *listen_ip); |
352 |
|
|
SOCK *AcceptRUDP(SOCK *s); |
353 |
|
|
void *InitWaitUntilHostIPAddressChanged(); |
354 |
|
|
void FreeWaitUntilHostIPAddressChanged(void *p); |
355 |
|
|
@@ -1286,7 +1287,7 @@ bool SetTtl(SOCK *sock, UINT ttl); |
356 |
|
|
void Disconnect(SOCK *sock); |
357 |
|
|
SOCK *Listen(UINT port); |
358 |
|
|
SOCK *ListenEx(UINT port, bool local_only); |
359 |
|
|
-SOCK *ListenEx2(UINT port, bool local_only, bool enable_ca); |
360 |
|
|
+SOCK *ListenEx2(UINT port, bool local_only, bool enable_ca, IP *listen_ip); |
361 |
|
|
SOCK *Listen6(UINT port); |
362 |
|
|
SOCK *ListenEx6(UINT port, bool local_only); |
363 |
|
|
SOCK *ListenEx62(UINT port, bool local_only, bool enable_ca); |
364 |
|
|
@@ -1556,7 +1557,7 @@ void AddHostIPAddressToList(LIST *o, IP *ip); |
365 |
|
|
int CmpIpAddressList(void *p1, void *p2); |
366 |
|
|
UINT64 GetHostIPAddressListHash(); |
367 |
|
|
|
368 |
|
|
-UDPLISTENER *NewUdpListener(UDPLISTENER_RECV_PROC *recv_proc, void *param); |
369 |
|
|
+UDPLISTENER *NewUdpListener(UDPLISTENER_RECV_PROC *recv_proc, void *param, IP *listen_ip); |
370 |
|
|
void UdpListenerThread(THREAD *thread, void *param); |
371 |
|
|
void UdpListenerGetPublicPortList(UDPLISTENER *u, char *dst, UINT size); |
372 |
|
|
void FreeUdpListener(UDPLISTENER *u); |
373 |
|
|
|
374 |
|
|
From 776d3816d0d368a086b870354a431d93378e19be Mon Sep 17 00:00:00 2001 |
375 |
|
|
From: macaronnik <macaronnik@gmail.com> |
376 |
|
|
Date: Thu, 12 Nov 2015 13:48:17 +0300 |
377 |
|
|
Subject: [PATCH 2/2] Fixed bug in VPN client |
378 |
|
|
|
379 |
|
|
--- |
380 |
|
|
src/Cedar/Listener.c | 9 ++++++++- |
381 |
|
|
1 file changed, 8 insertions(+), 1 deletion(-) |
382 |
|
|
|
383 |
|
|
diff --git a/src/Cedar/Listener.c b/src/Cedar/Listener.c |
384 |
|
|
index 3f586f69c..786450856 100644 |
385 |
|
|
--- a/src/Cedar/Listener.c |
386 |
|
|
+++ b/src/Cedar/Listener.c |
387 |
|
|
@@ -465,7 +465,14 @@ void ListenerTCPMainLoop(LISTENER *r) |
388 |
|
|
{ |
389 |
|
|
if (r->ShadowIPv6 == false) |
390 |
|
|
{ |
391 |
|
|
- s = ListenEx2(r->Port, r->LocalOnly, r->EnableConditionalAccept, &r->Cedar->Server->ListenIP); |
392 |
|
|
+ if (r->Cedar->Server == NULL) |
393 |
|
|
+ { |
394 |
|
|
+ s = ListenEx2(r->Port, r->LocalOnly, r->EnableConditionalAccept, NULL); |
395 |
|
|
+ } |
396 |
|
|
+ else |
397 |
|
|
+ { |
398 |
|
|
+ s = ListenEx2(r->Port, r->LocalOnly, r->EnableConditionalAccept, &r->Cedar->Server->ListenIP); |
399 |
|
|
+ } |
400 |
|
|
} |
401 |
|
|
else |
402 |
|
|
{ |
403 |
jpp |
1.2 |
--- v4.34-9744//src/Cedar/Server.h.orig 2020-03-28 14:23:47.171000000 -0400 |
404 |
|
|
+++ v4.34-9744//src/Cedar/Server.h 2020-03-28 14:35:15.322000000 -0400 |
405 |
|
|
@@ -361,6 +361,7 @@ |
406 |
|
|
|
407 |
|
|
|
408 |
|
|
volatile UINT NatTGlobalUdpPort; // NAT-T global UDP port |
409 |
|
|
+ IP ListenIP; // Listen IP |
410 |
|
|
|
411 |
|
|
bool StrictSyslogDatetimeFormat; // Make syslog datetime format strict RFC3164 |
412 |
|
|
bool DisableJsonRpcWebApi; // Disable JSON-RPC Web API |