1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-22 09:29:52 +03:00

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

This commit is contained in:
Davide Beatrici 2018-11-25 20:50:14 +01:00
parent b8629f324f
commit 8a58af86b1
3 changed files with 23 additions and 4 deletions

View File

@ -209,6 +209,9 @@
// Hidden password string of 8 characters
#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
X *ServerX; // 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
UINT Version; // Version information
UINT Build; // Build Number

View File

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

View File

@ -2540,6 +2540,9 @@ void SiLoadInitialConfiguration(SERVER *s)
// Set the server certificate to default
SiInitDefaultServerCert(s);
// Set the character which separates the username from the hub name
s->Cedar->UsernameHubSeparator = DEFAULT_USERNAME_HUB_SEPARATOR;
// Create a default HUB
{
SiInitDefaultHubList(s);
@ -5936,6 +5939,12 @@ void SiLoadServerCfg(SERVER *s, FOLDER *f)
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
if (CfgGetStr(f, "CipherName", tmp, sizeof(tmp)))
{
@ -6313,6 +6322,13 @@ void SiWriteServerCfg(FOLDER *f, SERVER *s)
CfgAddBuf(f, "ServerKey", 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
Lock(c->TrafficLock);
{