1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-22 17:39:53 +03:00

Merge PR #816: Cedar: add new "UsernameHubSeparator" configuration option for the server, to specify a different character from '@'

This commit is contained in:
Davide Beatrici 2018-11-26 21:59:52 +01:00 committed by GitHub
commit e143873337
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 4 deletions

View File

@ -209,6 +209,9 @@
// Hidden password string of 8 characters // Hidden password string of 8 characters
#define HIDDEN_PASSWORD "********" #define HIDDEN_PASSWORD "********"
// Default separator character for the hub name in the username
#define DEFAULT_USERNAME_HUB_SEPARATOR '@'
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// //
@ -1024,6 +1027,7 @@ typedef struct CEDAR
COUNTER *ConnectionIncrement; // Connection increment counter COUNTER *ConnectionIncrement; // Connection increment counter
X *ServerX; // Server certificate X *ServerX; // Server certificate
K *ServerK; // Private key of the server certificate K *ServerK; // Private key of the server certificate
char UsernameHubSeparator; // Character which separates the username from the hub name
char *CipherList; // List of encryption algorithms char *CipherList; // List of encryption algorithms
UINT Version; // Version information UINT Version; // Version information
UINT Build; // Build Number UINT Build; // Build Number

View File

@ -807,14 +807,14 @@ bool PPPParseUsername(CEDAR *cedar, char *src_username, ETHERIP_ID *dst)
} }
else else
{ {
// Search for the last "@" in the string // Search for the separator character's last position in the string
len = StrLen(src); len = StrLen(src);
last_at = INFINITE; last_at = INFINITE;
for (i = 0;i < len;i++) for (i = 0;i < len;i++)
{ {
char c = src[i]; char c = src[i];
if (c == '@') if (c == cedar->UsernameHubSeparator)
{ {
last_at = i; last_at = i;
} }
@ -825,12 +825,11 @@ bool PPPParseUsername(CEDAR *cedar, char *src_username, ETHERIP_ID *dst)
if (last_at == INFINITE) if (last_at == INFINITE)
{ {
// "@" is not specified // The separator character is not specified
StrCpy(token1, sizeof(token1), src); StrCpy(token1, sizeof(token1), src);
} }
else else
{ {
// Split with last "@"
StrCpy(token1, sizeof(token1), src); StrCpy(token1, sizeof(token1), src);
token1[last_at] = 0; token1[last_at] = 0;

View File

@ -2540,6 +2540,9 @@ void SiLoadInitialConfiguration(SERVER *s)
// Set the server certificate to default // Set the server certificate to default
SiInitDefaultServerCert(s); SiInitDefaultServerCert(s);
// Set the character which separates the username from the hub name
s->Cedar->UsernameHubSeparator = DEFAULT_USERNAME_HUB_SEPARATOR;
// Create a default HUB // Create a default HUB
{ {
SiInitDefaultHubList(s); SiInitDefaultHubList(s);
@ -5936,6 +5939,12 @@ void SiLoadServerCfg(SERVER *s, FOLDER *f)
FreeK(k); FreeK(k);
} }
// Character which separates the username from the hub name
if (CfgGetStr(f, "UsernameHubSeparator", tmp, sizeof(tmp)))
{
c->UsernameHubSeparator = IsPrintableAsciiChar(tmp[0]) ? tmp[0] : DEFAULT_USERNAME_HUB_SEPARATOR;
}
// Cipher Name // Cipher Name
if (CfgGetStr(f, "CipherName", tmp, sizeof(tmp))) if (CfgGetStr(f, "CipherName", tmp, sizeof(tmp)))
{ {
@ -6313,6 +6322,13 @@ void SiWriteServerCfg(FOLDER *f, SERVER *s)
CfgAddBuf(f, "ServerKey", b); CfgAddBuf(f, "ServerKey", b);
FreeBuf(b); FreeBuf(b);
{
// Character which separates the username from the hub name
char str[2];
StrCpy(str, sizeof(str), &c->UsernameHubSeparator);
CfgAddStr(f, "UsernameHubSeparator", str);
}
// Traffic information // Traffic information
Lock(c->TrafficLock); Lock(c->TrafficLock);
{ {