Changeset 2a6ca4f


Ignore:
Timestamp:
2006-01-04T11:16:58Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
0196c47
Parents:
13c4cd3
Message:

Better handling of IPv4 connections in IPv6 mode. (Wrapping/Unwrapping of ::ffff:style addresses.)

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • bitlbee.c

    r13c4cd3 r2a6ca4f  
    8989        listen_addr.sin6_family = AF_INETx;
    9090        listen_addr.sin6_port = htons( global.conf->port );
    91         i = inet_pton( AF_INETx, global.conf->iface, &listen_addr.sin6_addr );
     91        i = inet_pton( AF_INETx, ipv6_wrap( global.conf->iface ), &listen_addr.sin6_addr );
    9292#else
    9393        listen_addr.sin_family = AF_INETx;
  • bitlbee.conf

    r13c4cd3 r2a6ca4f  
    2222## DaemonPort/DaemonInterface:
    2323##
    24 ## For RunMode=Daemon, here you can specify on what interface and port the
    25 ## daemon should be listening for connections.
     24## For daemon mode, you can specify on what interface and port the daemon
     25## should be listening for connections.
    2626##
    2727# DaemonInterface = 0.0.0.0
     
    5555## Normally, BitlBee gets a hostname using getsockname(). If you have a nicer
    5656## alias for your BitlBee daemon, you can set it here and BitlBee will identify
    57 ## itself with that name instead. Leave it commented out if you want BitlBee to
    58 ## use getsockname() to get a hostname.
     57## itself with that name instead.
    5958##
    6059# HostName = localhost
  • conf.c

    r13c4cd3 r2a6ca4f  
    4646        conf = g_new0( conf_t, 1 );
    4747       
     48#ifdef IPV6
     49        conf->iface = "::";
     50#else
    4851        conf->iface = "0.0.0.0";
     52#endif
    4953        conf->port = 6667;
    5054        conf->nofork = 0;
  • irc.c

    r13c4cd3 r2a6ca4f  
    8383                        irc->myhost = g_strdup( peer->h_name );
    8484                else if( inet_ntop( AF_INETx, &sock->sin6_addr, buf, sizeof( buf ) - 1 ) != NULL )
    85                         irc->myhost = g_strdup( buf );
     85                        irc->myhost = g_strdup( ipv6_unwrap( buf ) );
    8686        }
    8787#else
     
    102102                        irc->host = g_strdup( peer->h_name );
    103103                else if( inet_ntop( AF_INETx, &sock->sin6_addr, buf, sizeof( buf ) - 1 ) != NULL )
    104                         irc->host = g_strdup( buf );
     104                        irc->host = g_strdup( ipv6_unwrap( buf ) );
    105105        }
    106106#else
     
    114114#endif
    115115       
     116        /* Rare, but possible. */
    116117        if( !irc->host ) irc->host = g_strdup( "localhost." );
    117118        if( !irc->myhost ) irc->myhost = g_strdup( "localhost." );
  • protocols/nogaim.h

    r13c4cd3 r2a6ca4f  
    288288G_MODULE_EXPORT void serv_got_chat_in( struct gaim_connection *gc, int id, char *who, int whisper, char *msg, time_t mtime );
    289289G_MODULE_EXPORT void serv_got_chat_left( struct gaim_connection *gc, int id );
    290 /* void serv_finish_login( struct gaim_connection *gc ); */
    291290
    292291/* util.c */
     
    299298G_MODULE_EXPORT char *escape_html( const char *html );
    300299G_MODULE_EXPORT void info_string_append(GString *str, char *newline, char *name, char *value);
     300G_MODULE_EXPORT char *ipv6_wrap( char *src );
     301G_MODULE_EXPORT char *ipv6_unwrap( char *src );
    301302
    302303/* prefs.c */
  • util.c

    r13c4cd3 r2a6ca4f  
    403403        return source;
    404404}
     405
     406#ifdef IPV6
     407/* Wrap an IPv4 address into IPv6 space. Not thread-safe... */
     408char *ipv6_wrap( char *src )
     409{
     410        static char dst[64];
     411        int i;
     412       
     413        for( i = 0; src[i]; i ++ )
     414                if( ( src[i] < '0' || src[i] > '9' ) && src[i] != '.' )
     415                        break;
     416       
     417        /* Hmm, it's not even an IP... */
     418        if( src[i] )
     419                return src;
     420       
     421        g_snprintf( dst, sizeof( dst ), "::ffff:%s", src );
     422       
     423        return dst;
     424}
     425
     426/* Unwrap an IPv4 address into IPv6 space. Thread-safe, because it's very simple. :-) */
     427char *ipv6_unwrap( char *src )
     428{
     429        int i;
     430       
     431        if( g_strncasecmp( src, "::ffff:", 7 ) != 0 )
     432                return src;
     433       
     434        for( i = 7; src[i]; i ++ )
     435                if( ( src[i] < '0' || src[i] > '9' ) && src[i] != '.' )
     436                        break;
     437       
     438        /* Hmm, it's not even an IP... */
     439        if( src[i] )
     440                return src;
     441       
     442        return ( src + 7 );
     443}
     444#endif
Note: See TracChangeset for help on using the changeset viewer.