|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
要多google,因为我不可能,也不可以给你解答所有内容,我只能告诉你一些关键点,甚至我会故意隐瞒答案,因为在寻找答案的过程中。
opensips用户认证设置文件-opensips.cfgopensips.cfg设置文件,白色标志的为增加修正的部分,亲身测试!
#
#$Id:opensips.cfg97422013-02-0510:24:48Zvladut-paiu$
#
#OpenSIPSresidentialconfigurationscript
#byOpenSIPSSolutions<team@opensips-solutions.com>
#
#Thisscriptwasgeneratedvia"makemenuconfig",from
#the"Residential"scenario.
#Youcanenable/disablemorefeatures/functionalitiesby
#re-generatingthescenariowithdifferentoptions.#
#
#PleaserefertotheCoreCookBookat:
#http://www.opensips.org/Resources/DocsCookbooks
#foraexplanationofpossiblestatements,functionsandparameters.
#
#######GlobalParameters#########
debug=3
log_stderror=no
log_facility=LOG_LOCAL0
fork=yes
children=4
/*uncommentthefollowinglinestoenabledebugging*/
#debug=6
#fork=no
#log_stderror=yes
/*uncommentthenextlinetoenabletheautotemporaryblacklistingof
notavailabledestinations(defaultdisabled)*/
#disable_dns_blacklist=no
/*uncommentthenextlinetoenableIPv6lookupafterIPv4dns
lookupfailures(defaultdisabled)*/
#dns_try_ipv6=yes
/*commentthenextlinetoenabletheautodiscoveryoflocalaliases
basedonreversDNSonIPs*/
auto_aliases=no
#listen=udp:127.0.0.1:5060#CUSTOMIZEME
listen=udp:192.168.139.121:5060#CUSTOMIZEME
disable_tcp=yes
#disable_tls=yes
#######ModulesSection########
#setmodulepath
mpath="//lib/opensips/modules/"
####MySQL
loadmodule"db_mysql.so"
####SIGNALINGmodule
loadmodule"signaling.so"
####StateLessmodule
loadmodule"sl.so"
####TransactionModule
loadmodule"tm.so"
modparam("tm","fr_timer",5)
modparam("tm","fr_inv_timer",30)
modparam("tm","restart_fr_on_each_reply",0)
modparam("tm","onreply_avp_mode",1)
####RecordRouteModule
loadmodule"rr.so"
/*donotappendfromtagtotheRR(noneedforthisscript)*/
modparam("rr","append_fromtag",0)
####MAXForWarDmodule
loadmodule"maxfwd.so"
####SIPMSGOPerationSmodule
loadmodule"sipmsgops.so"
####FIFOManagementInterface
loadmodule"mi_fifo.so"
modparam("mi_fifo","fifo_name","/tmp/opensips_fifo")
modparam("mi_fifo","fifo_mode",0666)
####URImodule
loadmodule"uri.so"
modparam("uri","use_uri_table",0)
####USeRLOCationmodule
loadmodule"usrloc.so"
modparam("usrloc","nat_bflag","NAT")
modparam("usrloc","db_url","mysql://opensips:opensipsrw@localhost/opensips")
modparam("usrloc","db_mode",2)
####REGISTRARmodule
loadmodule"registrar.so"
modparam("registrar","tcp_persistent_flag","TCP_PERSISTENT")
/*uncommentthenextlinenottoallowmorethan10contactsperAOR*/
#modparam("registrar","max_contacts",10)
####ACCountingmodule
loadmodule"acc.so"
/*whatspecialeventsshouldbeaccounted?*/
modparam("acc","early_media",0)
modparam("acc","report_cancels",0)
/*bydefaultwedonotadjustthedirectofthesequentialrequests.
ifyouenablethisparameter,besuretheenable"append_fromtag"
in"rr"module*/
modparam("acc","detect_direction",0)
modparam("acc","failed_transaction_flag","ACC_FAILED")
/*accounttriggers(flags)*/
modparam("acc","log_flag","ACC_DO")
modparam("acc","log_missed_flag","ACC_MISSED")
####Authsupport
loadmodule"auth.so"
loadmodule"auth_db.so"
modparam("auth","calculate_ha1",yes)
modparam("auth_db","db_url","mysql://opensips:opensipsrw@localhost/opensips")
modparam("auth_db","password_column","password")
#######RoutingLogic########
#mainrequestroutinglogic
route{
if(!mf_process_maxfwd_header("10")){
sl_send_reply("483","TooManyHops");
exit;
}
if(has_totag()){
#sequentialrequestwithingadialogshould
#takethepathdeterminedbyrecord-routing
if(loose_route()){
if(is_method("BYE")){
setflag(ACC_DO);#doaccounting...
setflag(ACC_FAILED);#...evenifthetransactionfails
}elseif(is_method("INVITE")){
#evenifinmostofthecasesisuseless,doRRfor
#re-INVITEsalos,assomebuggyclientsdochangerouteset
#duringthedialog.
record_route();
}
#routeitouttowhateverdestinationwassetbyloose_route()
#in$du(destinationURI).
route(relay);
}else{
if(is_method("ACK")){
if(t_check_trans()){
#nonloose-route,butstatefulACK;mustbeanACKafter
#a487ore.g.404fromupstreamserver
t_relay();
exit;
}else{
#ACKwithoutmatchingtransaction->
#ignoreanddiscard
exit;
}
}
sl_send_reply("404","Nothere");
}
exit;
}
#CANCELprocessing
if(is_method("CANCEL"))
{
if(t_check_trans())
t_relay();
exit;
}
t_check_trans();
if(!(is_method("REGISTER"))){
if(from_uri==myself)
{
}else{
#ifcallerisnotlocal,thencallednumbermustbelocal
if(!uri==myself){
send_reply("403","Relyforbidden");
exit;
}
}
}
#preloadedroutechecking
if(loose_route()){
xlog("L_ERR",
"AttempttoroutewithpreloadedRoutes[$fu/$tu/$ru/$ci]");
if(!is_method("ACK"))
sl_send_reply("403","PreloadRoutedenied");
exit;
}
#recordrouting
if(!is_method("REGISTER|MESSAGE"))
record_route();
#accountonlyINVITEs
if(is_method("INVITE")){
setflag(ACC_DO);#doaccounting
}
if(!uri==myself){
append_hf("P-hint:outbound
");
route(relay);
}
#requestsformydomain
if(is_method("PUBLISH|SUBSCRIBE"))
{
sl_send_reply("503","ServiceUnavailable");
exit;
}
if(is_method("REGISTER"))
{
#authuserusingmysqlDB
if(!www_authorize("192.168.139.121","subscriber")){
www_challenge("192.168.139.121","0");
exit;
}
#endauthuser
if(0)setflag(TCP_PERSISTENT);
if(!save("location"))
sl_reply_error();
exit;
}
if($rU==NULL){
#requestwithnoUsernameinRURI
sl_send_reply("484","AddressIncomplete");
exit;
}
#dolookupwithmethodfiltering
if(!lookup("location","m")){
t_newtran();
t_reply("404","NotFound");
exit;
}
#whenroutingviausrloc,logthemissedcallsalso
setflag(ACC_MISSED);
route(relay);
}
route[relay]{
#forINVITEsenablesomeadditionalhelperroutes
if(is_method("INVITE")){
t_on_branch("per_branch_ops");
t_on_reply("handle_nat");
#t_on_reply();
t_on_failure("missed_call");
}
if(!t_relay()){
send_reply("500","InternalError");
};
exit;
}
branch_route[per_branch_ops]{
xlog("newbranchat$ru
");
}
onreply_route[handle_nat]{
xlog("incomingreply
");
}
failure_route[missed_call]{
if(t_was_cancelled()){
exit;
}
#uncommentthefollowinglinesifyouwanttoblockclient
#redirectbasedon3xxreplies.
##if(t_check_status("3[0-9][0-9]")){
##t_reply("404","Notfound");
##exit;
##}
}
linux系统的文件布置,etc/,opt/目录的内容等; |
|