cleanup
This commit is contained in:
parent
e73b220104
commit
6e771607c0
2 changed files with 24 additions and 23 deletions
|
@ -264,6 +264,28 @@ public:
|
||||||
*/
|
*/
|
||||||
static std::vector<std::string> split(const char *s,const char *const sep,const char *esc,const char *quot);
|
static std::vector<std::string> split(const char *s,const char *const sep,const char *esc,const char *quot);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trim whitespace from beginning and end of string
|
||||||
|
*/
|
||||||
|
static inline std::string trimString(const std::string &s)
|
||||||
|
{
|
||||||
|
unsigned long end = (unsigned long)s.length();
|
||||||
|
while (end) {
|
||||||
|
char c = s[end - 1];
|
||||||
|
if ((c == ' ')||(c == '\r')||(c == '\n')||(!c)||(c == '\t'))
|
||||||
|
--end;
|
||||||
|
else break;
|
||||||
|
}
|
||||||
|
unsigned long start = 0;
|
||||||
|
while (start < end) {
|
||||||
|
char c = s[start];
|
||||||
|
if ((c == ' ')||(c == '\r')||(c == '\n')||(!c)||(c == '\t'))
|
||||||
|
++start;
|
||||||
|
else break;
|
||||||
|
}
|
||||||
|
return s.substr(start,end - start);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write a block of data to disk, replacing any current file contents
|
* Write a block of data to disk, replacing any current file contents
|
||||||
*
|
*
|
||||||
|
|
|
@ -117,27 +117,6 @@ namespace ZeroTier {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
static const InetAddress NULL_INET_ADDR;
|
|
||||||
|
|
||||||
static std::string _trimString(const std::string &s)
|
|
||||||
{
|
|
||||||
unsigned long end = (unsigned long)s.length();
|
|
||||||
while (end) {
|
|
||||||
char c = s[end - 1];
|
|
||||||
if ((c == ' ')||(c == '\r')||(c == '\n')||(!c)||(c == '\t'))
|
|
||||||
--end;
|
|
||||||
else break;
|
|
||||||
}
|
|
||||||
unsigned long start = 0;
|
|
||||||
while (start < end) {
|
|
||||||
char c = s[start];
|
|
||||||
if ((c == ' ')||(c == '\r')||(c == '\n')||(!c)||(c == '\t'))
|
|
||||||
++start;
|
|
||||||
else break;
|
|
||||||
}
|
|
||||||
return s.substr(start,end - start);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _networkToJson(nlohmann::json &nj,const ZT_VirtualNetworkConfig *nc,const std::string &portDeviceName,const OneService::NetworkSettings &localSettings)
|
static void _networkToJson(nlohmann::json &nj,const ZT_VirtualNetworkConfig *nc,const std::string &portDeviceName,const OneService::NetworkSettings &localSettings)
|
||||||
{
|
{
|
||||||
char tmp[256];
|
char tmp[256];
|
||||||
|
@ -511,7 +490,7 @@ public:
|
||||||
OSUtils::lockDownFile(authTokenPath.c_str(),false);
|
OSUtils::lockDownFile(authTokenPath.c_str(),false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_authToken = _trimString(_authToken);
|
_authToken = OSUtils::trimString(_authToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1504,7 +1483,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!src)
|
if (!src)
|
||||||
src = &NULL_INET_ADDR;
|
src = &InetAddress::NIL;
|
||||||
|
|
||||||
if ( (!checkIfManagedIsAllowed(n,*target)) || ((via->ss_family == target->ss_family)&&(matchIpOnly(myIps,*via))) )
|
if ( (!checkIfManagedIsAllowed(n,*target)) || ((via->ss_family == target->ss_family)&&(matchIpOnly(myIps,*via))) )
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue