Legend:
- Unmodified
- Added
- Removed
-
irc.c
rc39cd8e rdf67b48 41 41 { 42 42 irc_t *irc; 43 struct sockaddr_storage sock;44 socklen_t socklen = sizeof(sock);45 char *host = NULL, *myhost = NULL;46 43 irc_user_t *iu; 47 44 GSList *l; … … 64 61 irc->iconv = (GIConv) - 1; 65 62 irc->oconv = (GIConv) - 1; 66 67 if (global.conf->hostname) {68 myhost = g_strdup(global.conf->hostname);69 } else if (getsockname(irc->fd, (struct sockaddr*) &sock, &socklen) == 0) {70 myhost = reverse_lookup((struct sockaddr*) &sock, socklen);71 }72 73 if (getpeername(irc->fd, (struct sockaddr*) &sock, &socklen) == 0) {74 host = reverse_lookup((struct sockaddr*) &sock, socklen);75 }76 77 if (host == NULL) {78 host = g_strdup("localhost.localdomain");79 }80 if (myhost == NULL) {81 myhost = g_strdup("localhost.localdomain");82 }83 63 84 64 if (global.conf->ping_interval > 0 && global.conf->ping_timeout > 0) { … … 128 108 129 109 irc->root = iu = irc_user_new(irc, ROOT_NICK); 130 iu->host = g_strdup(myhost);131 110 iu->fullname = g_strdup(ROOT_FN); 132 111 iu->f = &irc_user_root_funcs; 133 112 134 113 iu = irc_user_new(irc, NS_NICK); 135 iu->host = g_strdup(myhost);136 114 iu->fullname = g_strdup(ROOT_FN); 137 115 iu->f = &irc_user_root_funcs; 138 116 139 117 irc->user = g_new0(irc_user_t, 1); 140 irc->user->host = g_strdup(host); 118 119 irc_set_hosts(irc, NULL, 0); 141 120 142 121 conf_loaddefaults(irc); … … 154 133 } 155 134 156 g_free(myhost);157 g_free(host);158 159 135 /* libpurple doesn't like fork()s after initializing itself, so this 160 136 is the right moment to initialize it. */ … … 176 152 177 153 return irc; 154 } 155 156 void irc_set_hosts(irc_t *irc, const struct sockaddr *remote_addr, const socklen_t remote_addrlen) 157 { 158 struct sockaddr_storage sock; 159 socklen_t socklen = sizeof(sock); 160 char *host = NULL, *myhost = NULL; 161 struct irc_user *iu; 162 163 if (global.conf->hostname) { 164 myhost = g_strdup(global.conf->hostname); 165 } else if (getsockname(irc->fd, (struct sockaddr*) &sock, &socklen) == 0) { 166 myhost = reverse_lookup((struct sockaddr*) &sock, socklen); 167 } 168 169 if (remote_addrlen > 0) { 170 host = reverse_lookup(remote_addr, remote_addrlen); 171 } else if (getpeername(irc->fd, (struct sockaddr*) &sock, &socklen) == 0) { 172 host = reverse_lookup((struct sockaddr*) &sock, socklen); 173 } 174 175 if (myhost == NULL) { 176 myhost = g_strdup("localhost.localdomain"); 177 } 178 if (host == NULL) { 179 host = g_strdup("localhost.localdomain"); 180 } 181 182 if (irc->root->host != irc->root->nick) { 183 g_free(irc->root->host); 184 } 185 irc->root->host = g_strdup(myhost); 186 if ((iu = irc_user_by_name(irc, NS_NICK))) { 187 if (iu->host != iu->nick) { 188 g_free(iu->host); 189 } 190 iu->host = g_strdup(myhost); 191 } 192 193 if (irc->user->host != irc->user->nick) { 194 g_free(irc->user->host); 195 } 196 irc->user->host = g_strdup(host); 197 198 g_free(myhost); 199 g_free(host); 178 200 } 179 201
Note: See TracChangeset
for help on using the changeset viewer.