Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/SoftEtherVPN/SoftEtherVPN_Stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaiyuu Nobori <da.git@softether.co.jp>2014-02-05 20:35:38 +0400
committerDaiyuu Nobori <da.git@softether.co.jp>2014-02-05 20:35:38 +0400
commitef054055b05b15f8bd318de0ba99e8c71f930636 (patch)
treee538180504621d733569ba70ae3acf8abbb10528
parentcdd4540baaae47865402cf208566324c39945446 (diff)
parentd38762941f92ffa72516dd1e1180ba0912b36559 (diff)
Merge pull request #14 from el1n/adminipcidr
adminip.txt CIDR Support
-rw-r--r--src/Cedar/Admin.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/Cedar/Admin.c b/src/Cedar/Admin.c
index e61e41f4..626c1cd7 100644
--- a/src/Cedar/Admin.c
+++ b/src/Cedar/Admin.c
@@ -13212,6 +13212,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 +13245,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)
{