mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 22:28:56 +00:00
(svn r15978) -Codechange: support parsing [] enclosed IPv6 addresses.
This commit is contained in:
parent
20e82c46d3
commit
a5a424ce28
@ -96,7 +96,7 @@ public:
|
||||
if (StrEmpty(hostname)) hostname = "";
|
||||
if (*hostname == '[') hostname++;
|
||||
strecpy(this->hostname, StrEmpty(hostname) ? "" : hostname, lastof(this->hostname));
|
||||
char *tmp = strrchr(hostname, ']');
|
||||
char *tmp = strrchr(this->hostname, ']');
|
||||
if (tmp != NULL) *tmp = '\0';
|
||||
|
||||
memset(&this->address, 0, sizeof(this->address));
|
||||
|
@ -374,14 +374,25 @@ static void CheckMinActiveClients()
|
||||
* occupied by connection_string. */
|
||||
void ParseConnectionString(const char **company, const char **port, char *connection_string)
|
||||
{
|
||||
bool ipv6 = false;
|
||||
char *p;
|
||||
for (p = connection_string; *p != '\0'; p++) {
|
||||
switch (*p) {
|
||||
case '[':
|
||||
ipv6 = true;
|
||||
break;
|
||||
|
||||
case ']':
|
||||
ipv6 = false;
|
||||
break;
|
||||
|
||||
case '#':
|
||||
*company = p + 1;
|
||||
*p = '\0';
|
||||
break;
|
||||
|
||||
case ':':
|
||||
if (ipv6) break;
|
||||
*port = p + 1;
|
||||
*p = '\0';
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user