1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2025-07-07 00:04:57 +03:00

Merge branch 'master' into autoconnect

This commit is contained in:
ELIN
2014-02-08 06:06:19 +00:00
315 changed files with 1748 additions and 318 deletions

View File

@ -12,6 +12,8 @@
// http://www.softether.org/
//
// Author: Daiyuu Nobori
// Contributors:
// - ELIN (https://github.com/el1n)
// Comments: Tetsuo Sugiyama, Ph.D.
//
//
@ -13212,6 +13214,9 @@ bool CheckAdminSourceAddress(SOCK *sock, char *hubname)
UINT i;
TOKEN_LIST *t;
IP ip;
IP mask;
IP ip1;
IP ip2;
s = CfgReadNextLine(b);
if (s == NULL)
@ -13242,7 +13247,30 @@ bool CheckAdminSourceAddress(SOCK *sock, char *hubname)
{
if (t->NumTokens == 1 || StrCmpi(hubname, t->Token[1]) == 0)
{
if (StrToIP(&ip, t->Token[0]))
if (ParseIpAndMask46(t->Token[0], &ip, &mask))
{
if (IsIP4(&sock->RemoteIP) && IsIP4(&ip))
{
IPAnd4(&ip1, &sock->RemoteIP, &mask);
IPAnd4(&ip2, &ip, &mask);
if (CmpIpAddr(&ip1, &ip2) == 0)
{
ok = true;
}
}
else if (IsIP6(&sock->RemoteIP) && IsIP6(&ip))
{
IPAnd6(&ip1, &sock->RemoteIP, &mask);
IPAnd6(&ip2, &ip, &mask);
if (CmpIpAddr(&ip1, &ip2) == 0)
{
ok = true;
}
}
}
else if (StrToIP(&ip, t->Token[0]))
{
if (CmpIpAddr(&sock->RemoteIP, &ip) == 0)
{

View File

@ -114,10 +114,10 @@
// Version number
#define CEDAR_VER 404
#define CEDAR_VER 405
// Build Number
#define CEDAR_BUILD 9412
#define CEDAR_BUILD 9418
// Beta number
//#define BETA_NUMBER 3
@ -137,11 +137,11 @@
// Specifies the build date
#define BUILD_DATE_Y 2014
#define BUILD_DATE_M 1
#define BUILD_DATE_D 15
#define BUILD_DATE_HO 17
#define BUILD_DATE_MI 22
#define BUILD_DATE_SE 14
#define BUILD_DATE_M 2
#define BUILD_DATE_D 6
#define BUILD_DATE_HO 1
#define BUILD_DATE_MI 58
#define BUILD_DATE_SE 47
// Tolerable time difference
#define ALLOW_TIMESTAMP_DIFF (UINT64)(3 * 24 * 60 * 60 * 1000)
@ -705,7 +705,15 @@
#define TAP_FILENAME_1 "/dev/net/tun"
#define TAP_FILENAME_2 "/dev/tun"
#ifdef UNIX_MACOS
#ifdef NO_VLAN
#define TAP_MACOS_FILENAME "/dev/tap0"
#else // NO_VLAN
#define TAP_MACOS_FILENAME "tap"
#endif // NO_VLAN
#define TAP_MACOS_DIR "/dev/"
#define TAP_MACOS_NUMBER (16)
#endif // UNIX_MACOS

View File

@ -12,6 +12,8 @@
// http://www.softether.org/
//
// Author: Daiyuu Nobori
// Contributors:
// - nattoheaven (https://github.com/nattoheaven)
// Comments: Tetsuo Sugiyama, Ph.D.
//
//
@ -7455,12 +7457,14 @@ bool CtDisableVLan(CLIENT *c, RPC_CLIENT_CREATE_VLAN *vlan)
#ifndef OS_WIN32
#ifdef NO_VLAN
if (GetOsInfo()->OsType == OSTYPE_MACOS_X)
{
// Can not be added or removed the virtual LAN card in MacOS X
CiSetError(c, ERR_NOT_SUPPORTED);
return false;
}
#endif // NO_VLAN
// Check whether the virtual LAN card with the specified name is not
// being used by one or more accounts
@ -7606,12 +7610,14 @@ bool CtEnableVLan(CLIENT *c, RPC_CLIENT_CREATE_VLAN *vlan)
#ifndef OS_WIN32
#ifdef NO_VLAN
if (GetOsInfo()->OsType == OSTYPE_MACOS_X)
{
// Can not be added or removed the virtual LAN card in MacOS X
CiSetError(c, ERR_NOT_SUPPORTED);
return false;
}
#endif // NO_VLAN
// Search the virtual LAN card
LockList(c->UnixVLanList);
@ -7702,12 +7708,14 @@ bool CtDeleteVLan(CLIENT *c, RPC_CLIENT_CREATE_VLAN *d)
#ifndef OS_WIN32
#ifdef NO_VLAN
if (GetOsInfo()->OsType == OSTYPE_MACOS_X)
{
// Can not be added or removed the virtual LAN card in MacOS X
CiSetError(c, ERR_NOT_SUPPORTED);
return false;
}
#endif // NO_VLAN
// Check whether the virtual LAN card with the specified name is not
// being used by one or more accounts
@ -8274,12 +8282,14 @@ bool CtCreateVLan(CLIENT *c, RPC_CLIENT_CREATE_VLAN *create)
#ifndef OS_WIN32
// Non-Win32
#ifdef NO_VLAN
if (GetOsInfo()->OsType == OSTYPE_MACOS_X)
{
// A virtual LAN card can not be added or removed in MacOS X
CiSetError(c, ERR_NOT_SUPPORTED);
return false;
}
#endif // NO_VLAN
// Check whether the specified name is valid or not
if (IsSafeStr(create->DeviceName) == false)
@ -9801,7 +9811,11 @@ bool CiReadSettingFromCfg(CLIENT *c, FOLDER *root)
// Eraser
c->Eraser = NewEraser(c->Logger, CfgGetInt64(config, "AutoDeleteCheckDiskFreeSpaceMin"));
if (OS_IS_UNIX(GetOsInfo()->OsType) && GetOsInfo()->OsType != OSTYPE_MACOS_X)
if (OS_IS_UNIX(GetOsInfo()->OsType)
#ifdef NO_VLAN
&& GetOsInfo()->OsType != OSTYPE_MACOS_X
#endif // NO_VLAN
)
{
// Read the UNIX version virtual LAN card list (except MacOS)
vlan = CfgGetFolder(root, "UnixVLan");
@ -9811,6 +9825,7 @@ bool CiReadSettingFromCfg(CLIENT *c, FOLDER *root)
}
}
#ifdef NO_VLAN
if (GetOsInfo()->OsType == OSTYPE_MACOS_X)
{
#ifdef OS_UNIX
@ -9831,7 +9846,7 @@ bool CiReadSettingFromCfg(CLIENT *c, FOLDER *root)
Add(c->UnixVLanList, uv);
#endif // OS_UNIX
}
#endif // NO_VLAN
CiLoadAccountDatabase(c, db);
if (CfgGetByte(root, "EncryptedPassword", c->EncryptedPassword, SHA1_SIZE) == false)
@ -10337,7 +10352,11 @@ void CiWriteSettingToCfg(CLIENT *c, FOLDER *root)
CiWriteCAList(c, ca);
// VLAN
if (OS_IS_UNIX(GetOsInfo()->OsType) && GetOsInfo()->OsType != OSTYPE_MACOS_X)
if (OS_IS_UNIX(GetOsInfo()->OsType)
#ifdef NO_VLAN
&& GetOsInfo()->OsType != OSTYPE_MACOS_X
#endif // NO_VLAN
)
{
vlan = CfgCreateFolder(root, "UnixVLan");
CiWriteVLanList(c, vlan);

View File

@ -12,6 +12,8 @@
// http://www.softether.org/
//
// Author: Daiyuu Nobori
// Contributors:
// - nattoheaven (https://github.com/nattoheaven)
// Comments: Tetsuo Sugiyama, Ph.D.
//
//
@ -311,11 +313,7 @@ CANCEL *VLanGetCancel(VLAN *v)
fd = v->fd;
#ifndef UNIX_MACOS
UnixSetSocketNonBlockingMode(fd, true);
#else // UNIX_MACOS
UnixSetSocketNonBlockingMode(fd, false);
#endif // UNIX_MACOS
c->SpecialFlag = true;
c->pipe_read = fd;
@ -411,6 +409,9 @@ int UnixCreateTapDeviceEx(char *name, char *prefix, UCHAR *mac_address)
struct sockaddr sa;
char *tap_name = TAP_FILENAME_1;
int s;
#ifdef UNIX_MACOS
char tap_macos_name[256] = TAP_MACOS_DIR TAP_MACOS_FILENAME;
#endif
// Validate arguments
if (name == NULL)
{
@ -454,13 +455,23 @@ int UnixCreateTapDeviceEx(char *name, char *prefix, UCHAR *mac_address)
tap_name = TAP_FILENAME_2;
}
#else // UNIX_MACOS
// MacOS X
fd = open(TAP_MACOS_FILENAME, O_RDWR);
if (fd == -1)
{
return -1;
int i;
fd = -1;
for (i = 0; i < TAP_MACOS_NUMBER; i++) {
sprintf(tap_macos_name + strlen(TAP_MACOS_DIR TAP_MACOS_FILENAME), "%d", i);
fd = open(tap_macos_name, O_RDWR);
if (fd != -1)
{
tap_name = tap_macos_name;
break;
}
}
if (fd == -1)
{
return -1;
}
}
tap_name = TAP_MACOS_FILENAME;
#endif // UNIX_MACOS
#ifdef UNIX_LINUX
@ -488,7 +499,7 @@ int UnixCreateTapDeviceEx(char *name, char *prefix, UCHAR *mac_address)
Zero(&ifr, sizeof(ifr));
StrCpy(ifr.ifr_name, sizeof(ifr.ifr_name), eth_name);
ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
Copy(&ifr.ifr_hwaddr.sa_data, mac_address, 6);
Copy(&ifr.ifr_addr.sa_data, mac_address, 6);
ioctl(s, SIOCSIFHWADDR, &ifr);
}
@ -503,6 +514,33 @@ int UnixCreateTapDeviceEx(char *name, char *prefix, UCHAR *mac_address)
}
#else // UNIX_LINUX
#ifdef UNIX_MACOS
// MAC address setting
s = socket(AF_INET, SOCK_DGRAM, 0);
if (s != -1)
{
char *macos_eth_name;
macos_eth_name = tap_macos_name + strlen(TAP_MACOS_DIR);
if (mac_address != NULL)
{
uint8_t macos_mac_address[19];
Zero(&ifr, sizeof(ifr));
StrCpy(ifr.ifr_name, sizeof(ifr.ifr_name), macos_eth_name);
Copy(&ifr.ifr_addr.sa_data, mac_address, 6);
ioctl(s, SIOCSIFLLADDR, &ifr);
}
Zero(&ifr, sizeof(ifr));
StrCpy(ifr.ifr_name, sizeof(ifr.ifr_name), macos_eth_name);
ioctl(s, SIOCGIFFLAGS, &ifr);
ifr.ifr_flags |= IFF_UP;
ioctl(s, SIOCSIFFLAGS, &ifr);
close(s);
}
#endif // UNIX_MACOS
#ifdef UNIX_SOLARIS
// Create a tap for Solaris
{

View File

@ -3729,9 +3729,22 @@ UINT AboutDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param
CombinePathW(path, sizeof(path), MsGetExeDirNameW(), L"vpnsetup.exe");
if (MsExecuteW(path, L"/language:yes") == false)
if (IsFileExistsW(path))
{
MsgBox(hWnd, MB_ICONEXCLAMATION, _UU("SW_CHILD_PROCESS_ERROR"));
// with Installer
if (MsExecuteW(path, L"/language:yes") == false)
{
MsgBox(hWnd, MB_ICONEXCLAMATION, _UU("SW_CHILD_PROCESS_ERROR"));
}
}
else
{
// without Installer
CombinePathW(path, sizeof(path), MsGetExeDirNameW(), L"lang.config");
if (MsExecuteW(path, L"") == false)
{
MsgBox(hWnd, MB_ICONEXCLAMATION, _UU("SW_CHILD_PROCESS_ERROR"));
}
}
}
break;