Changeset 8a90001 for protocols/jabber/s5bytestream.c
- Timestamp:
- 2008-07-22T12:37:49Z (16 years ago)
- Branches:
- master
- Children:
- 4ac647d
- Parents:
- 9afeefa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/s5bytestream.c
r9afeefa r8a90001 362 362 tf->ft->free = jabber_bs_free_transfer; 363 363 364 jabber_bs_recv_handshake( bt, 0, 0 );364 jabber_bs_recv_handshake( bt, -1, 0 ); 365 365 366 366 return XT_HANDLED; … … 381 381 int gret; 382 382 383 if ( ( fd != 0) && !jabber_bs_poll( bt, fd, &revents ) )383 if ( ( fd != -1 ) && !jabber_bs_poll( bt, fd, &revents ) ) 384 384 return FALSE; 385 385 … … 554 554 { 555 555 bt->sh = shlist->next->data; 556 return jabber_bs_recv_handshake( bt, 0, 0 );556 return jabber_bs_recv_handshake( bt, -1, 0 ); 557 557 } 558 558 … … 620 620 struct jabber_transfer *tf = bt->tf; 621 621 622 if( fd != 0) /* called via event thread */622 if( fd != -1 ) /* called via event thread */ 623 623 { 624 624 tf->watch_in = 0; … … 666 666 } 667 667 668 jabber_bs_recv_read( tf->streamhandle, 0, 0 );668 jabber_bs_recv_read( tf->streamhandle, -1 , 0 ); 669 669 670 670 return TRUE; … … 776 776 /* using a proxy, abort listen */ 777 777 778 if 778 if( tf->watch_in ) 779 779 { 780 780 b_event_remove( tf->watch_in ); … … 782 782 } 783 783 784 closesocket( tf->fd ); 785 tf->fd = 0; 784 if( tf->fd != -1 ) { 785 closesocket( tf->fd ); 786 tf->fd = -1; 787 } 786 788 787 789 if ( bt->connect_timeout ) … … 798 800 { 799 801 bt->sh = sh; 800 jabber_bs_recv_handshake( bt, 0, 0 );802 jabber_bs_recv_handshake( bt, -1, 0 ); 801 803 return XT_HANDLED; 802 804 } … … 872 874 } 873 875 876 jabber_streamhost_t *jabber_si_parse_proxy( struct im_connection *ic, char *proxy ) 877 { 878 char *host, *port, *jid; 879 jabber_streamhost_t *sh; 880 881 if( ( ( host = strchr( proxy, ',' ) ) == 0 ) || 882 ( ( port = strchr( host+1, ',' ) ) == 0 ) ) { 883 imcb_log( ic, "Error parsing proxy setting: \"%s\" (ignored)", proxy ); 884 return NULL; 885 } 886 887 jid = proxy; 888 *host++ = '\0'; 889 *port++ = '\0'; 890 891 sh = g_new0( jabber_streamhost_t, 1 ); 892 sh->jid = g_strdup( jid ); 893 sh->host = g_strdup( host ); 894 strcpy( sh->port, port ); 895 896 return sh; 897 } 898 899 void jabber_si_set_proxies( struct bs_transfer *bt ) 900 { 901 struct jabber_transfer *tf = bt->tf; 902 struct jabber_data *jd = tf->ic->proto_data; 903 char *proxysetting = g_strdup ( set_getstr( &tf->ic->acc->set, "proxy" ) ); 904 char *proxy,*next; 905 char port[6]; 906 char host[INET6_ADDRSTRLEN]; 907 jabber_streamhost_t *sh, *sh2; 908 GSList *streamhosts = jd->streamhosts; 909 910 proxy = proxysetting; 911 while ( proxy && ( *proxy!='\0' ) ) { 912 if( ( next = strchr( proxy, ';' ) ) ) 913 *next++ = '\0'; 914 915 if( ( strcmp( proxy, "<local>" ) == 0 ) && jabber_bs_send_listen( bt, &tf->saddr, host, port ) ) { 916 sh = g_new0( jabber_streamhost_t, 1 ); 917 sh->jid = g_strdup( tf->ini_jid ); 918 sh->host = g_strdup( host ); 919 strcpy( sh->port, port ); 920 bt->streamhosts = g_slist_append( bt->streamhosts, sh ); 921 922 bt->tf->watch_in = b_input_add( tf->fd, GAIM_INPUT_READ, jabber_bs_send_handshake, bt ); 923 bt->connect_timeout = b_timeout_add( JABBER_BS_LISTEN_TIMEOUT * 1000, jabber_bs_connect_timeout, bt ); 924 } else if( strcmp( proxy, "<auto>" ) == 0 ) { 925 while ( streamhosts ) { 926 sh = g_new0( jabber_streamhost_t, 1 ); 927 sh2 = streamhosts->data; 928 sh->jid = g_strdup( sh2->jid ); 929 sh->host = g_strdup( sh2->host ); 930 strcpy( sh->port, sh2->port ); 931 bt->streamhosts = g_slist_append( bt->streamhosts, sh ); 932 streamhosts = g_slist_next( streamhosts ); 933 } 934 } else if( ( sh = jabber_si_parse_proxy( tf->ic, proxy ) ) ) 935 bt->streamhosts = g_slist_append( bt->streamhosts, sh ); 936 proxy = next; 937 } 938 } 939 874 940 /* 875 941 * Starts a bytestream. … … 877 943 gboolean jabber_bs_send_start( struct jabber_transfer *tf ) 878 944 { 879 char host[INET6_ADDRSTRLEN];880 945 struct bs_transfer *bt; 881 946 sha1_state_t sha; … … 883 948 unsigned char hash[20]; 884 949 int i,ret; 885 struct jabber_data *jd = tf->ic->proto_data;886 jabber_streamhost_t sh;887 GSList *streamhosts = jd->streamhosts;888 950 889 951 /* SHA1( SID + Initiator JID + Target JID ) is given to the streamhost which it will match against the initiator's value */ … … 905 967 tf->ft->canceled = jabber_bs_canceled; 906 968 907 if ( !jabber_bs_send_listen( bt, &tf->saddr, sh.host = host, sh.port ) ) 908 return FALSE; 909 910 bt->tf->watch_in = b_input_add( tf->fd, GAIM_INPUT_READ, jabber_bs_send_handshake, bt ); 911 bt->connect_timeout = b_timeout_add( JABBER_BS_LISTEN_TIMEOUT * 1000, jabber_bs_connect_timeout, bt ); 912 913 sh.jid = tf->ini_jid; 914 915 /* temporarily add listen address to streamhosts, send the request and remove it */ 916 streamhosts = g_slist_prepend( streamhosts, &sh ); 917 ret = jabber_bs_send_request( tf, streamhosts); 918 streamhosts = g_slist_remove( streamhosts, &sh ); 969 jabber_si_set_proxies( bt ); 970 971 ret = jabber_bs_send_request( tf, bt->streamhosts); 919 972 920 973 return ret;
Note: See TracChangeset
for help on using the changeset viewer.