Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • irc_commands.c

    rb097945 r2e78f75  
    2626#define BITLBEE_CORE
    2727#include "bitlbee.h"
    28 #include "canohost.h"
    2928#include "help.h"
    3029#include "ipc.h"
     
    5857                irc_check_login(irc);
    5958        }
    60 }
    61 
    62 /* http://www.haproxy.org/download/1.8/doc/proxy-protocol.txt
    63 
    64    This isn't actually IRC, it's used by for example stunnel4 to indicate
    65    the origin of the secured counterpart of the connection. It'll go wrong
    66    with arguments starting with : like for example "::1" but I guess I'm
    67    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 for
    89            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);
    10259}
    10360
     
    851808        { "cap",         1, irc_cmd_cap,         0 },
    852809        { "pass",        1, irc_cmd_pass,        0 },
    853         { "proxy",       5, irc_cmd_proxy,       IRC_CMD_PRE_LOGIN },
    854810        { "user",        4, irc_cmd_user,        IRC_CMD_PRE_LOGIN },
    855811        { "nick",        1, irc_cmd_nick,        0 },
Note: See TracChangeset for help on using the changeset viewer.