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/Cedar/Server.h b/src/Cedar/Server.h |
188 |
index 1567a3494..febff1099 100644 |
189 |
--- a/src/Cedar/Server.h |
190 |
+++ b/src/Cedar/Server.h |
191 |
@@ -367,6 +367,8 @@ struct SERVER |
192 |
|
193 |
|
194 |
volatile UINT NatTGlobalUdpPort; // NAT-T global UDP port |
195 |
+ |
196 |
+ IP ListenIP; // Listen IP |
197 |
}; |
198 |
|
199 |
|
200 |
diff --git a/src/Mayaqua/Network.c b/src/Mayaqua/Network.c |
201 |
index def2f45e6..aec224148 100644 |
202 |
--- a/src/Mayaqua/Network.c |
203 |
+++ b/src/Mayaqua/Network.c |
204 |
@@ -2724,16 +2724,16 @@ void RUDPBulkSend(RUDP_STACK *r, RUDP_SESSION *se, void *data, UINT data_size) |
205 |
// Start a socket for R-UDP Listening |
206 |
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) |
207 |
{ |
208 |
- return ListenRUDPEx(svc_name, proc_interrupts, proc_rpc_recv, param, port, no_natt_register, over_dns_mode, NULL, 0); |
209 |
+ return ListenRUDPEx(svc_name, proc_interrupts, proc_rpc_recv, param, port, no_natt_register, over_dns_mode, NULL, 0, NULL); |
210 |
} |
211 |
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, |
212 |
- volatile UINT *natt_global_udp_port, UCHAR rand_port_id) |
213 |
+ volatile UINT *natt_global_udp_port, UCHAR rand_port_id, IP *listen_ip) |
214 |
{ |
215 |
SOCK *s; |
216 |
RUDP_STACK *r; |
217 |
|
218 |
// Creating a R-UDP stack |
219 |
- r = NewRUDPServer(svc_name, proc_interrupts, proc_rpc_recv, param, port, no_natt_register, over_dns_mode, natt_global_udp_port, rand_port_id); |
220 |
+ 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); |
221 |
if (r == NULL) |
222 |
{ |
223 |
return NULL; |
224 |
@@ -5259,7 +5259,7 @@ SOCK *NewRUDPClientDirect(char *svc_name, IP *ip, UINT port, UINT *error_code, U |
225 |
return NULL; |
226 |
} |
227 |
|
228 |
- r = NewRUDP(false, svc_name, NULL, NULL, NULL, local_port, sock, sock_event, false, over_dns_mode, ip, NULL, 0); |
229 |
+ r = NewRUDP(false, svc_name, NULL, NULL, NULL, local_port, sock, sock_event, false, over_dns_mode, ip, NULL, 0, NULL); |
230 |
if (r == NULL) |
231 |
{ |
232 |
*error_code = RUDP_ERROR_UNKNOWN; |
233 |
@@ -5318,7 +5318,7 @@ SOCK *NewRUDPClientDirect(char *svc_name, IP *ip, UINT port, UINT *error_code, U |
234 |
} |
235 |
|
236 |
// Creating a R-UDP server |
237 |
-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) |
238 |
+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) |
239 |
{ |
240 |
RUDP_STACK *r; |
241 |
// Validate arguments |
242 |
@@ -5334,7 +5334,7 @@ RUDP_STACK *NewRUDPServer(char *svc_name, RUDP_STACK_INTERRUPTS_PROC *proc_inter |
243 |
|
244 |
ListenTcpForPopupFirewallDialog(); |
245 |
|
246 |
- 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); |
247 |
+ 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); |
248 |
|
249 |
if (r == NULL) |
250 |
{ |
251 |
@@ -5345,7 +5345,7 @@ RUDP_STACK *NewRUDPServer(char *svc_name, RUDP_STACK_INTERRUPTS_PROC *proc_inter |
252 |
} |
253 |
|
254 |
// Creating a R-UDP |
255 |
-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) |
256 |
+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) |
257 |
{ |
258 |
RUDP_STACK *r; |
259 |
char tmp[MAX_SIZE]; |
260 |
@@ -5371,11 +5371,11 @@ RUDP_STACK *NewRUDP(bool server_mode, char *svc_name, RUDP_STACK_INTERRUPTS_PROC |
261 |
{ |
262 |
if (rand_port_id == 0) |
263 |
{ |
264 |
- sock = NewUDP(port); |
265 |
+ sock = NewUDPEx2(port, false, listen_ip); |
266 |
} |
267 |
else |
268 |
{ |
269 |
- sock = NewUDPEx2RandMachineAndExePath(false, NULL, 0, rand_port_id); |
270 |
+ sock = NewUDPEx2RandMachineAndExePath(false, listen_ip, 0, rand_port_id); |
271 |
} |
272 |
} |
273 |
|
274 |
@@ -14202,9 +14202,9 @@ SOCK *Listen(UINT port) |
275 |
} |
276 |
SOCK *ListenEx(UINT port, bool local_only) |
277 |
{ |
278 |
- return ListenEx2(port, local_only, false); |
279 |
+ return ListenEx2(port, local_only, false, NULL); |
280 |
} |
281 |
-SOCK *ListenEx2(UINT port, bool local_only, bool enable_ca) |
282 |
+SOCK *ListenEx2(UINT port, bool local_only, bool enable_ca, IP *listen_ip) |
283 |
{ |
284 |
SOCKET s; |
285 |
SOCK *sock; |
286 |
@@ -14233,7 +14233,14 @@ SOCK *ListenEx2(UINT port, bool local_only, bool enable_ca) |
287 |
SetIP(&localhost, 127, 0, 0, 1); |
288 |
|
289 |
addr.sin_port = htons((UINT)port); |
290 |
- *((UINT *)&addr.sin_addr) = htonl(INADDR_ANY); |
291 |
+ if (listen_ip == NULL) |
292 |
+ { |
293 |
+ *((UINT *)&addr.sin_addr) = htonl(INADDR_ANY); |
294 |
+ } |
295 |
+ else |
296 |
+ { |
297 |
+ IPToInAddr(&addr.sin_addr, listen_ip); |
298 |
+ } |
299 |
addr.sin_family = AF_INET; |
300 |
|
301 |
if (local_only) |
302 |
@@ -20019,6 +20026,11 @@ void UdpListenerThread(THREAD *thread, void *param) |
303 |
{ |
304 |
IP *ip = LIST_DATA(iplist, i); |
305 |
|
306 |
+ if (CmpIpAddr(ip, &u->ListenIP) != 0) |
307 |
+ { |
308 |
+ continue; |
309 |
+ } |
310 |
+ |
311 |
WriteBuf(ip_list_buf_new, ip, sizeof(IP)); |
312 |
|
313 |
for (j = 0;j < LIST_NUM(u->PortList);j++) |
314 |
@@ -20534,7 +20546,7 @@ void UdpListenerSendPacket(UDPLISTENER *u, UDPPACKET *packet) |
315 |
} |
316 |
|
317 |
// Creating a UDP listener |
318 |
-UDPLISTENER *NewUdpListener(UDPLISTENER_RECV_PROC *recv_proc, void *param) |
319 |
+UDPLISTENER *NewUdpListener(UDPLISTENER_RECV_PROC *recv_proc, void *param, IP *listen_ip) |
320 |
{ |
321 |
UDPLISTENER *u; |
322 |
// Validate arguments |
323 |
@@ -20550,6 +20562,11 @@ UDPLISTENER *NewUdpListener(UDPLISTENER_RECV_PROC *recv_proc, void *param) |
324 |
u->PortList = NewList(NULL); |
325 |
u->Event = NewSockEvent(); |
326 |
|
327 |
+ if (listen_ip) |
328 |
+ { |
329 |
+ Copy(&u->ListenIP, listen_ip, sizeof(IP)); |
330 |
+ } |
331 |
+ |
332 |
u->RecvProc = recv_proc; |
333 |
u->SendPacketList = NewList(NULL); |
334 |
|
335 |
diff --git a/src/Mayaqua/Network.h b/src/Mayaqua/Network.h |
336 |
index 6f51bedf0..158485e64 100644 |
337 |
--- a/src/Mayaqua/Network.h |
338 |
+++ b/src/Mayaqua/Network.h |
339 |
@@ -599,6 +599,7 @@ struct UDPLISTENER |
340 |
bool IsEspRawPortOpened; // Whether the raw port opens |
341 |
bool PollMyIpAndPort; // Examine whether the global IP and the port number of its own |
342 |
QUERYIPTHREAD *GetNatTIpThread; // NAT-T IP address acquisition thread |
343 |
+ IP ListenIP; // Listen IP |
344 |
}; |
345 |
|
346 |
#define QUERYIPTHREAD_INTERVAL_LAST_OK (3 * 60 * 60 * 1000) |
347 |
@@ -1067,9 +1068,9 @@ void ConnectThreadForTcp(THREAD *thread, void *param); |
348 |
void ConnectThreadForRUDP(THREAD *thread, void *param); |
349 |
void ConnectThreadForOverDnsOrIcmp(THREAD *thread, void *param); |
350 |
SOCK *NewRUDPClientNatT(char *svc_name, IP *ip, UINT *error_code, UINT timeout, bool *cancel, char *hint_str, char *target_hostname); |
351 |
-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); |
352 |
+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); |
353 |
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); |
354 |
-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); |
355 |
+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); |
356 |
void FreeRUDP(RUDP_STACK *r); |
357 |
void RUDPMainThread(THREAD *thread, void *param); |
358 |
void RUDPRecvProc(RUDP_STACK *r, UDPPACKET *p); |
359 |
@@ -1096,7 +1097,7 @@ UINT64 RUDPGetCurrentSendingMinSeqNo(RUDP_SESSION *se); |
360 |
UINT64 RUDPGetCurrentSendingMaxSeqNo(RUDP_SESSION *se); |
361 |
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); |
362 |
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, |
363 |
- volatile UINT *natt_global_udp_port, UCHAR rand_port_id); |
364 |
+ volatile UINT *natt_global_udp_port, UCHAR rand_port_id, IP *listen_ip); |
365 |
SOCK *AcceptRUDP(SOCK *s); |
366 |
void *InitWaitUntilHostIPAddressChanged(); |
367 |
void FreeWaitUntilHostIPAddressChanged(void *p); |
368 |
@@ -1286,7 +1287,7 @@ bool SetTtl(SOCK *sock, UINT ttl); |
369 |
void Disconnect(SOCK *sock); |
370 |
SOCK *Listen(UINT port); |
371 |
SOCK *ListenEx(UINT port, bool local_only); |
372 |
-SOCK *ListenEx2(UINT port, bool local_only, bool enable_ca); |
373 |
+SOCK *ListenEx2(UINT port, bool local_only, bool enable_ca, IP *listen_ip); |
374 |
SOCK *Listen6(UINT port); |
375 |
SOCK *ListenEx6(UINT port, bool local_only); |
376 |
SOCK *ListenEx62(UINT port, bool local_only, bool enable_ca); |
377 |
@@ -1556,7 +1557,7 @@ void AddHostIPAddressToList(LIST *o, IP *ip); |
378 |
int CmpIpAddressList(void *p1, void *p2); |
379 |
UINT64 GetHostIPAddressListHash(); |
380 |
|
381 |
-UDPLISTENER *NewUdpListener(UDPLISTENER_RECV_PROC *recv_proc, void *param); |
382 |
+UDPLISTENER *NewUdpListener(UDPLISTENER_RECV_PROC *recv_proc, void *param, IP *listen_ip); |
383 |
void UdpListenerThread(THREAD *thread, void *param); |
384 |
void UdpListenerGetPublicPortList(UDPLISTENER *u, char *dst, UINT size); |
385 |
void FreeUdpListener(UDPLISTENER *u); |
386 |
|
387 |
From 776d3816d0d368a086b870354a431d93378e19be Mon Sep 17 00:00:00 2001 |
388 |
From: macaronnik <macaronnik@gmail.com> |
389 |
Date: Thu, 12 Nov 2015 13:48:17 +0300 |
390 |
Subject: [PATCH 2/2] Fixed bug in VPN client |
391 |
|
392 |
--- |
393 |
src/Cedar/Listener.c | 9 ++++++++- |
394 |
1 file changed, 8 insertions(+), 1 deletion(-) |
395 |
|
396 |
diff --git a/src/Cedar/Listener.c b/src/Cedar/Listener.c |
397 |
index 3f586f69c..786450856 100644 |
398 |
--- a/src/Cedar/Listener.c |
399 |
+++ b/src/Cedar/Listener.c |
400 |
@@ -465,7 +465,14 @@ void ListenerTCPMainLoop(LISTENER *r) |
401 |
{ |
402 |
if (r->ShadowIPv6 == false) |
403 |
{ |
404 |
- s = ListenEx2(r->Port, r->LocalOnly, r->EnableConditionalAccept, &r->Cedar->Server->ListenIP); |
405 |
+ if (r->Cedar->Server == NULL) |
406 |
+ { |
407 |
+ s = ListenEx2(r->Port, r->LocalOnly, r->EnableConditionalAccept, NULL); |
408 |
+ } |
409 |
+ else |
410 |
+ { |
411 |
+ s = ListenEx2(r->Port, r->LocalOnly, r->EnableConditionalAccept, &r->Cedar->Server->ListenIP); |
412 |
+ } |
413 |
} |
414 |
else |
415 |
{ |