Changeset 5283


Ignore:
Timestamp:
May 9, 2016 6:58:29 AM (8 years ago)
Author:
riza
Message:

Fixed #1914: Ignore STUN error after pjstun_get_mapped_addr2().

Location:
pjproject/trunk/pjsip
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h

    r5273 r5283  
    15781578 
    15791579    /** 
    1580      * This specifies if the library startup should ignore failure with the 
     1580     * This specifies if the library should ignore failure with the 
    15811581     * STUN servers. If this is set to PJ_FALSE, the library will refuse to 
    15821582     * start if it fails to resolve or contact any of the STUN servers. 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c

    r5241 r5283  
    20532053        status = pjstun_get_mapped_addr2(&pjsua_var.cp.factory, &stun_opt, 
    20542054                                         1, &sock, &p_pub_addr->ipv4); 
    2055         if (status != PJ_SUCCESS) { 
     2055        if (status != PJ_SUCCESS && !pjsua_var.ua_cfg.stun_ignore_failure) { 
    20562056            pjsua_perror(THIS_FILE, "Error contacting STUN server", status); 
    20572057            pj_sock_close(sock); 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c

    r5282 r5283  
    391391#endif 
    392392            if (status != PJ_SUCCESS) { 
    393                 pjsua_perror(THIS_FILE, "STUN resolve error", status); 
    394                 goto on_error; 
     393                if (!pjsua_var.ua_cfg.stun_ignore_failure) { 
     394                    pjsua_perror(THIS_FILE, "STUN resolve error", status); 
     395                    goto on_error; 
     396                } 
     397 
     398                PJ_LOG(4,(THIS_FILE, "Ignoring STUN resolve error %d",  
     399                          status)); 
     400 
     401                if (!pj_sockaddr_has_addr(&bound_addr)) { 
     402                    pj_sockaddr addr; 
     403 
     404                    /* Get local IP address. */ 
     405                    status = pj_gethostip(af, &addr); 
     406                    if (status != PJ_SUCCESS) 
     407                        goto on_error; 
     408 
     409                    pj_sockaddr_copy_addr(&bound_addr, &addr); 
     410                } 
     411 
     412                for (i=0; i<2; ++i) { 
     413                    pj_sockaddr_init(af, &mapped_addr[i], NULL, 0); 
     414                    pj_sockaddr_copy_addr(&mapped_addr[i], &bound_addr); 
     415                    pj_sockaddr_set_port(&mapped_addr[i], 
     416                                         (pj_uint16_t)(acc->next_rtp_port+i)); 
     417                } 
     418                break; 
    395419            } 
    396420 
Note: See TracChangeset for help on using the changeset viewer.