Ignore:
Timestamp:
2007-11-24T18:02:39Z (17 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
221a273
Parents:
3a80471
Message:

Added some random hash to the id= for cached XMPP packets so that packets
from other BitlBees won't be picked up accidentally. Might also want to
randomize the per-packet IDs because they're still predictable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/jabber.c

    r3a80471 r608f8cf  
    3232#include "bitlbee.h"
    3333#include "jabber.h"
     34#include "md5.h"
     35#include "base64.h"
    3436
    3537static void jabber_init( account_t *acc )
     
    5961        s->flags |= ACC_SET_OFFLINE_ONLY;
    6062}
     63
     64static void jabber_generate_id_hash( struct jabber_data *jd );
    6165
    6266static void jabber_login( account_t *acc )
     
    200204                imcb_add_buddy( ic, JABBER_XMLCONSOLE_HANDLE, NULL );
    201205        }
     206       
     207        jabber_generate_id_hash( jd );
     208}
     209
     210static void jabber_generate_id_hash( struct jabber_data *jd )
     211{
     212        md5_state_t id_hash;
     213        md5_byte_t binbuf[16];
     214        char *s;
     215       
     216        md5_init( &id_hash );
     217        md5_append( &id_hash, (unsigned char *) jd->username, strlen( jd->username ) );
     218        md5_append( &id_hash, (unsigned char *) jd->server, strlen( jd->server ) );
     219        s = set_getstr( &jd->ic->acc->set, "resource" );
     220        md5_append( &id_hash, (unsigned char *) s, strlen( s ) );
     221        random_bytes( binbuf, 16 );
     222        md5_append( &id_hash, binbuf, 16 );
     223        md5_finish( &id_hash, binbuf );
     224       
     225        s = base64_encode( binbuf, 9 );
     226        jd->cached_id_prefix = g_strdup_printf( "%s%s", JABBER_CACHED_ID, s );
     227        g_free( s );
     228       
     229        printf( "%s\n", jd->cached_id_prefix );
    202230}
    203231
Note: See TracChangeset for help on using the changeset viewer.