Changeset 416:2db037c7ce5f in verona


Ignore:
Timestamp:
Jan 17, 2012 3:55:07 PM (16 months ago)
Author:
Vadim Lebedev <vadim@…>
Branch:
default
rebase_source:
6126c71f04a05bf0798d5cfae88e3467840eed65
Message:

fixes for socks transport

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • libeXosip2/src/eXconf.c

    r389 r416  
    636636        int i; 
    637637        struct eXtl_protocol* proto; 
     638        int port; 
    638639 
    639640        for(i = 0; proto = socks_proto_tab[i]; i++) 
     
    650651 
    651652        eXosip.eXtl = proto; 
     653        port = atoi(tport); 
    652654        proto->tl_init(); 
    653         proto->tl_masquerade_contact(tserver, atoi(tport)); 
     655        proto->tl_masquerade_contact(tserver, port); 
    654656        snprintf(eXosip.transport, sizeof(eXosip.transport), "%s", 
    655657                        proto->proto_num == IPPROTO_UDP ? "UDP" : "TCP"); 
     
    666668        } 
    667669#endif 
    668  
    669670        return 0; 
    670671} 
     
    770771        eXosip.keep_alive = 17000; 
    771772 
    772         eXtl_udp.tl_init(); 
    773         eXtl_tcp.tl_init(); 
     773        if (!eXosip.eXtl) { 
     774                eXtl_udp.tl_init(); 
     775                eXtl_tcp.tl_init(); 
    774776#ifdef HAVE_OPENSSL_SSL_H 
    775777#if !(OPENSSL_VERSION_NUMBER < 0x00908000L) 
    776778        eXtl_dtls.tl_init(); 
    777779#endif 
    778         eXtl_tls.tl_init(); 
     780                eXtl_tls.tl_init(); 
     781        } 
    779782#endif 
    780783        return OSIP_SUCCESS; 
  • libeXosip2/src/eXtl_socks.c

    r390 r416  
    284284                return -1; 
    285285 
    286         if (resp.atp != 0) 
     286        if (resp.atp != 1) 
    287287                return -1; 
    288288 
     
    293293        ina.s_addr = resp.destip; 
    294294        osip_strncpy(sk->public_ip, inet_ntoa(ina), sizeof(sk->public_ip)-1); 
    295         sk->public_port = ntohl(resp.dport); 
     295        sk->public_port = ntohs(resp.dport); 
    296296 
    297297        return 0; 
     
    334334                                curinfo->ai_protocol); 
    335335 
    336  
    337                 if (sock < 0) { 
    338                         OSIP_TRACE(osip_trace 
    339                                         (__FILE__, __LINE__, OSIP_ERROR, NULL, 
    340                                                         "Cannot create socket %s!\n", strerror(ex_errno))); 
    341                         continue; 
    342                 } 
     336                if (sock) 
     337                        break; 
     338 
     339                OSIP_TRACE(osip_trace 
     340                                (__FILE__, __LINE__, OSIP_ERROR, NULL, 
     341                                                "Cannot create socket %s!\n", strerror(ex_errno))); 
    343342 
    344343        } 
     
    348347                sk->socket = sock; 
    349348                sk->remote_port = port; 
    350                 osip_strncpy(sk->remote_ip, addr, sizeof(sk->remote_ip)); 
     349                osip_strncpy(sk->remote_ip, addr, sizeof(sk->remote_ip)-1); 
    351350                if (!socks_negotiate(sk)) { 
    352351                        eXosip_freeaddrinfo(addrinfo); 
     
    375374                                if (mode & SOCKST_UDPMASK) { 
    376375                                        sk->pbuf = osip_malloc(SIP_MESSAGE_MAX_LENGTH); 
    377                                         if (sk->pbuf) { 
     376                                        if (!sk->pbuf) { 
    378377                                                closesocket(sk->socket); 
    379378                                                return 0; 
     
    852851                        return -1; 
    853852                memcpy(pfx+1, message, length); 
     853                pfx->len = htonl(length); 
    854854                length += sizeof(*pfx); 
    855855                osip_free(message); 
  • libeXosip2/src/jcallback.c

    r268 r416  
    193193 
    194194        i = -1; 
    195         if (osip_strcasecmp(via->protocol, "udp") == 0) { 
     195        if (eXosip.eXtl) { 
     196                i = eXosip.eXtl->tl_send_message(tr, sip, host, port, out_socket); 
     197        } 
     198        else if (osip_strcasecmp(via->protocol, "udp") == 0) { 
    196199                i = eXtl_udp.tl_send_message(tr, sip, host, port, out_socket); 
    197200        } else if (osip_strcasecmp(via->protocol, "tcp") == 0) { 
  • phapi/phapi.c

    r415 r416  
    290290                eos++; 
    291291 
    292         while(*uri && !isspace(*uri)) 
     292        while(*uri && isspace(*uri)) 
    293293                uri++; 
    294294 
    295295 
    296         copyfield(tun->tunnel_proto,  uri, addr-1, sizeof(tun->tunnel_proto)-1); 
     296        copyfield(tun->tunnel_proto,  uri, addr, sizeof(tun->tunnel_proto)-1); 
    297297        copyfield(tun->tunnel_server,  addr+3, port, sizeof(tun->tunnel_server)-1); 
    298298        copyfield(tun->tunnel_port,  port+1, eos, sizeof(tun->tunnel_port)-1); 
     
    320320        } 
    321321 
    322         return tun - tinfo; 
     322        return i; 
    323323} 
    324324 
     
    42624262        } 
    42634263 
    4264         if (phcfg.use_tunnel & PH_TUNNEL_USE) { 
    4265                 tun = ph_select_tunnel(sip_tunnel_set, TUNNEL_MAX); 
    4266                 if (tun) 
    4267                         eXosip_set_tunnel(tun->tunnel_proto, tun->tunnel_server, tun->tunnel_port);; 
    4268         } 
     4264        return 0; 
    42694265#endif 
    42704266 
     
    47284724        if (i) 
    47294725                return -1; 
     4726 
     4727        if (phcfg.use_tunnel & PH_TUNNEL_USE) { 
     4728                struct tunnel_info *tun; 
     4729 
     4730                tun = ph_select_tunnel(sip_tunnel_set, sip_tunnel_count); 
     4731                if (tun) 
     4732                        eXosip_set_tunnel(tun->tunnel_proto, tun->tunnel_server, tun->tunnel_port);; 
     4733        } 
     4734 
    47304735         
    47314736        ph_nat_init(); 
     
    47394744        } 
    47404745 
    4741         i = phListenAddr(atoi(phcfg.sipport)); 
    4742         if(i) 
    4743                 return -1; 
     4746        if (!(phcfg.use_tunnel & PH_TUNNEL_USE)) { 
     4747                i = phListenAddr(atoi(phcfg.sipport)); 
     4748                if(i) 
     4749                        return -1; 
     4750        } 
    47444751 
    47454752        { 
Note: See TracChangeset for help on using the changeset viewer.