- # log levels:
- # 1 warn
- # 2 notice
- # 3 info
- # 4 debug (default)
- # globals
- listen=udp:sip.example.com:5060
- fifo="/tmp/openser_fifo"
- # load modules
- loadmodule "/usr/lib/openser/modules/sl.so"
- loadmodule "/usr/lib/openser/modules/tm.so"
- loadmodule "/usr/lib/openser/modules/rr.so"
- loadmodule "/usr/lib/openser/modules/maxfwd.so"
- loadmodule "/usr/lib/openser/modules/usrloc.so"
- loadmodule "/usr/lib/openser/modules/registrar.so"
- loadmodule "/usr/lib/openser/modules/textops.so"
- loadmodule "/usr/lib/openser/modules/auth.so"
- loadmodule "/usr/lib/openser/modules/domain.so"
- loadmodule "/usr/lib/openser/modules/mediaproxy.so"
- loadmodule "/usr/lib/openser/modules/acc.so"
- loadmodule "/usr/lib/openser/modules/exec.so"
- loadmodule "/usr/lib/openser/modules/xlog.so"
- # module params
- # rr
- # add value to ;lr param to make some broken UAs happy
- modparam("rr", "enable_full_lr", 1)
- # mediaproxy
- #modparam("mediaproxy", "mediaproxy_socket", "/var/run/proxydispatcher.sock")
- #modparam("mediaproxy", "natping_interval", 60)
- modparam("registrar", "nat_flag", 2)
- # request routing logic
- alias="example.com"
- alias="voip.example.com"
- route
- {
- # sanity checks
- if (!mf_process_maxfwd_header("10"))
- {
- sl_send_reply("483","Too Many Hops");
- exit;
- }
- if (msg:len >= max_len)
- {
- sl_send_reply("513", "Message too big");
- exit;
- }
- # apply loose (normal) routing rules
- loose_route();
- # NAT test
- if (client_nat_test("3") && !search("^Route:"))
- {
- setflag(2); # flag for NAT
- force_rport();
- fix_contact();
- append_hf("P-hint: NAT\r\n");
- }
- # outbound routing if not for me
- lookup("aliases");
- if (uri != myself)
- {
- route(1);
- exit;
- }
- # Registration
- if (method == "REGISTER")
- {
- save("location"); # simple no-auth registration
- exit;
- }
- if (method == "INVITE")
- {
- # enable Record-Route
- record_route();
- # Is this to one of our numbers
- if (lookup("location"))
- {
- append_hf("P-hint: userloc applied\r\n");
- }
- else
- {
- sl_send_reply("404","Not found");
- }
- }
- route(1);
- }
- route[1]
- {
- if (isflagset(2))
- {
- if (method == "INVITE")
- {
- t_on_reply("1");
- t_on_failure("1");
- use_media_proxy();
- }
- else if (method == "BYE" || method == "CANCEL")
- {
- end_media_session();
- }
- }
- # send it out now; use stateful forwarding as it works reliably
- # even for UDP2TCP
- if (!t_relay())
- {
- sl_reply_error();
- }
- exit;
- }
- onreply_route[1]
- {
- if (status =~ "(183)|(2[0-9][0-9])")
- {
- if (client_nat_test("1"))
- {
- fix_contact();
- }
- use_media_proxy();
- }
- }
- failure_route[1]
- {
- end_media_session();
- }
- # The perl filetype works pretty well for this
- # vim: filetype=perl
0 comments: