Ignore:
Timestamp:
2008-07-16T23:22:52Z (16 years ago)
Author:
Sven Moritz Hallberg <pesco@…>
Branches:
master
Children:
9b55485
Parents:
9730d72 (diff), 6a78c0e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge in latest trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/jabber.c

    r9730d72 r6738a67  
    3333#include "jabber.h"
    3434#include "md5.h"
    35 #include "base64.h"
    3635
    3736GSList *jabber_connections;
    3837
     38/* First enty is the default */
     39static const int jabber_port_list[] = {
     40        5222,
     41        5223,
     42        5220,
     43        5221,
     44        5224,
     45        5225,
     46        5226,
     47        5227,
     48        5228,
     49        5229,
     50        80,
     51        443,
     52        0
     53};
     54
    3955static void jabber_init( account_t *acc )
    4056{
    4157        set_t *s;
    42        
    43         s = set_add( &acc->set, "port", JABBER_PORT_DEFAULT, set_eval_int, acc );
     58        char str[16];
     59       
     60        g_snprintf( str, sizeof( str ), "%d", jabber_port_list[0] );
     61        s = set_add( &acc->set, "port", str, set_eval_int, acc );
    4462        s->flags |= ACC_SET_OFFLINE_ONLY;
    4563       
     
    7290        struct ns_srv_reply *srv = NULL;
    7391        char *connect_to, *s;
     92        int i;
    7493       
    7594        /* For now this is needed in the _connected() handlers if using
     
    177196        imcb_log( ic, "Connecting" );
    178197       
    179         if( set_getint( &acc->set, "port" ) < JABBER_PORT_MIN ||
    180             set_getint( &acc->set, "port" ) > JABBER_PORT_MAX )
    181         {
    182                 imcb_log( ic, "Incorrect port number, must be in the %d-%d range",
    183                                JABBER_PORT_MIN, JABBER_PORT_MAX );
     198        for( i = 0; jabber_port_list[i] > 0; i ++ )
     199                if( set_getint( &acc->set, "port" ) == jabber_port_list[i] )
     200                        break;
     201
     202        if( jabber_port_list[i] == 0 )
     203        {
     204                imcb_log( ic, "Illegal port number" );
    184205                imc_logout( ic, FALSE );
    185206                return;
     
    219240}
    220241
     242/* This generates an unfinished md5_state_t variable. Every time we generate
     243   an ID, we finish the state by adding a sequence number and take the hash. */
    221244static void jabber_generate_id_hash( struct jabber_data *jd )
    222245{
    223         md5_state_t id_hash;
    224         md5_byte_t binbuf[16];
     246        md5_byte_t binbuf[4];
    225247        char *s;
    226248       
    227         md5_init( &id_hash );
    228         md5_append( &id_hash, (unsigned char *) jd->username, strlen( jd->username ) );
    229         md5_append( &id_hash, (unsigned char *) jd->server, strlen( jd->server ) );
     249        md5_init( &jd->cached_id_prefix );
     250        md5_append( &jd->cached_id_prefix, (unsigned char *) jd->username, strlen( jd->username ) );
     251        md5_append( &jd->cached_id_prefix, (unsigned char *) jd->server, strlen( jd->server ) );
    230252        s = set_getstr( &jd->ic->acc->set, "resource" );
    231         md5_append( &id_hash, (unsigned char *) s, strlen( s ) );
    232         random_bytes( binbuf, 16 );
    233         md5_append( &id_hash, binbuf, 16 );
    234         md5_finish( &id_hash, binbuf );
    235        
    236         s = base64_encode( binbuf, 9 );
    237         jd->cached_id_prefix = g_strdup_printf( "%s%s", JABBER_CACHED_ID, s );
    238         g_free( s );
     253        md5_append( &jd->cached_id_prefix, (unsigned char *) s, strlen( s ) );
     254        random_bytes( binbuf, 4 );
     255        md5_append( &jd->cached_id_prefix, binbuf, 4 );
    239256}
    240257
Note: See TracChangeset for help on using the changeset viewer.