kamailio 多慮擬域配置

kamailio 作爲強大的開源  sip服務器

根據環境需要配置 域隔離的配置   主要修改kamailio.cfg

#!define WITH_AUTH

#!define WITH_MULTIDOMAIN

#!ifdef WITH_MULTIDOMAIN

loadmodule "domain.so"

#!endif

定位到認證路由函數

# Authentication route

route[AUTH] {

#!ifdef WITH_AUTH

 

#!ifdef WITH_IPAUTH

        if((!is_method("REGISTER")) && allow_source_address())

        {

                # source IP allowed

                return;

        }

#!endif

        if (is_method("REGISTER") || from_uri==myself)

        {

                # authenticate requests

                if (!auth_check("$fd", "subscriber", "1")) {

                        auth_challenge("$fd", "0");

                        exit;

                }

                # user authenticated - remove auth header

                if(!is_method("REGISTER|PUBLIS"))

                        consume_credentials();

        }

 

        if (is_method("INVITE") && ($td!=$fd))

        {

                xlog("INVITE:-------------$td  $fd------\n");

                sl_send_reply("404","Not relaying");

                exit;

        }

        # if caller is not local subscriber, then check if it calls

        # a local destination, otherwise deny, not an open relay here

        if (from_uri!=myself && uri!=myself)

        {

                sl_send_reply("403","Not relaying");

                exit;

        }

#!endif

        return;

}

從僞變量表中可以查到

$td - To URI Domain

$td - reference to domain in URI of 'To' header

$fd - From URI domain

$fd - reference to domain in URI of 'From' header

上面配置文件的意思是對於認證的invite包,如果報文中的toDomainfromDomain不一樣則認爲是不在同一個域的用戶間相互拔打電話,這時回404,這樣就實現的簡單的域隔離功能



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章