mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 02:19:41 +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 (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));
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user