Changeset 8661caa for protocols/jabber/jabber.c
- Timestamp:
- 2008-08-04T14:45:24Z (16 years ago)
- Branches:
- master
- Children:
- 87f525e
- Parents:
- 4ac647d (diff), 718e05f (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/jabber.c
r4ac647d r8661caa 33 33 #include "jabber.h" 34 34 #include "md5.h" 35 #include "base64.h"36 35 37 36 GSList *jabber_connections; 38 37 38 /* First enty is the default */ 39 static 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 39 55 static void jabber_init( account_t *acc ) 40 56 { 41 57 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 ); 44 62 s->flags |= ACC_SET_OFFLINE_ONLY; 45 63 … … 74 92 struct ns_srv_reply *srv = NULL; 75 93 char *connect_to, *s; 94 int i; 76 95 77 96 /* For now this is needed in the _connected() handlers if using … … 179 198 imcb_log( ic, "Connecting" ); 180 199 181 if( set_getint( &acc->set, "port" ) < JABBER_PORT_MIN || 182 set_getint( &acc->set, "port" ) > JABBER_PORT_MAX ) 183 { 184 imcb_log( ic, "Incorrect port number, must be in the %d-%d range", 185 JABBER_PORT_MIN, JABBER_PORT_MAX ); 200 for( i = 0; jabber_port_list[i] > 0; i ++ ) 201 if( set_getint( &acc->set, "port" ) == jabber_port_list[i] ) 202 break; 203 204 if( jabber_port_list[i] == 0 ) 205 { 206 imcb_log( ic, "Illegal port number" ); 186 207 imc_logout( ic, FALSE ); 187 208 return; … … 221 242 } 222 243 244 /* This generates an unfinished md5_state_t variable. Every time we generate 245 an ID, we finish the state by adding a sequence number and take the hash. */ 223 246 static void jabber_generate_id_hash( struct jabber_data *jd ) 224 247 { 225 md5_state_t id_hash; 226 md5_byte_t binbuf[16]; 248 md5_byte_t binbuf[4]; 227 249 char *s; 228 250 229 md5_init( & id_hash);230 md5_append( & id_hash, (unsigned char *) jd->username, strlen( jd->username ) );231 md5_append( & id_hash, (unsigned char *) jd->server, strlen( jd->server ) );251 md5_init( &jd->cached_id_prefix ); 252 md5_append( &jd->cached_id_prefix, (unsigned char *) jd->username, strlen( jd->username ) ); 253 md5_append( &jd->cached_id_prefix, (unsigned char *) jd->server, strlen( jd->server ) ); 232 254 s = set_getstr( &jd->ic->acc->set, "resource" ); 233 md5_append( &id_hash, (unsigned char *) s, strlen( s ) ); 234 random_bytes( binbuf, 16 ); 235 md5_append( &id_hash, binbuf, 16 ); 236 md5_finish( &id_hash, binbuf ); 237 238 s = base64_encode( binbuf, 9 ); 239 jd->cached_id_prefix = g_strdup_printf( "%s%s", JABBER_CACHED_ID, s ); 240 g_free( s ); 255 md5_append( &jd->cached_id_prefix, (unsigned char *) s, strlen( s ) ); 256 random_bytes( binbuf, 4 ); 257 md5_append( &jd->cached_id_prefix, binbuf, 4 ); 241 258 } 242 259 … … 281 298 xt_free( jd->xt ); 282 299 283 g_free( jd->cached_id_prefix );284 300 g_free( jd->away_message ); 285 301 g_free( jd->username );
Note: See TracChangeset
for help on using the changeset viewer.