mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2025-07-08 00:34:57 +03:00
Add parameter "ListenIP" to server configuration (vpn_server.config) (#202)
* Added parameter "ListenIP" to server configuration (vpn_server.config) * Fixed bug in VPN client
This commit is contained in:
@ -545,6 +545,8 @@ void IPsecServerSetServices(IPSEC_SERVER *s, IPSEC_SERVICES *sl)
|
||||
{
|
||||
Copy(&s->Services, sl, sizeof(IPSEC_SERVICES));
|
||||
|
||||
Copy(&s->UdpListener->ListenIP, &s->Cedar->Server->ListenIP, sizeof(IP));
|
||||
|
||||
if (sl->L2TP_Raw)
|
||||
{
|
||||
AddPortToUdpListener(s->UdpListener, IPSEC_PORT_L2TP);
|
||||
@ -782,7 +784,7 @@ IPSEC_SERVER *NewIPsecServer(CEDAR *cedar)
|
||||
s->Ike = NewIKEServer(cedar, s);
|
||||
StrCpy(s->Ike->Secret, sizeof(s->Ike->Secret), IPSEC_DEFAULT_SECRET);
|
||||
|
||||
s->UdpListener = NewUdpListener(IPsecServerUdpPacketRecvProc, s);
|
||||
s->UdpListener = NewUdpListener(IPsecServerUdpPacketRecvProc, s, &cedar->Server->ListenIP);
|
||||
|
||||
s->EtherIPIdList = NewList(CmpEtherIPId);
|
||||
|
||||
|
@ -2695,7 +2695,7 @@ OPENVPN_SERVER_UDP *NewOpenVpnServerUdp(CEDAR *cedar)
|
||||
AddRef(u->Cedar->ref);
|
||||
|
||||
// Create a UDP listener
|
||||
u->UdpListener = NewUdpListener(OpenVpnServerUdpListenerProc, u);
|
||||
u->UdpListener = NewUdpListener(OpenVpnServerUdpListenerProc, u, &cedar->Server->ListenIP);
|
||||
|
||||
// Create an OpenVPN server
|
||||
u->OpenVpnServer = NewOpenVpnServer(cedar, u->UdpListener->Interrupts, u->UdpListener->Event);
|
||||
@ -2704,7 +2704,7 @@ OPENVPN_SERVER_UDP *NewOpenVpnServerUdp(CEDAR *cedar)
|
||||
}
|
||||
|
||||
// Apply the port list to the OpenVPN server
|
||||
void OvsApplyUdpPortList(OPENVPN_SERVER_UDP *u, char *port_list)
|
||||
void OvsApplyUdpPortList(OPENVPN_SERVER_UDP *u, char *port_list, IP *listen_ip)
|
||||
{
|
||||
LIST *o;
|
||||
UINT i;
|
||||
@ -2716,6 +2716,11 @@ void OvsApplyUdpPortList(OPENVPN_SERVER_UDP *u, char *port_list)
|
||||
|
||||
DeleteAllPortFromUdpListener(u->UdpListener);
|
||||
|
||||
if (u->UdpListener != NULL && listen_ip != NULL)
|
||||
{
|
||||
Copy(&u->UdpListener->ListenIP, listen_ip, sizeof(IP));
|
||||
}
|
||||
|
||||
o = StrToIntList(port_list, true);
|
||||
|
||||
for (i = 0;i < LIST_NUM(o);i++)
|
||||
|
@ -319,7 +319,7 @@ struct OPENVPN_SERVER_UDP
|
||||
OPENVPN_SERVER_UDP *NewOpenVpnServerUdp(CEDAR *cedar);
|
||||
void FreeOpenVpnServerUdp(OPENVPN_SERVER_UDP *u);
|
||||
void OpenVpnServerUdpListenerProc(UDPLISTENER *u, LIST *packet_list);
|
||||
void OvsApplyUdpPortList(OPENVPN_SERVER_UDP *u, char *port_list);
|
||||
void OvsApplyUdpPortList(OPENVPN_SERVER_UDP *u, char *port_list, IP *listen_ip);
|
||||
|
||||
OPENVPN_SERVER *NewOpenVpnServer(CEDAR *cedar, INTERRUPT_MANAGER *interrupt, SOCK_EVENT *sock_event);
|
||||
void FreeOpenVpnServer(OPENVPN_SERVER *s);
|
||||
|
@ -356,7 +356,7 @@ void ListenerUDPMainLoop(LISTENER *r)
|
||||
}
|
||||
|
||||
Debug("NewUDP()\n");
|
||||
r->Sock = NewUDP(r->Port);
|
||||
r->Sock = NewUDPEx2(r->Port, false, &r->Cedar->Server->ListenIP);
|
||||
if (r->Sock != NULL)
|
||||
{
|
||||
// Wait success
|
||||
@ -465,7 +465,14 @@ void ListenerTCPMainLoop(LISTENER *r)
|
||||
{
|
||||
if (r->ShadowIPv6 == false)
|
||||
{
|
||||
s = ListenEx2(r->Port, r->LocalOnly, r->EnableConditionalAccept);
|
||||
if (r->Cedar->Server == NULL)
|
||||
{
|
||||
s = ListenEx2(r->Port, r->LocalOnly, r->EnableConditionalAccept, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
s = ListenEx2(r->Port, r->LocalOnly, r->EnableConditionalAccept, &r->Cedar->Server->ListenIP);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -478,7 +485,7 @@ void ListenerTCPMainLoop(LISTENER *r)
|
||||
}
|
||||
else if (r->Protocol == LISTENER_RUDP)
|
||||
{
|
||||
s = ListenRUDPEx(VPN_RUDP_SVC_NAME, NULL, ListenerRUDPRpcRecvProc, NULL, 0, false, false, r->NatTGlobalUdpPort, r->RandPortId);
|
||||
s = ListenRUDPEx(VPN_RUDP_SVC_NAME, NULL, ListenerRUDPRpcRecvProc, NULL, 0, false, false, r->NatTGlobalUdpPort, r->RandPortId, &r->Cedar->Server->ListenIP);
|
||||
}
|
||||
else if (r->Protocol == LISTENER_ICMP)
|
||||
{
|
||||
|
@ -227,13 +227,13 @@ void SetSysLog(SLOG *g, char *hostname, UINT port)
|
||||
}
|
||||
|
||||
// Create a syslog client
|
||||
SLOG *NewSysLog(char *hostname, UINT port)
|
||||
SLOG *NewSysLog(char *hostname, UINT port, IP *ip)
|
||||
{
|
||||
// Validate arguments
|
||||
SLOG *g = ZeroMalloc(sizeof(SLOG));
|
||||
|
||||
g->lock = NewLock();
|
||||
g->Udp = NewUDP(0);
|
||||
g->Udp = NewUDPEx2(0, false, ip);
|
||||
|
||||
SetSysLog(g, hostname, port);
|
||||
|
||||
|
@ -263,7 +263,7 @@ LIST *GenerateEraseFileList(ERASER *e);
|
||||
void FreeEraseFileList(LIST *o);
|
||||
void PrintEraseFileList(LIST *o);
|
||||
void EnumEraseFile(LIST *o, char *dirname);
|
||||
SLOG *NewSysLog(char *hostname, UINT port);
|
||||
SLOG *NewSysLog(char *hostname, UINT port, IP *ip);
|
||||
void SetSysLog(SLOG *g, char *hostname, UINT port);
|
||||
void FreeSysLog(SLOG *g);
|
||||
void SendSysLog(SLOG *g, wchar_t *str);
|
||||
|
@ -159,11 +159,11 @@ void SiSetOpenVPNAndSSTPConfig(SERVER *s, OPENVPN_SSTP_CONFIG *c)
|
||||
{
|
||||
if (s->DisableOpenVPNServer)
|
||||
{
|
||||
OvsApplyUdpPortList(s->OpenVpnServerUdp, "");
|
||||
OvsApplyUdpPortList(s->OpenVpnServerUdp, "", NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
OvsApplyUdpPortList(s->OpenVpnServerUdp, s->OpenVpnServerUdpPorts);
|
||||
OvsApplyUdpPortList(s->OpenVpnServerUdp, s->OpenVpnServerUdpPorts, &s->ListenIP);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5831,6 +5831,7 @@ void SiLoadServerCfg(SERVER *s, FOLDER *f)
|
||||
}
|
||||
|
||||
s->DontBackupConfig = CfgGetBool(f, "DontBackupConfig");
|
||||
CfgGetIp(f, "ListenIP", &s->ListenIP);
|
||||
|
||||
if (CfgIsItem(f, "BackupConfigOnlyWhenModified"))
|
||||
{
|
||||
@ -6287,6 +6288,7 @@ void SiWriteServerCfg(FOLDER *f, SERVER *s)
|
||||
CfgAddBool(f, "DontBackupConfig", s->DontBackupConfig);
|
||||
CfgAddBool(f, "BackupConfigOnlyWhenModified", s->BackupConfigOnlyWhenModified);
|
||||
|
||||
CfgAddIp(f, "ListenIP", &s->ListenIP);
|
||||
if (s->Logger != NULL)
|
||||
{
|
||||
CfgAddInt(f, "ServerLogSwitchType", s->Logger->SwitchType);
|
||||
@ -10965,8 +10967,6 @@ SERVER *SiNewServerEx(bool bridge, bool in_client_inner_server, bool relay_serve
|
||||
s->Cedar->CheckExpires = true;
|
||||
s->ServerListenerList = NewList(CompareServerListener);
|
||||
s->StartTime = SystemTime64();
|
||||
s->Syslog = NewSysLog(NULL, 0);
|
||||
s->SyslogLock = NewLock();
|
||||
s->TasksFromFarmControllerLock = NewLock();
|
||||
|
||||
if (bridge)
|
||||
@ -10998,6 +10998,9 @@ SERVER *SiNewServerEx(bool bridge, bool in_client_inner_server, bool relay_serve
|
||||
// Initialize the configuration
|
||||
SiInitConfiguration(s);
|
||||
|
||||
s->Syslog = NewSysLog(NULL, 0, &s->Cedar->Server->ListenIP);
|
||||
s->SyslogLock = NewLock();
|
||||
|
||||
SetFifoCurrentReallocMemSize(MEM_FIFO_REALLOC_MEM_SIZE);
|
||||
|
||||
|
||||
|
@ -368,6 +368,7 @@ struct SERVER
|
||||
|
||||
volatile UINT NatTGlobalUdpPort; // NAT-T global UDP port
|
||||
|
||||
IP ListenIP; // Listen IP
|
||||
bool StrictSyslogDatetimeFormat; // Make syslog datetime format strict RFC3164
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user