Ignore:
Timestamp:
Aug 12, 2009 11:03:23 AM (15 years ago)
Author:
bennylp
Message:

Ticket #866: Allow application to specify more than one STUN servers for more robustness, and continue application startup if STUN resolution fails

PJSUA-LIB:

  • New fields in pjsua_config to specify more than one STUN servers (the stun_srv_cnt and stun_srv array)
  • The existing stun_host and stun_domain fields are deprecated, but backward compatibility is maintained. If stun_srv_cnt is zero, the library will import the entries from stun_host and stun_domain
  • The library will now resolve the STUN server entries one by one and test it before using it
  • New auxiliary API pjsua_resolve_stun_servers() to perform resolution and test against array of STUN servers

pjsua application:

  • The "stun-srv" command line options can now be specified more than once
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c

    r2862 r2864  
    191191    puts  ("  --publish           Send presence PUBLISH for this account"); 
    192192    puts  ("  --use-100rel        Require reliable provisional response (100rel)"); 
    193     puts  ("  --use-timer         Require session timers"); 
     193    puts  ("  --use-timer         Require SIP session timers"); 
    194194    puts  ("  --timer-se          Session timers expiration period, in secs (def:1800)"); 
    195195    puts  ("  --timer-min-se      Session timers minimum expiration period, in secs (def:90)"); 
     
    217217    puts  ("  --outbound=url      Set the URL of global outbound proxy server"); 
    218218    puts  ("                      May be specified multiple times"); 
    219     puts  ("  --stun-srv=name     Set STUN server host or domain"); 
     219    puts  ("  --stun-srv=FORMAT   Set STUN server host or domain. This option may be"); 
     220    puts  ("                      specified more than once. FORMAT is hostdom[:PORT]"); 
    220221    puts  (""); 
    221222    puts  ("TLS Options:"); 
     
    478479           OPT_BOUND_ADDR, OPT_CONTACT_PARAMS, OPT_CONTACT_URI_PARAMS, 
    479480           OPT_100REL, OPT_USE_IMS, OPT_REALM, OPT_USERNAME, OPT_PASSWORD, 
    480            OPT_NAMESERVER, OPT_STUN_DOMAIN, OPT_STUN_SRV, 
     481           OPT_NAMESERVER, OPT_STUN_SRV, 
    481482           OPT_ADD_BUDDY, OPT_OFFER_X_MS_MSG, OPT_NO_PRESENCE, 
    482483           OPT_AUTO_ANSWER, OPT_AUTO_PLAY, OPT_AUTO_PLAY_HANGUP, OPT_AUTO_LOOP, 
     
    544545        { "password",   1, 0, OPT_PASSWORD}, 
    545546        { "nameserver", 1, 0, OPT_NAMESERVER}, 
    546         { "stun-domain",1, 0, OPT_STUN_DOMAIN}, 
    547547        { "stun-srv",   1, 0, OPT_STUN_SRV}, 
    548548        { "add-buddy",  1, 0, OPT_ADD_BUDDY}, 
     
    960960            break; 
    961961 
    962         case OPT_STUN_DOMAIN:   /* STUN domain */ 
    963             cfg->cfg.stun_domain = pj_str(pj_optarg); 
    964             break; 
    965  
    966962        case OPT_STUN_SRV:   /* STUN server */ 
    967963            cfg->cfg.stun_host = pj_str(pj_optarg); 
     964            if (cfg->cfg.stun_srv_cnt==PJ_ARRAY_SIZE(cfg->cfg.stun_srv)) { 
     965                PJ_LOG(1,(THIS_FILE, "Error: too many STUN servers")); 
     966                return PJ_ETOOMANY; 
     967            } 
     968            cfg->cfg.stun_srv[cfg->cfg.stun_srv_cnt++] = pj_str(pj_optarg); 
    968969            break; 
    969970 
     
    16161617 
    16171618    /* STUN */ 
    1618     if (config->cfg.stun_domain.slen) { 
    1619         pj_ansi_sprintf(line, "--stun-domain %.*s\n", 
    1620                         (int)config->cfg.stun_domain.slen,  
    1621                         config->cfg.stun_domain.ptr); 
    1622         pj_strcat2(&cfg, line); 
    1623     } 
    1624     if (config->cfg.stun_host.slen) { 
     1619    for (i=0; i<config->cfg.stun_srv_cnt; ++i) { 
    16251620        pj_ansi_sprintf(line, "--stun-srv %.*s\n", 
    1626                         (int)config->cfg.stun_host.slen,  
    1627                         config->cfg.stun_host.ptr); 
     1621                        (int)config->cfg.stun_srv[i].slen,  
     1622                        config->cfg.stun_srv[i].ptr); 
    16281623        pj_strcat2(&cfg, line); 
    16291624    } 
Note: See TracChangeset for help on using the changeset viewer.