Changes in / [32c632f:00f434f]


Ignore:
Files:
2 added
23 edited

Legend:

Unmodified
Added
Removed
  • Makefile

    r32c632f r00f434f  
    1010
    1111# Program variables
    12 objects = account.o bitlbee.o commands.o conf.o crypting.o help.o ini.o irc.o log.o nick.o query.o set.o unix.o url.o user.o storage_text.o storage.o
     12objects = account.o bitlbee.o commands.o conf.o crypting.o help.o ini.o irc.o log.o nick.o query.o set.o storage.o storage_text.o unix.o url.o user.o
    1313subdirs = protocols
    1414
  • configure

    r32c632f r00f434f  
    256256        if [ "$ret" = "0" ]; then
    257257                echo
    258                 echo 'WARNING: Could not find a suitable SSL library (GnuTLS, libnss or OpenSSL).'
    259                 echo '         This is necessary for MSN and full Jabber support. To continue,'
    260                 echo '         install a suitable SSL library or disable MSN support (--msn=0).'
    261                 echo '         If you want Jabber without SSL support you can try --ssl=bogus.'
     258                echo 'ERROR: Could not find a suitable SSL library (GnuTLS, libnss or OpenSSL).'
     259                echo '       This is necessary for MSN and full Jabber support. To continue,'
     260                echo '       install a suitable SSL library or disable MSN support (--msn=0).'
     261                echo '       If you want Jabber without SSL support you can try --ssl=bogus.'
    262262               
    263263                exit 1;
     
    312312        echo '#define WITH_MSN' >> config.h
    313313        protocols=$protocols'msn '
    314         protoobjs=$protoobjs'msnn.o '
     314        protoobjs=$protoobjs'msn_mod.o '
    315315fi
    316316
     
    320320        echo '#define WITH_JABBER' >> config.h
    321321        protocols=$protocols'jabber '
    322         protoobjs=$protoobjs'jabberr.o '
     322        protoobjs=$protoobjs'jabber_mod.o '
    323323fi
    324324
     
    328328        echo '#define WITH_OSCAR' >> config.h
    329329        protocols=$protocols'oscar '
    330         protoobjs=$protoobjs'oscarr.o '
     330        protoobjs=$protoobjs'oscar_mod.o '
    331331fi
    332332
     
    336336        echo '#define WITH_YAHOO' >> config.h
    337337        protocols=$protocols'yahoo '
    338         protoobjs=$protoobjs'yahooo.o '
     338        protoobjs=$protoobjs'yahoo_mod.o '
    339339fi
    340340
  • irc.c

    r32c632f r00f434f  
    10761076        irc_reply( irc,   3, ":%s", IRCD_INFO );
    10771077        irc_reply( irc,   4, "%s %s %s %s", irc->myhost, BITLBEE_VERSION, UMODES, CMODES );
     1078        irc_reply( irc,   5, "PREFIX=(ov)@+ CHANTYPES=#& CHANMODES=,,,%s NICKLEN=%d NETWORK=BitlBee CASEMAPPING=rfc1459 MAXTARGETS=1 WATCH=128 :are supported by this server", CMODES, MAX_NICK_LENGTH - 1 );
    10781079        irc_motd( irc );
    10791080        irc_umode_set( irc, irc->myhost, "+" UMODE );
  • protocols/Makefile

    r32c632f r00f434f  
    1010
    1111# [SH] Program variables
    12 objects = md5.o nogaim.o proxy.o sha.o util.o $(SSL_CLIENT)
     12objects = http_client.o md5.o nogaim.o proxy.o sha.o $(SSL_CLIENT) util.o
    1313
    1414# [SH] The next two lines should contain the directory name (in $(subdirs))
  • protocols/jabber/Makefile

    r32c632f r00f434f  
    1616
    1717# [SH] Phony targets
    18 all: jabberr.o
     18all: jabber_mod.o
    1919
    2020.PHONY: all clean distclean
     
    3333        @$(CC) -c $(CFLAGS) $< -o $@
    3434
    35 jabberr.o: $(objects)
    36         @echo '*' Linking jabberr.o
    37         @$(LD) $(LFLAGS) $(objects) -o jabberr.o
     35jabber_mod.o: $(objects)
     36        @echo '*' Linking jabber_mod.o
     37        @$(LD) $(LFLAGS) $(objects) -o jabber_mod.o
  • protocols/msn/Makefile

    r32c632f r00f434f  
    1616
    1717# [SH] Phony targets
    18 all: msnn.o
     18all: msn_mod.o
    1919       
    2020.PHONY: all clean distclean
     
    3333        @$(CC) -c $(CFLAGS) $< -o $@
    3434
    35 msnn.o: $(objects)
    36         @echo '*' Linking msnn.o
    37         @$(LD) $(LFLAGS) $(objects) -o msnn.o
     35msn_mod.o: $(objects)
     36        @echo '*' Linking msn_mod.o
     37        @$(LD) $(LFLAGS) $(objects) -o msn_mod.o
    3838       
    3939
  • protocols/msn/msn.h

    r32c632f r00f434f  
    127127#define STATUS_FATAL            1
    128128#define STATUS_SB_FATAL         2
     129#define STATUS_SB_IM_SPARE      4       /* Make one-to-one conversation switchboard available again, invite failed. */
     130#define STATUS_SB_CHAT_SPARE    8       /* Same, but also for groupchats (not used yet). */
    129131
    130132int msn_chat_id;
  • protocols/msn/ns.c

    r32c632f r00f434f  
    208208                {
    209209                        /* Time for some Passport black magic... */
    210                         if( !passport_get_id( gc, gc->username, gc->password, cmd[4], msn_auth_got_passport_id ) )
     210                        if( !passport_get_id( msn_auth_got_passport_id, gc, gc->username, gc->password, cmd[4] ) )
    211211                        {
    212212                                hide_login_progress_error( gc, "Error while contacting Passport server" );
  • protocols/msn/passport.c

    r32c632f r00f434f  
    2020 */
    2121
    22 #include "ssl_client.h"
     22#include "http_client.h"
    2323#include "passport.h"
    2424#include "msn.h"
     
    3131static char *prd_cached = NULL;
    3232
    33 static char *passport_create_header( char *reply, char *email, char *pwd );
     33static int passport_get_id_real( gpointer func, gpointer data, char *header );
     34static void passport_get_id_ready( struct http_request *req );
     35
    3436static int passport_retrieve_dalogin( gpointer data, gpointer func, char *header );
    35 static void passport_retrieve_dalogin_connected( gpointer data, void *ssl, GaimInputCondition cond );
    36 static int passport_get_id_from( gpointer data, gpointer func, char *header_i, char *url );
    37 static void passport_get_id_connected( gpointer data, void *ssl, GaimInputCondition cond );
     37static void passport_retrieve_dalogin_ready( struct http_request *req );
     38
     39static char *passport_create_header( char *cookie, char *email, char *pwd );
    3840static void destroy_reply( struct passport_reply *rep );
    3941
    40 
    41 int passport_get_id( gpointer data, char *username, char *password, char *cookie, gpointer func )
     42int passport_get_id( gpointer func, gpointer data, char *username, char *password, char *cookie )
    4243{
    4344        char *header = passport_create_header( cookie, username, password );
    4445       
    45         if( prd_cached )
    46         {
    47                 int st;
    48                
    49                 st = passport_get_id_from( data, func, header, prd_cached );
    50                 g_free( header );
    51                 return( st );
    52         }
     46        if( prd_cached == NULL )
     47                return passport_retrieve_dalogin( func, data, header );
    5348        else
    54         {
    55                 return( passport_retrieve_dalogin( data, func, header ) );
    56         }
    57 }
    58 
    59 
    60 static char *passport_create_header( char *reply, char *email, char *pwd )
    61 {
    62         char *buffer = g_new0( char, 2048 );
    63         char *currenttoken;
    64         char *email_enc, *pwd_enc;
    65        
    66         email_enc = g_new0( char, strlen( email ) * 3 + 1 );
    67         strcpy( email_enc, email );
    68         http_encode( email_enc );
    69        
    70         pwd_enc = g_new0( char, strlen( pwd ) * 3 + 1 );
    71         strcpy( pwd_enc, pwd );
    72         http_encode( pwd_enc );
    73        
    74         currenttoken = strstr( reply, "lc=" );
    75         if( currenttoken == NULL )
    76                 return( NULL );
    77        
    78         g_snprintf( buffer, 2048,
    79                     "Authorization: Passport1.4 OrgVerb=GET,"
    80                     "OrgURL=http%%3A%%2F%%2Fmessenger%%2Emsn%%2Ecom,"
    81                     "sign-in=%s,pwd=%s,%s", email_enc, pwd_enc,
    82                     currenttoken );
    83        
    84         g_free( email_enc );
    85         g_free( pwd_enc );
    86        
    87         return( buffer );
    88 }
    89 
    90 
    91 static int passport_retrieve_dalogin( gpointer data, gpointer func, char *header )
    92 {
    93         struct passport_reply *rep = g_new0( struct passport_reply, 1 );
    94         void *ssl;
    95        
     49                return passport_get_id_real( func, data, header );
     50}
     51
     52static int passport_get_id_real( gpointer func, gpointer data, char *header )
     53{
     54        struct passport_reply *rep;
     55        char *server, *dummy, *reqs;
     56        struct http_request *req;
     57       
     58        rep = g_new0( struct passport_reply, 1 );
    9659        rep->data = data;
    9760        rep->func = func;
    98         rep->header = header;
    99        
    100         ssl = ssl_connect( "nexus.passport.com", 443, passport_retrieve_dalogin_connected, rep );
    101        
    102         if( !ssl )
    103                 destroy_reply( rep );
    104        
    105         return( ssl != NULL );
    106 }
    107 
    108 #define PPR_BUFFERSIZE 2048
    109 #define PPR_REQUEST "GET /rdr/pprdr.asp HTTP/1.0\r\n\r\n"
    110 static void passport_retrieve_dalogin_connected( gpointer data, void *ssl, GaimInputCondition cond )
    111 {
    112         int ret;
    113         char buffer[PPR_BUFFERSIZE+1];
    114         struct passport_reply *rep = data;
    115        
    116         if( !g_slist_find( msn_connections, rep->data ) )
    117         {
    118                 if( ssl ) ssl_disconnect( ssl );
     61       
     62        server = g_strdup( prd_cached );
     63        dummy = strchr( server, '/' );
     64       
     65        if( dummy == NULL )
     66        {
     67                destroy_reply( rep );
     68                return( 0 );
     69        }
     70       
     71        reqs = g_malloc( strlen( header ) + strlen( dummy ) + 128 );
     72        sprintf( reqs, "GET %s HTTP/1.0\r\n%s\r\n\r\n", dummy, header );
     73       
     74        *dummy = 0;
     75        req = http_dorequest( server, 443, 1, reqs, passport_get_id_ready, rep );
     76       
     77        g_free( server );
     78        g_free( reqs );
     79       
     80        if( req == NULL )
     81                destroy_reply( rep );
     82       
     83        return( req != NULL );
     84}
     85
     86static void passport_get_id_ready( struct http_request *req )
     87{
     88        struct passport_reply *rep = req->data;
     89       
     90        if( !g_slist_find( msn_connections, rep->data ) || !req->finished || !req->reply_headers )
     91        {
    11992                destroy_reply( rep );
    12093                return;
    12194        }
    12295       
    123         if( !ssl )
    124         {
    125                 rep->func( rep );
    126                 destroy_reply( rep );
    127                 return;
    128         }
    129        
    130         ssl_write( ssl, PPR_REQUEST, strlen( PPR_REQUEST ) );
    131        
    132         if( ( ret = ssl_read( ssl, buffer, PPR_BUFFERSIZE ) ) <= 0 )
    133         {
    134                 goto failure;
    135         }
    136 
    137         {
    138                 char *dalogin = strstr( buffer, "DALogin=" );
    139                 char *urlend;
     96        if( req->status_code == 200 )
     97        {
     98                char *dummy;
    14099               
    141                 if( !dalogin )
    142                         goto failure;
    143                
    144                 dalogin += strlen( "DALogin=" );
    145                 urlend = strchr( dalogin, ',' );
    146                 if( urlend )
    147                         *urlend = 0;
    148                
    149                 /* strip the http(s):// part from the url */
    150                 urlend = strstr( urlend, "://" );
    151                 if( urlend )
    152                         dalogin = urlend + strlen( "://" );
    153                
    154                 if( prd_cached == NULL )
    155                         prd_cached = g_strdup( dalogin );
    156         }
    157        
    158         if( passport_get_id_from( rep->data, rep->func, rep->header, prd_cached ) )
    159         {
    160                 ssl_disconnect( ssl );
    161                 destroy_reply( rep );
    162                 return;
    163         }
    164        
    165 failure:       
    166         ssl_disconnect( ssl );
    167         rep->func( rep );
    168         destroy_reply( rep );
    169 }
    170 
    171 
    172 static int passport_get_id_from( gpointer data, gpointer func, char *header_i, char *url )
    173 {
    174         struct passport_reply *rep = g_new0( struct passport_reply, 1 );
    175         char server[512], *dummy;
    176         void *ssl;
    177        
    178         rep->data = data;
    179         rep->func = func;
    180         rep->redirects = 4;
    181        
    182         strncpy( server, url, 512 );
    183         dummy = strchr( server, '/' );
    184         if( dummy )
    185                 *dummy = 0;
    186        
    187         ssl = ssl_connect( server, 443, passport_get_id_connected, rep );
    188        
    189         if( ssl )
    190         {
    191                 rep->header = g_strdup( header_i );
    192                 rep->url = g_strdup( url );
    193         }
    194         else
    195         {
    196                 destroy_reply( rep );
    197         }
    198        
    199         return( ssl != NULL );
    200 }
    201 
    202 #define PPG_BUFFERSIZE 4096
    203 static void passport_get_id_connected( gpointer data, void *ssl, GaimInputCondition cond )
    204 {
    205         struct passport_reply *rep = data;
    206         char server[512], buffer[PPG_BUFFERSIZE+1], *dummy;
    207         int ret;
    208        
    209         if( !g_slist_find( msn_connections, rep->data ) )
    210         {
    211                 if( ssl ) ssl_disconnect( ssl );
    212                 destroy_reply( rep );
    213                 return;
    214         }
    215        
    216         if( !ssl )
    217         {
    218                 rep->func( rep );
    219                 destroy_reply( rep );
    220                 return;
    221         }
    222        
    223         memset( buffer, 0, PPG_BUFFERSIZE + 1 );
    224        
    225         strncpy( server, rep->url, 512 );
    226         dummy = strchr( server, '/' );
    227         if( dummy == NULL )
    228                 goto end;
    229        
    230         g_snprintf( buffer, PPG_BUFFERSIZE - 1, "GET %s HTTP/1.0\r\n"
    231                     "%s\r\n\r\n", dummy, rep->header );
    232        
    233         ssl_write( ssl, buffer, strlen( buffer ) );
    234         memset( buffer, 0, PPG_BUFFERSIZE + 1 );
    235        
    236         {
    237                 char *buffer2 = buffer;
    238                
    239                 while( ( ( ret = ssl_read( ssl, buffer2, 512 ) ) > 0 ) &&
    240                        ( buffer + PPG_BUFFERSIZE - buffer2 - ret - 512 >= 0 ) )
    241                 {
    242                         buffer2 += ret;
    243                 }
    244         }
    245        
    246         if( *buffer == 0 )
    247                 goto end;
    248        
    249         if( ( dummy = strstr( buffer, "Location:" ) ) )
    250         {
    251                 char *urlend;
    252                
    253                 rep->redirects --;
    254                 if( rep->redirects == 0 )
    255                         goto end;
    256                
    257                 dummy += strlen( "Location:" );
    258                 while( isspace( *dummy ) ) dummy ++;
    259                 urlend = dummy;
    260                 while( !isspace( *urlend ) ) urlend ++;
    261                 *urlend = 0;
    262                 if( ( urlend = strstr( dummy, "://" ) ) )
    263                         dummy = urlend + strlen( "://" );
    264                
    265                 g_free( rep->url );
    266                 rep->url = g_strdup( dummy );
    267                
    268                 strncpy( server, dummy, sizeof( server ) - 1 );
    269                 dummy = strchr( server, '/' );
    270                 if( dummy ) *dummy = 0;
    271                
    272                 ssl_disconnect( ssl );
    273                
    274                 if( ssl_connect( server, 443, passport_get_id_connected, rep ) )
    275                 {
    276                         return;
    277                 }
    278                 else
    279                 {
    280                         rep->func( rep );
    281                         destroy_reply( rep );
    282                         return;
    283                 }
    284         }
    285         else if( strstr( buffer, "200 OK" ) )
    286         {
    287                 if( ( dummy = strstr( buffer, "from-PP='" ) ) )
     100                if( ( dummy = strstr( req->reply_headers, "from-PP='" ) ) )
    288101                {
    289102                        char *responseend;
     
    298111        }
    299112       
    300 end:
    301         ssl_disconnect( ssl );
    302113        rep->func( rep );
    303114        destroy_reply( rep );
    304115}
    305116
     117static char *passport_create_header( char *cookie, char *email, char *pwd )
     118{
     119        char *buffer = g_new0( char, 2048 );
     120        char *currenttoken;
     121        char *email_enc, *pwd_enc;
     122       
     123        email_enc = g_new0( char, strlen( email ) * 3 + 1 );
     124        strcpy( email_enc, email );
     125        http_encode( email_enc );
     126       
     127        pwd_enc = g_new0( char, strlen( pwd ) * 3 + 1 );
     128        strcpy( pwd_enc, pwd );
     129        http_encode( pwd_enc );
     130       
     131        currenttoken = strstr( cookie, "lc=" );
     132        if( currenttoken == NULL )
     133                return( NULL );
     134       
     135        g_snprintf( buffer, 2048,
     136                    "Authorization: Passport1.4 OrgVerb=GET,"
     137                    "OrgURL=http%%3A%%2F%%2Fmessenger%%2Emsn%%2Ecom,"
     138                    "sign-in=%s,pwd=%s,%s", email_enc, pwd_enc,
     139                    currenttoken );
     140       
     141        g_free( email_enc );
     142        g_free( pwd_enc );
     143       
     144        return( buffer );
     145}
     146
     147#define PPR_REQUEST "GET /rdr/pprdr.asp HTTP/1.0\r\n\r\n"
     148static int passport_retrieve_dalogin( gpointer func, gpointer data, char *header )
     149{
     150        struct passport_reply *rep = g_new0( struct passport_reply, 1 );
     151        struct http_request *req;
     152       
     153        rep->data = data;
     154        rep->func = func;
     155        rep->header = header;
     156       
     157        req = http_dorequest( "nexus.passport.com", 443, 1, PPR_REQUEST, passport_retrieve_dalogin_ready, rep );
     158       
     159        if( !req )
     160                destroy_reply( rep );
     161       
     162        return( req != NULL );
     163}
     164
     165static void passport_retrieve_dalogin_ready( struct http_request *req )
     166{
     167        struct passport_reply *rep = req->data;
     168        char *dalogin;
     169        char *urlend;
     170       
     171        if( !g_slist_find( msn_connections, rep->data ) || !req->finished || !req->reply_headers )
     172        {
     173                destroy_reply( rep );
     174                return;
     175        }
     176       
     177        dalogin = strstr( req->reply_headers, "DALogin=" );     
     178       
     179        if( !dalogin )
     180                goto failure;
     181       
     182        dalogin += strlen( "DALogin=" );
     183        urlend = strchr( dalogin, ',' );
     184        if( urlend )
     185                *urlend = 0;
     186       
     187        /* strip the http(s):// part from the url */
     188        urlend = strstr( urlend, "://" );
     189        if( urlend )
     190                dalogin = urlend + strlen( "://" );
     191       
     192        if( prd_cached == NULL )
     193                prd_cached = g_strdup( dalogin );
     194       
     195        if( passport_get_id_real( rep->func, rep->data, rep->header ) )
     196        {
     197                destroy_reply( rep );
     198                return;
     199        }
     200       
     201failure:       
     202        rep->func( rep );
     203        destroy_reply( rep );
     204}
    306205
    307206static void destroy_reply( struct passport_reply *rep )
    308207{
    309         if( rep->result ) g_free( rep->result );
    310         if( rep->url ) g_free( rep->url );
    311         if( rep->header ) g_free( rep->header );
    312         if( rep ) g_free( rep );
    313 }
     208        g_free( rep->result );
     209        g_free( rep->header );
     210        g_free( rep );
     211}
  • protocols/msn/passport.h

    r32c632f r00f434f  
    3535struct passport_reply
    3636{
     37        void (*func)( struct passport_reply * );
    3738        void *data;
    3839        char *result;
    39         void (*func)( struct passport_reply * );
    40         char *url;
    4140        char *header;
    42         int redirects;
    4341};
    4442
    45 int passport_get_id( gpointer data, char *username, char *password, char *cookie, gpointer func );
     43int passport_get_id( gpointer func, gpointer data, char *username, char *password, char *cookie );
    4644
    4745#endif /* __PASSPORT_H__ */
  • protocols/msn/sb.c

    r32c632f r00f434f  
    522522                        return( 0 );
    523523                }
    524                 else if( err->flags & STATUS_FATAL )
     524                if( err->flags & STATUS_FATAL )
    525525                {
    526526                        signoff( gc );
    527527                        return( 0 );
     528                }
     529                if( err->flags & STATUS_SB_IM_SPARE )
     530                {
     531                        if( sb->who )
     532                        {
     533                                struct msn_message *m;
     534                                GSList *l;
     535                               
     536                                /* Apparently some invitation failed. We might want to use this
     537                                   board later, so keep it as a spare. */
     538                                g_free( sb->who );
     539                                sb->who = NULL;
     540                               
     541                                /* Also clear the msgq, otherwise someone else might get them. */
     542                                for( l = sb->msgq; l; l = l->next )
     543                                {
     544                                        m = l->data;
     545                                        g_free( m->who );
     546                                        g_free( m->text );
     547                                        g_free( m );
     548                                }
     549                                g_slist_free( sb->msgq );
     550                                sb->msgq = NULL;
     551                        }
    528552                }
    529553        }
  • protocols/msn/tables.c

    r32c632f r00f434f  
    8080        { 206, "Domain name missing",                                   0 },
    8181        { 207, "Already logged in",                                     0 },
    82         { 208, "Invalid handle",                                        0 },
     82        { 208, "Invalid handle",                                        STATUS_SB_IM_SPARE },
    8383        { 209, "Forbidden nickname",                                    0 },
    8484        { 210, "Buddy list too long",                                   0 },
    8585        { 215, "Handle is already in list",                             0 },
    86         { 216, "Handle is not in list",                                 0 },
    87         { 217, "Person is off-line or non-existent",                    0 },
     86        { 216, "Handle is not in list",                                 STATUS_SB_IM_SPARE },
     87        { 217, "Person is off-line or non-existent",                    STATUS_SB_IM_SPARE },
    8888        { 218, "Already in that mode",                                  0 },
    8989        { 219, "Handle is already in opposite list",                    0 },
     
    118118        { 711, "Write is blocking",                                     STATUS_FATAL },
    119119        { 712, "Session is overloaded",                                 STATUS_FATAL },
    120         { 713, "Calling too rapidly",                                   0 },
     120        { 713, "Calling too rapidly",                                   STATUS_SB_IM_SPARE },
    121121        { 714, "Too many sessions",                                     STATUS_FATAL },
    122122        { 715, "Not expected/Invalid argument/action",                  0 },
  • protocols/oscar/Makefile

    r32c632f r00f434f  
    1616
    1717# [SH] Phony targets
    18 all: oscarr.o
     18all: oscar_mod.o
    1919
    2020.PHONY: all clean distclean
     
    3333        @$(CC) -c $(CFLAGS) $< -o $@
    3434
    35 oscarr.o: $(objects)
    36         @echo '*' Linking oscarr.o
    37         @$(LD) $(LFLAGS) $(objects) -o oscarr.o
     35oscar_mod.o: $(objects)
     36        @echo '*' Linking oscar_mod.o
     37        @$(LD) $(LFLAGS) $(objects) -o oscar_mod.o
  • protocols/proxy.c

    r32c632f r00f434f  
    106106        if (condition & GAIM_WRITE_COND)
    107107                gaim_cond |= GAIM_INPUT_WRITE;
    108 //      if (condition & GAIM_ERR_COND)
    109 //              fprintf( stderr, "ERROR! fd=%d\n", g_io_channel_unix_get_fd( source ) );
    110108
    111109        closure->function(closure->data, g_io_channel_unix_get_fd(source), gaim_cond);
  • protocols/ssl_bogus.c

    r32c632f r00f434f  
    2828int ssl_errno;
    2929
    30 void *ssl_connect( char *host, int port, SslInputFunction func, gpointer data )
     30void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data )
    3131{
    3232        return( NULL );
  • protocols/ssl_client.h

    r32c632f r00f434f  
    3333extern int ssl_errno;
    3434
    35 typedef void (*SslInputFunction)(gpointer, void*, GaimInputCondition);
     35typedef void (*ssl_input_function)(gpointer, void*, GaimInputCondition);
    3636
    37 G_MODULE_EXPORT void *ssl_connect( char *host, int port, SslInputFunction func, gpointer data );
     37G_MODULE_EXPORT void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data );
    3838G_MODULE_EXPORT int ssl_read( void *conn, char *buf, int len );
    3939G_MODULE_EXPORT int ssl_write( void *conn, const char *buf, int len );
    4040G_MODULE_EXPORT void ssl_disconnect( void *conn_ );
    4141G_MODULE_EXPORT int ssl_getfd( void *conn );
     42G_MODULE_EXPORT GaimInputCondition ssl_getdirection( void *conn );
  • protocols/ssl_gnutls.c

    r32c632f r00f434f  
    3838struct scd
    3939{
    40         SslInputFunction func;
     40        ssl_input_function func;
    4141        gpointer data;
    4242        int fd;
     
    5151
    5252
    53 void *ssl_connect( char *host, int port, SslInputFunction func, gpointer data )
     53void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data )
    5454{
    5555        struct scd *conn = g_new0( struct scd, 1 );
     
    111111       
    112112        if( conn->inpa != -1 )
     113        {
    113114                gaim_input_remove( conn->inpa );
     115                conn->inpa = -1;
     116        }
    114117       
    115118        if( ( st = gnutls_handshake( conn->session ) ) < 0 )
     
    117120                if( st == GNUTLS_E_AGAIN || st == GNUTLS_E_INTERRUPTED )
    118121                {
    119                         conn->inpa = gaim_input_add( conn->fd,
    120                                                      gnutls_record_get_direction( conn->session ) ?
    121                                                          GAIM_INPUT_WRITE : GAIM_INPUT_READ,
     122                        conn->inpa = gaim_input_add( conn->fd, ssl_getdirection( conn ),
    122123                                                     ssl_handshake, data );
    123124                }
     
    145146int ssl_read( void *conn, char *buf, int len )
    146147{
     148        int st;
     149       
    147150        if( !((struct scd*)conn)->established )
    148151        {
     
    151154        }
    152155       
    153         return( gnutls_record_recv( ((struct scd*)conn)->session, buf, len ) );
    154        
     156        st = gnutls_record_recv( ((struct scd*)conn)->session, buf, len );
     157       
     158        ssl_errno = SSL_OK;
     159        if( st == GNUTLS_E_AGAIN || st == GNUTLS_E_INTERRUPTED )
     160                ssl_errno = SSL_AGAIN;
     161       
     162        return st;
    155163}
    156164
    157165int ssl_write( void *conn, const char *buf, int len )
    158166{
     167        int st;
     168       
    159169        if( !((struct scd*)conn)->established )
    160170        {
     
    163173        }
    164174       
    165         return( gnutls_record_send( ((struct scd*)conn)->session, buf, len ) );
     175        st = gnutls_record_send( ((struct scd*)conn)->session, buf, len );
     176       
     177        ssl_errno = SSL_OK;
     178        if( st == GNUTLS_E_AGAIN || st == GNUTLS_E_INTERRUPTED )
     179                ssl_errno = SSL_AGAIN;
     180       
     181        return st;
    166182}
    167183
     
    169185{
    170186        struct scd *conn = conn_;
     187       
     188        if( conn->inpa != -1 )
     189                gaim_input_remove( conn->inpa );
    171190       
    172191        if( conn->established )
     
    184203        return( ((struct scd*)conn)->fd );
    185204}
     205
     206GaimInputCondition ssl_getdirection( void *conn )
     207{
     208        return( gnutls_record_get_direction( ((struct scd*)conn)->session ) ?
     209                GAIM_INPUT_WRITE : GAIM_INPUT_READ );
     210}
  • protocols/ssl_nss.c

    r32c632f r00f434f  
    4545struct scd
    4646{
    47         SslInputFunction func;
     47        ssl_input_function func;
    4848        gpointer data;
    4949        int fd;
     
    9191
    9292
    93 void *ssl_connect( char *host, int port, SslInputFunction func, gpointer data )
     93void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data )
    9494{
    9595        struct scd *conn = g_new0( struct scd, 1 );
  • protocols/ssl_openssl.c

    r32c632f r00f434f  
    4141struct scd
    4242{
    43         SslInputFunction func;
     43        ssl_input_function func;
    4444        gpointer data;
    4545        int fd;
    4646        gboolean established;
    4747       
     48        int inpa;
     49        int lasterr;            /* Necessary for SSL_get_error */
    4850        SSL *ssl;
    4951        SSL_CTX *ssl_ctx;
     
    5456
    5557
    56 void *ssl_connect( char *host, int port, SslInputFunction func, gpointer data )
     58void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data )
    5759{
    5860        struct scd *conn = g_new0( struct scd, 1 );
     
    9395}
    9496
     97static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond );
     98
    9599static void ssl_connected( gpointer data, gint source, GaimInputCondition cond )
    96100{
     
    98102       
    99103        if( source == -1 )
    100                 goto ssl_connected_failure;
    101        
     104                return ssl_handshake( data, -1, cond );
     105       
     106        /* Make it non-blocking at least during the handshake... */
     107        sock_make_nonblocking( conn->fd );
    102108        SSL_set_fd( conn->ssl, conn->fd );
    103109       
    104         if( SSL_connect( conn->ssl ) < 0 )
    105                 goto ssl_connected_failure;
     110        return ssl_handshake( data, source, cond );
     111}       
     112
     113static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond )
     114{
     115        struct scd *conn = data;
     116        int st;
     117       
     118        if( conn->inpa != -1 )
     119        {
     120                gaim_input_remove( conn->inpa );
     121                conn->inpa = -1;
     122        }
     123       
     124        if( ( st = SSL_connect( conn->ssl ) ) < 0 )
     125        {
     126                conn->lasterr = SSL_get_error( conn->ssl, st );
     127                if( conn->lasterr != SSL_ERROR_WANT_READ && conn->lasterr != SSL_ERROR_WANT_WRITE )
     128                        goto ssl_connected_failure;
     129               
     130                conn->inpa = gaim_input_add( conn->fd, ssl_getdirection( conn ), ssl_handshake, data );
     131                return;
     132        }
    106133       
    107134        conn->established = TRUE;
     135        sock_make_blocking( conn->fd );         /* For now... */
    108136        conn->func( conn->data, conn, cond );
    109137        return;
     
    127155int ssl_read( void *conn, char *buf, int len )
    128156{
     157        int st;
     158       
    129159        if( !((struct scd*)conn)->established )
    130                 return( 0 );
    131        
    132         return( SSL_read( ((struct scd*)conn)->ssl, buf, len ) );
     160        {
     161                ssl_errno = SSL_NOHANDSHAKE;
     162                return -1;
     163        }
     164       
     165        st = SSL_read( ((struct scd*)conn)->ssl, buf, len );
     166       
     167        ssl_errno = SSL_OK;
     168        if( st <= 0 )
     169        {
     170                ((struct scd*)conn)->lasterr = SSL_get_error( ((struct scd*)conn)->ssl, st );
     171                if( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_READ || ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE )
     172                        ssl_errno = SSL_AGAIN;
     173        }
     174       
     175        return st;
    133176}
    134177
    135178int ssl_write( void *conn, const char *buf, int len )
    136179{
     180        int st;
     181       
    137182        if( !((struct scd*)conn)->established )
    138                 return( 0 );
    139        
    140         return( SSL_write( ((struct scd*)conn)->ssl, buf, len ) );
     183        {
     184                ssl_errno = SSL_NOHANDSHAKE;
     185                return -1;
     186        }
     187       
     188        st = SSL_write( ((struct scd*)conn)->ssl, buf, len );
     189       
     190        ssl_errno = SSL_OK;
     191        if( st <= 0 )
     192        {
     193                ((struct scd*)conn)->lasterr = SSL_get_error( ((struct scd*)conn)->ssl, st );
     194                if( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_READ || ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE )
     195                        ssl_errno = SSL_AGAIN;
     196        }
     197       
     198        return st;
    141199}
    142200
     
    144202{
    145203        struct scd *conn = conn_;
     204       
     205        if( conn->inpa != -1 )
     206                gaim_input_remove( conn->inpa );
    146207       
    147208        if( conn->established )
     
    159220        return( ((struct scd*)conn)->fd );
    160221}
     222
     223GaimInputCondition ssl_getdirection( void *conn )
     224{
     225        return( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ? GAIM_INPUT_WRITE : GAIM_INPUT_READ );
     226}
  • protocols/yahoo/Makefile

    r32c632f r00f434f  
    1616
    1717# [SH] Phony targets
    18 all: yahooo.o
     18all: yahoo_mod.o
    1919
    2020.PHONY: all clean distclean
     
    3333        @$(CC) -c $(CFLAGS) $< -o $@
    3434
    35 yahooo.o: $(objects)
    36         @echo '*' Linking yahooo.o
    37         @$(LD) $(LFLAGS) $(objects) -o yahooo.o
     35yahoo_mod.o: $(objects)
     36        @echo '*' Linking yahoo_mod.o
     37        @$(LD) $(LFLAGS) $(objects) -o yahoo_mod.o
  • sock.h

    r32c632f r00f434f  
     1#include <errno.h>
     2#include <fcntl.h>
     3
    14#ifndef _WIN32
    25#include <unistd.h>
  • url.c

    r32c632f r00f434f  
    22  * BitlBee -- An IRC to other IM-networks gateway                     *
    33  *                                                                    *
    4   * Copyright 2001-2004 Wilmer van der Gaast and others                *
     4  * Copyright 2001-2005 Wilmer van der Gaast and others                *
    55  \********************************************************************/
    66
     
    3030{
    3131        char s[MAX_STRING];
    32         char *i, *j;
     32        char *i;
    3333       
    3434        /* protocol://                                                  */
     
    4040        else
    4141        {
    42                 if( g_strncasecmp( set_url, "http", i - set_url ) == 0 )
     42                if( g_strncasecmp( set_url, "https", i - set_url ) == 0 )
     43                        url->proto = PROTO_HTTPS;
     44                else if( g_strncasecmp( set_url, "http", i - set_url ) == 0 )
    4345                        url->proto = PROTO_HTTP;
    4446                else if( g_strncasecmp( set_url, "socks4", i - set_url ) == 0 )
     
    5658        if( ( i = strchr( s, '/' ) ) == NULL )
    5759        {
    58                 strcpy( url->dir, "/" );
     60                strcpy( url->file, "/" );
    5961        }
    6062        else
    6163        {
     64                strncpy( url->file, i, MAX_STRING );
    6265                *i = 0;
    63                 g_snprintf( url->dir, MAX_STRING, "/%s", i + 1 );
    64                 if( url->proto == PROTO_HTTP )
    65                         http_encode( url->dir );
    6666        }
    6767        strncpy( url->host, s, MAX_STRING );
    68         j = strchr( url->dir, '?' );
    69         if( j != NULL )
    70                 *j = 0;
    71         i = strrchr( url->dir, '/' );
    72         *i = 0;
    73         if( j != NULL )
    74                 *j = '?';
    75         if( i == NULL )
    76         {
    77                 strcpy( url->file, url->dir );
    78                 strcpy( url->dir, "/" );
    79         }
    80         else
    81         {
    82                 strcpy( url->file, i + 1 );
    83                 strcat( url->dir, "/" );
    84         }
    8568       
    8669        /* Check for username in host field                             */
     
    9679        else
    9780        {
    98                 if( url->proto == PROTO_FTP )
    99                 {
    100                         strcpy( url->user, "anonymous" );
    101                         strcpy( url->pass, "-p.artmaps@lintux.cx" );
    102                 }
    103                 else
    104                 {
    105                         *url->user = *url->pass = 0;
    106                 }
     81                *url->user = *url->pass = 0;
    10782        }
    10883       
     
    11792        {
    11893                *i = 0;
    119                 sscanf( i + 1, "%i", &url->port );
     94                sscanf( i + 1, "%d", &url->port );
    12095        }
    121         /* Take default port numbers from /etc/services                 */
    12296        else
    12397        {
    12498                if( url->proto == PROTO_HTTP )
    125                         url->port = 8080;
     99                        url->port = 80;
     100                else if( url->proto == PROTO_HTTPS )
     101                        url->port = 443;
    126102                else if( url->proto == PROTO_SOCKS4 || url->proto == PROTO_SOCKS4 )
    127103                        url->port = 1080;
  • url.h

    r32c632f r00f434f  
    2626#include "bitlbee.h"
    2727
    28 #define PROTO_FTP               1
    2928#define PROTO_HTTP              2
     29#define PROTO_HTTPS             5
    3030#define PROTO_SOCKS4    3
    3131#define PROTO_SOCKS5    4
     
    3737        int port;
    3838        char host[MAX_STRING];
    39         char dir[MAX_STRING];
    4039        char file[MAX_STRING];
    4140        char user[MAX_STRING];
Note: See TracChangeset for help on using the changeset viewer.