summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-04 12:57:43 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-04 12:57:43 +0000
commit32ea53d02e36c3fd4e9eef86cfea32c89fb75ede (patch)
tree3b88baee666ea99b284e2a23ab88a660f5d946e1 /src
parent7e6cdd6c8b96f17c8c1130e50fdd954cac1d94c9 (diff)
Changes
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4701 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/users.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/users.cpp b/src/users.cpp
index 057922d2a..fa0fd8d69 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -267,7 +267,9 @@ userrec::userrec()
haspassed = dns_done = false;
recvq = "";
sendq = "";
+ WriteError = "";
res_forward = res_reverse = NULL;
+ ip = NULL;
chans.clear();
invites.clear();
chans.resize(MAXCHANS);
@@ -289,6 +291,20 @@ userrec::~userrec()
ucrec* x = (ucrec*)*n;
delete x;
}
+
+ if (ip)
+ {
+ if (this->GetProtocolFamily() == AF_INET)
+ {
+ delete (sockaddr_in*)ip;
+ }
+#ifdef SUPPORT_IP6LINKS
+ else
+ {
+ delete (sockaddr_in6*)ip;
+ }
+#endif
+ }
}
/* XXX - minor point, other *Host functions return a char *, this one creates it. Might be nice to be consistant? */
@@ -917,13 +933,13 @@ long FindMatchingLocal(userrec* user)
userrec* comp = *a;
#ifdef IPV6
/* I dont think theres any faster way of matching two ipv6 addresses than memcmp */
- in6_addr* s1 = &(((sockaddr_in6*)&comp->ip)->sin6_addr);
- in6_addr* s2 = &(((sockaddr_in6*)&user->ip)->sin6_addr);
+ in6_addr* s1 = (((sockaddr_in6*)&comp->ip)->sin6_addr);
+ in6_addr* s2 = (((sockaddr_in6*)&user->ip)->sin6_addr);
if (!memcmp(s1->s6_addr, s2->s6_addr, sizeof(in6_addr)))
x++;
#else
- in_addr* s1 = &((sockaddr_in*)&comp->ip)->sin_addr;
- in_addr* s2 = &((sockaddr_in*)&user->ip)->sin_addr;
+ in_addr* s1 = ((sockaddr_in*)&comp->ip)->sin_addr;
+ in_addr* s2 = ((sockaddr_in*)&user->ip)->sin_addr;
if (s1->s_addr == s2->s_addr)
x++;
#endif
@@ -1111,20 +1127,22 @@ void userrec::SetSockAddr(int protocol_family, const char* ip, int port)
case AF_INET6:
{
log(DEBUG,"Set inet6 protocol address");
- sockaddr_in6* sin = (sockaddr_in6*)&this->ip;
+ sockaddr_in6* sin = new sockaddr_in6;
sin->sin6_family = AF_INET6;
sin->sin6_port = port;
inet_pton(AF_INET6, ip, &sin->sin6_addr);
+ this->ip = (sockaddr*)sin;
}
break;
#endif
case AF_INET:
{
log(DEBUG,"Set inet4 protocol address");
- sockaddr_in* sin = (sockaddr_in*)&this->ip;
+ sockaddr_in* sin = new sockaddr_in;
sin->sin_family = AF_INET;
sin->sin_port = port;
inet_pton(AF_INET, ip, &sin->sin_addr);
+ this->ip = (sockaddr*)sin;
}
break;
default: