仅仅能实现用户注册

  • /usr/local/etc/kamailio/kamailio.cfg 文件

    #!KAMAILIO5.5.x
    debug=2
    
    /* 下面是宏定义,其中7443是加密端口 */
    #!substdef "!MY_IP_ADDR!172.28.78.102!g"    /* CUSTOMIZE ME 地址 */
    #!substdef "!MY_SIP_PORT!35060!g"            /* CUSTOMIZE ME 不加密的端口 */
    #!substdef "!MY_SIPS_PORT!443!g"           /* CUSTOMIZE ME 加密的端口 */
    #!substdef "!MY_DOMAIN!fs.dot2.com!g"      /* CUSTOMIZE ME 域名 */
    
    log_stderror=no                             /* 配置为no表示日志写到syslog */
    log_facility=LOG_LOCAL0
    tcp_accept_no_cl=yes                        /* 没有cl(content-length)头kamailio也接受,默认值是拒绝 */
    enable_tls=yes
    
    /* 配置监听的地址和端口 */
    listen=udp:MY_IP_ADDR:MY_SIP_PORT
    listen=tcp:MY_IP_ADDR:MY_SIP_PORT
    listen=tls:MY_IP_ADDR:MY_SIPS_PORT
    
    alias="MY_DOMAIN"
    force_rport=yes
    
    /* 模块路径 */
    # mpath="/usr/local/lib/kamailio/modules/"
    
    /* 加载模块 */
    loadmodule "xhttp.so"
    loadmodule "jsonrpcs.so"
    loadmodule "tm.so"
    loadmodule "sl.so"
    loadmodule "pv.so"
    loadmodule "usrloc.so"
    loadmodule "registrar.so"
    loadmodule "siputils.so"
    loadmodule "xlog.so"
    loadmodule "ctl.so"
    loadmodule "tls.so"
    loadmodule "websocket.so"
    
    modparam("jsonrpcs", "pretty_format", 1)
    modparam("jsonrpcs", "transport", 7)
    
    modparam("tm", "failure_reply_mode", 3)
    modparam("tm", "fr_timer", 30000)
    modparam("tm", "fr_inv_timer", 120000)
    
    modparam("registrar", "method_filtering", 1)
    modparam("registrar", "max_expires", 3600)
    
    modparam("usrloc", "use_domain", 0)
    modparam("usrloc", "db_mode", 0)
    
    /* 参考 https://github.com/kamailio/kamailio/blob/master/src/modules/tls/tls.cfg */
    modparam("tls", "config", "/usr/local/etc/kamailio/tls.cfg")
    
    /* 主路由入口 */
    request_route {
        xinfo("*** $sel(msg)\n");
        if ($rm == "REGISTER") {    /* 为了尽量简单,这里只处理注册请求 */
            save("location");
            exit;
        }
    
        sl_send_reply("404", "Not here");
        exit;
    }
    
    /* http请求的路由入口 */
    event_route[xhttp:request] {
        set_reply_close();
        set_reply_no_connect();
    
        $var(msg) = @msg;           /* 跟$sel(msg)等效, 参考kamailio的selects文档 */
        xinfo("*** $var(msg)\n");
        /* 处理http升级到websocket */
        if ($hdr(Upgrade) =~ "websocket" && $hdr(Connection) =~ "Upgrade" && $rm =~ "GET") {
            if (ws_handle_handshake()) { /* websocket 握手 */
                exit;
            }
        }
    
        xhttp_reply("404", "Not Found", "", "");
    }
    
  • /usr/local/etc/kamailio/tls.cfg 文件

    [server:default]
    method = TLSv1.2+
    verify_certificate = no
    require_certificate = no
    private_key = /usr/local/etc/kamailio/tls/xxx.key
    certificate = /usr/local/etc/kamailio/tls/xxx.pem
    
    [client:default]
    verify_certificate = yes
    require_certificate = yes