Skip to content

Commit

Permalink
Static IP Support
Browse files Browse the repository at this point in the history
Static IP for user by User Name (login) or User Note (IPv4)
  • Loading branch information
dkxce authored Dec 23, 2021
1 parent 2207574 commit 87fb0d2
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/BuildFiles/VerScript/ver.rc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ BEGIN
BEGIN
BLOCK "041104b0"
BEGIN
VALUE "CompanyName", "SoftEther VPN Project at University of Tsukuba, Japan. (Open-source Customized Build)"
VALUE "FileDescription", "$PRODUCTNAME$ (Open-source Customized Build)"
VALUE "CompanyName", "SoftEther VPN Project (Milok Zbrozek <milokz@gmail.com> custom build)"
VALUE "FileDescription", "$PRODUCTNAME$ (Milok Zbrozek <milokz@gmail.com> Static IPv4 LN build)"
VALUE "FileVersion", "$VER_MAJOR$, $VER_MINOR$, 0, $VER_BUILD$"
VALUE "InternalName", "$INTERNALNAME$ (Open-source Customized Build)"
VALUE "LegalCopyright", "Copyright (C) 2012-$YEAR$ SoftEther VPN Project. All Rights Reserved. (Open-source Customized Build)"
Expand Down
4 changes: 2 additions & 2 deletions src/BuildUtil/VpnBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -396,11 +396,11 @@ static Paths()
// Get Microsoft SDK 6.0a directory
if (IntPtr.Size == 4)
{
Paths.MicrosoftSDKDir = IO.RemoteLastEnMark(Reg.ReadStr(RegRoot.LocalMachine, @"SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v6.0A", "InstallationFolder"));
Paths.MicrosoftSDKDir = IO.RemoteLastEnMark(Reg.ReadStr(RegRoot.LocalMachine, @"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0A", "InstallationFolder"));
}
else
{
Paths.MicrosoftSDKDir = IO.RemoteLastEnMark(Reg.ReadStr(RegRoot.LocalMachine, @"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0A", "InstallationFolder"));
Paths.MicrosoftSDKDir = IO.RemoteLastEnMark(Reg.ReadStr(RegRoot.LocalMachine, @"SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v6.0A", "InstallationFolder"));
}

// Get makecat.exe file name
Expand Down
4 changes: 2 additions & 2 deletions src/Cedar/Account.c
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,7 @@ UINT GetIPv4AddressFromUserName(char *name)
{
UINT ip32 = 0;
TOKEN_LIST *tokens;
tokens = ParseToken(ipv4str2, " ,/()[]");
tokens = ParseToken(name, " ,/()[]");
if (tokens != NULL)
{
if (tokens->NumTokens >= 1)
Expand All @@ -1456,7 +1456,7 @@ UINT GetIPv4AddressFromUserName(char *name)
}
}

UniFreeToken(tokens);
FreeToken(tokens);
}

return ip32;
Expand Down
2 changes: 0 additions & 2 deletions src/Cedar/Account.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,6 @@ void GetPolicyValueRangeStr(wchar_t *str, UINT size, UINT id);
void FormatPolicyValue(wchar_t *str, UINT size, UINT id, UINT value);
char *NormalizePolicyName(char *name);
bool GetUserMacAddressFromUserNote(UCHAR *mac, wchar_t *note);
UINT GetUserIPv4AddressFromUserNote32(wchar_t *note);
UINT GetIPv4AddressFromUserName(char *name)


#endif // ACCOUNT_H
Expand Down
14 changes: 9 additions & 5 deletions src/Cedar/Session.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void SessionMain(SESSION *s)
bool is_server_session = false;
bool lock_receive_blocks_queue = false;
UINT static_ip = 0;

// Validate arguments
if (s == NULL)
{
Expand Down Expand Up @@ -405,7 +405,7 @@ void SessionMain(SESSION *s)
// Remember the static IP address to remove it from the leased IP address list later
static_ip = ip;
}

if (b->Buf[0] & 0x01)
{
if (is_server_session == false)
Expand Down Expand Up @@ -711,7 +711,7 @@ void SessionMain(SESSION *s)

// Clear the DHCP lease record if assigned as a static client IP address
ClearDHCPLeaseRecordForIPv4(s, static_ip);

DelSession(s->Hub, s);
}

Expand Down Expand Up @@ -2613,9 +2613,13 @@ UINT PrepareDHCPRequestForStaticIPv4(SESSION *s, BLOCK *b)
return ret_ip;
}


// release dhcp lease for static IP
void ClearDHCPLeaseRecordForIPv4(SESSION *s, UINT static_ip)
{
VH *v = NULL;
DHCP_LEASE *d = NULL;

if (s == NULL || static_ip == 0)
{
return;
Expand All @@ -2626,13 +2630,13 @@ void ClearDHCPLeaseRecordForIPv4(SESSION *s, UINT static_ip)
return;
}

VH *v = s->Hub->SecureNAT->Nat->Virtual;
v = s->Hub->SecureNAT->Nat->Virtual;
if (v == NULL || v->DhcpLeaseList == NULL)
{
return;
}

DHCP_LEASE *d = SearchDhcpLeaseByIp(v, static_ip);
d = SearchDhcpLeaseByIp(v, static_ip);
if (d == NULL)
{
return;
Expand Down
5 changes: 4 additions & 1 deletion src/Cedar/Virtual.c
Original file line number Diff line number Diff line change
Expand Up @@ -10333,8 +10333,11 @@ PACKET_ADAPTER *VirtualGetPacketAdapter()
VirtualPaGetNextPacket, VirtualPaPutPacket, VirtualPaFree);
}


UINT ServeDhcpDiscoverEx(VH *v, UCHAR *mac, UINT request_ip, bool is_static_ip)
{
DHCP_LEASE *d = NULL;

if (is_static_ip == false)
{
return ServeDhcpDiscover(v, mac, request_ip );
Expand All @@ -10345,7 +10348,7 @@ UINT ServeDhcpDiscoverEx(VH *v, UCHAR *mac, UINT request_ip, bool is_static_ip)
return 0;
}

DHCP_LEASE *d = SearchDhcpLeaseByIp(v, request_ip);
d = SearchDhcpLeaseByIp(v, request_ip);
if (d != NULL)
{
// The requested IP address is used already
Expand Down
4 changes: 2 additions & 2 deletions src/CurrentBuild.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BUILD_NUMBER 9760
BUILD_NUMBER 9761
VERSION 438
BUILD_NAME rtm
BUILD_DATE 20210817_221406
BUILD_DATE 20211223_130000
50 changes: 50 additions & 0 deletions src/bin_modified/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
## Custom Builds

** Server

* Static IPv4 for users by User Name

[vpnserver-with-static-IPs-L-x86.exe](vpnserver-with-static-IPs-L-x86.exe) - L Build (Login)
[vpnserver-with-static-IPs-L-x64.exe](vpnserver-with-static-IPs-L-x64.exe) - L Build (Login)
How to set:
- Static IP can be set as user name (example: 10.0.0.1)
How to use:
1) Install Original Softether VP Server
2) Stop SoftEther VPN Server (SEVPNSERVER) service
3) Replace original vpnserver.exe file in C:\Program Files\SoftEther VPN Server with selected from above
4) Run SoftEther VPN Server (SEVPNSERVER) service
5) That's All
* Static IPv4 for users by User Note

[vpnserver-with-static-IPs-N-x86.exe](vpnserver-with-static-IPs-N-x86.exe) - N Build (Note)
[vpnserver-with-static-IPs-N-x64.exe](vpnserver-with-static-IPs-N-x64.exe) - N Build (Note)
How to set:
- Static IP can be set as user note (example: IPv4: 10.0.0.1)
How to use:
1) Install Original Softether VP Server
2) Stop SoftEther VPN Server (SEVPNSERVER) service
3) Replace original vpnserver.exe file in C:\Program Files\SoftEther VPN Server with selected from above
4) Run SoftEther VPN Server (SEVPNSERVER) service
5) That's All

* Static IPv4 for users by User Name or User Note:
[vpnserver-with-static-IPs-LN-x86.exe](vpnserver-with-static-IPs-LN-x86.exe) - LN Build (Login-Note)
[vpnserver-with-static-IPs-LN-x64.exe](vpnserver-with-static-IPs-LN-x64.exe) - LN Build (Login-Note)

How to set:
- Static IP can be set as user name (example: 10.0.0.1)
- Static IP can be set as user note (example: IPv4: 10.0.0.1)
* IP sets from User Name, if User Name is not IP then try to set from User Note

How to use:
1) Install Original Softether VP Server
2) Stop SoftEther VPN Server (SEVPNSERVER) service
3) Replace original vpnserver.exe file in C:\Program Files\SoftEther VPN Server with selected from above
4) Run SoftEther VPN Server (SEVPNSERVER) service
5) That's All
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 87fb0d2

Please sign in to comment.