Changeset aefaac3a


Ignore:
Timestamp:
2008-04-06T15:34:25Z (16 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
99f929c
Parents:
aa31117
Message:

Added ClientInterface configuration option to make BitlBee bind() to a
specific interface before connecting to a remote host.

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • bitlbee.c

    raa31117 raefaac3a  
    5454        ;
    5555
    56         i = getaddrinfo( global.conf->iface, global.conf->port, &hints, &addrinfo_bind );
     56        i = getaddrinfo( global.conf->iface_in, global.conf->port, &hints, &addrinfo_bind );
    5757        if( i )
    5858        {
    5959                log_message( LOGLVL_ERROR, "Couldn't parse address `%s': %s",
    60                                            global.conf->iface, gai_strerror(i) );
     60                                           global.conf->iface_in, gai_strerror(i) );
    6161                return -1;
    6262        }
  • bitlbee.conf

    raa31117 raefaac3a  
    3434# DaemonInterface = 0.0.0.0
    3535# DaemonPort = 6667
     36
     37## ClientInterface:
     38##
     39## If for any reason, you want BitlBee to use a specific address/interface
     40## for outgoing traffic (IM connections, HTTP(S), etc.), set it here.
     41##
     42# ClientInterface = 0.0.0.0
    3643
    3744## AuthMode
  • conf.c

    raa31117 raefaac3a  
    4545        conf = g_new0( conf_t, 1 );
    4646       
    47         conf->iface = NULL;
     47        conf->iface_in = NULL;
     48        conf->iface_out = NULL;
    4849        conf->port = g_strdup( "6667" );
    4950        conf->nofork = 0;
     
    8283                if( opt == 'i' )
    8384                {
    84                         conf->iface = g_strdup( optarg );
     85                        conf->iface_in = g_strdup( optarg );
    8586                }
    8687                else if( opt == 'p' )
     
    202203                        else if( g_strcasecmp( ini->key, "daemoninterface" ) == 0 )
    203204                        {
    204                                 g_free( conf->iface );
    205                                 conf->iface = g_strdup( ini->value );
     205                                g_free( conf->iface_in );
     206                                conf->iface_in = g_strdup( ini->value );
    206207                        }
    207208                        else if( g_strcasecmp( ini->key, "daemonport" ) == 0 )
     
    209210                                g_free( conf->port );
    210211                                conf->port = g_strdup( ini->value );
     212                        }
     213                        else if( g_strcasecmp( ini->key, "clientinterface" ) == 0 )
     214                        {
     215                                g_free( conf->iface_out );
     216                                conf->iface_out = g_strdup( ini->value );
    211217                        }
    212218                        else if( g_strcasecmp( ini->key, "authmode" ) == 0 )
  • conf.h

    raa31117 raefaac3a  
    3232typedef struct conf
    3333{
    34         char *iface;
     34        char *iface_in, *iface_out;
    3535        char *port;
    3636        int nofork;
  • lib/proxy.c

    raa31117 raefaac3a  
    114114{
    115115        struct sockaddr_in *sin;
     116        struct sockaddr_in me;
    116117        int fd = -1;
    117118
     
    127128
    128129        sock_make_nonblocking(fd);
     130       
     131        if( global.conf->iface_out )
     132        {
     133                me.sin_family = AF_INET;
     134                me.sin_port = 0;
     135                me.sin_addr.s_addr = inet_addr( global.conf->iface_out );
     136               
     137                if( bind( fd, (struct sockaddr *) &me, sizeof( me ) ) != 0 )
     138                        event_debug( "bind( %d, \"%s\" ) failure\n", fd, global.conf->iface_out );
     139        }
    129140       
    130141        event_debug("proxy_connect_none( \"%s\", %d ) = %d\n", host, port, fd);
Note: See TracChangeset for help on using the changeset viewer.