Changes in irc_commands.c [b097945:2e78f75]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
irc_commands.c
rb097945 r2e78f75 26 26 #define BITLBEE_CORE 27 27 #include "bitlbee.h" 28 #include "canohost.h"29 28 #include "help.h" 30 29 #include "ipc.h" … … 58 57 irc_check_login(irc); 59 58 } 60 }61 62 /* http://www.haproxy.org/download/1.8/doc/proxy-protocol.txt63 64 This isn't actually IRC, it's used by for example stunnel4 to indicate65 the origin of the secured counterpart of the connection. It'll go wrong66 with arguments starting with : like for example "::1" but I guess I'm67 okay with that. */68 static void irc_cmd_proxy(irc_t *irc, char **cmd)69 {70 struct addrinfo hints, *ai;71 struct sockaddr_storage sock;72 socklen_t socklen = sizeof(sock);73 74 if (getpeername(irc->fd, (struct sockaddr*) &sock, &socklen) != 0) {75 return;76 }77 78 ipv64_normalise_mapped(&sock, &socklen);79 80 /* Only accept PROXY "command" on localhost sockets. */81 if (!((sock.ss_family == AF_INET &&82 ntohl(((struct sockaddr_in*)&sock)->sin_addr.s_addr) == INADDR_LOOPBACK) ||83 (sock.ss_family == AF_INET6 &&84 IN6_IS_ADDR_LOOPBACK(&((struct sockaddr_in6*)&sock)->sin6_addr)))) {85 return;86 }87 88 /* And only once. Do this with a pretty dumb regex-match for89 now, maybe better to use some sort of flag.. */90 if (!g_regex_match_simple("^(ip6-)?localhost(.(localdomain.?)?)?$", irc->user->host, 0, 0)) {91 return;92 }93 94 memset(&hints, 0, sizeof(hints));95 hints.ai_flags = AI_NUMERICHOST;96 if (getaddrinfo(cmd[2], NULL, &hints, &ai) != 0) {97 return;98 }99 100 irc_set_hosts(irc, ai->ai_addr, ai->ai_addrlen);101 freeaddrinfo(ai);102 59 } 103 60 … … 851 808 { "cap", 1, irc_cmd_cap, 0 }, 852 809 { "pass", 1, irc_cmd_pass, 0 }, 853 { "proxy", 5, irc_cmd_proxy, IRC_CMD_PRE_LOGIN },854 810 { "user", 4, irc_cmd_user, IRC_CMD_PRE_LOGIN }, 855 811 { "nick", 1, irc_cmd_nick, 0 },
Note: See TracChangeset
for help on using the changeset viewer.