(svn r15978) -Codechange: support parsing [] enclosed IPv6 addresses.

This commit is contained in:
rubidium 2009-04-08 01:22:57 +00:00
parent 20e82c46d3
commit a5a424ce28
2 changed files with 12 additions and 1 deletions

View File

@ -96,7 +96,7 @@ public:
if (StrEmpty(hostname)) hostname = ""; if (StrEmpty(hostname)) hostname = "";
if (*hostname == '[') hostname++; if (*hostname == '[') hostname++;
strecpy(this->hostname, StrEmpty(hostname) ? "" : hostname, lastof(this->hostname)); strecpy(this->hostname, StrEmpty(hostname) ? "" : hostname, lastof(this->hostname));
char *tmp = strrchr(hostname, ']'); char *tmp = strrchr(this->hostname, ']');
if (tmp != NULL) *tmp = '\0'; if (tmp != NULL) *tmp = '\0';
memset(&this->address, 0, sizeof(this->address)); memset(&this->address, 0, sizeof(this->address));

View File

@ -374,14 +374,25 @@ static void CheckMinActiveClients()
* occupied by connection_string. */ * occupied by connection_string. */
void ParseConnectionString(const char **company, const char **port, char *connection_string) void ParseConnectionString(const char **company, const char **port, char *connection_string)
{ {
bool ipv6 = false;
char *p; char *p;
for (p = connection_string; *p != '\0'; p++) { for (p = connection_string; *p != '\0'; p++) {
switch (*p) { switch (*p) {
case '[':
ipv6 = true;
break;
case ']':
ipv6 = false;
break;
case '#': case '#':
*company = p + 1; *company = p + 1;
*p = '\0'; *p = '\0';
break; break;
case ':': case ':':
if (ipv6) break;
*port = p + 1; *port = p + 1;
*p = '\0'; *p = '\0';
break; break;