diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-04 15:16:37 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-04 15:16:37 +0000 |
commit | 2820565ea35791a45b0f897b3c15e9c4527d6d67 (patch) | |
tree | 54cf44e906a1f9ac18780849a796308dabaa0bef /src/users.cpp | |
parent | 425e2a649005beb72a258ddde76b56b0ffd15e40 (diff) |
Fixes for ::0 ip's, disable autobind when using ::ffff: etc
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4703 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/users.cpp')
-rw-r--r-- | src/users.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/users.cpp b/src/users.cpp index f5ceabf37..0e29519d5 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -1153,6 +1153,9 @@ void userrec::SetSockAddr(int protocol_family, const char* ip, int port) int userrec::GetPort() { + if (this->ip == NULL) + return 0; + switch (this->GetProtocolFamily()) { #ifdef SUPPORT_IP6LINKS @@ -1178,6 +1181,9 @@ int userrec::GetPort() int userrec::GetProtocolFamily() { + if (this->ip == NULL) + return 0; + sockaddr_in* sin = (sockaddr_in*)this->ip; return sin->sin_family; } @@ -1185,6 +1191,10 @@ int userrec::GetProtocolFamily() const char* userrec::GetIPString() { static char buf[1024]; + static char temp[1024]; + + if (this->ip == NULL) + return ""; switch (this->GetProtocolFamily()) { @@ -1193,6 +1203,13 @@ const char* userrec::GetIPString() { sockaddr_in6* sin = (sockaddr_in6*)this->ip; inet_ntop(sin->sin6_family, &sin->sin6_addr, buf, sizeof(buf)); + /* IP addresses starting with a : on irc are a Bad Thing (tm) */ + if (*buf == ':') + { + strlcpy(&temp[1], buf, sizeof(temp)); + *temp = '0'; + return temp; + } return buf; } break; |