[Serusers] Here Is A Complete ser.cfg Example File

Java Rockx javarockx at yahoo.com
Fri Dec 3 19:46:30 CET 2004


Aj,

Here is the complete ser.cfg file that I posted a one November 20th. I've done this inline text so
the attachment doesn't get deleted -- for the benefit of others of course.

Regards,
Paul

# ------------- Initial global variables

debug=3
fork=yes
log_stderror=no

listen=67.93.12.18  # put your real IP here
port=5060
alias=sip.mycompany.com

children=4
server_signature=yes
dns=no
rev_dns=no
check_via=no
syn_branch=yes
memlog=1000
sip_warning=yes
reply_to_via=no
uid="nobody"
gid="nobody"
mhomed=0
fifo_mode=0666
fifo="/tmp/ser_fifo"
fifo_db_url="mysql://ser:heslo@localhost/ser"


# ------------- external module loading
loadmodule "/usr/local/lib/ser/modules/mysql.so"
loadmodule "/usr/local/lib/ser/modules/sl.so"
loadmodule "/usr/local/lib/ser/modules/tm.so"
loadmodule "/usr/local/lib/ser/modules/rr.so"
loadmodule "/usr/local/lib/ser/modules/maxfwd.so"
loadmodule "/usr/local/lib/ser/modules/usrloc.so"
loadmodule "/usr/local/lib/ser/modules/registrar.so"
loadmodule "/usr/local/lib/ser/modules/auth.so"
loadmodule "/usr/local/lib/ser/modules/auth_db.so"
loadmodule "/usr/local/lib/ser/modules/acc.so"
loadmodule "/usr/local/lib/ser/modules/exec.so"
loadmodule "/usr/local/lib/ser/modules/group.so"
loadmodule "/usr/local/lib/ser/modules/print.so"
loadmodule "/usr/local/lib/ser/modules/textops.so"
loadmodule "/usr/local/lib/ser/modules/nathelper.so"
loadmodule "/usr/local/lib/ser/modules/uri.so"
loadmodule "/usr/local/lib/ser/modules/uri_db.so"
loadmodule "/usr/local/lib/ser/modules/domain.so"
loadmodule "/usr/local/lib/ser/modules/xlog.so"
loadmodule "/usr/local/lib/ser/modules/speeddial.so"
loadmodule "/usr/local/lib/ser/modules/options.so"

# ------------- db_url setting
modparam("acc|auth_db|domain|group|speeddial|uri_db|usrloc", 
         "db_url", "mysql://ser:heslo@localhost/ser")

# ------------- use_domain setting
modparam("auth_db|group|speeddial|uri_db|usrloc", "use_domain", 1)

# ------------- accounting parameters
modparam("acc", "db_flag", 1)
modparam("acc", "db_missed_flag", 1)
modparam("acc", "log_fmt", "cdfimorstup")
modparam("acc", "log_level", 1)
modparam("acc", "failed_transactions", 1)
modparam("acc", "report_cancels", 1)
modparam("acc", "report_ack", 0)

# ------------- auth parameters
# allows clear text passwords in the mysql database
modparam("auth_db", "calculate_ha1", yes)
modparam("auth_db", "password_column", "password")

# ------------- domain parameters
modparam("domain", "db_mode", 1)

# ------------- exec parameters
modparam("exec", "setvars", 1)
modparam("exec", "time_to_kill", 10)

# ------------- registration parameters
modparam("registrar", "nat_flag", 2)
modparam("registrar", "min_expires", 60)
modparam("registrar", "max_expires", 86400)
modparam("registrar", "default_expires", 3600)
modparam("registrar", "desc_time_order", 1)
modparam("registrar", "append_branches", 1)

#-------------- nathelper parameters
modparam("nathelper", "natping_interval", 30)
modparam("nathelper", "ping_nated_only", 1)

# ------------- rr parameters
# set ";lr" tag to lr=true
modparam("rr", "enable_full_lr", 1)

# ------------- tm parameters
modparam("tm", "fr_timer", 20)
modparam("tm", "fr_inv_timer", 40)
modparam("tm", "wt_timer", 5)

# ------------- usrloc parameters
# 0 = disable
# 1 = write-through
# 2 = write-back
modparam("usrloc", "db_mode", 2)
modparam("usrloc", "timer_interval", 60)
modparam("usrloc", "desc_time_order", 1)

# ------------- logging parameters
modparam("xlog", "buf_size", 8192)

route {

	# ------------------------------------------------------------------------
	# Sanity Check Section
	# ------------------------------------------------------------------------
	if (!mf_process_maxfwd_header("10")) {
		sl_send_reply("483", "Too Many Hops");
		break;
	};

	if (msg:len > max_len) {
		sl_send_reply("513", "Message Overflow");
		break;
	};

	# ------------------------------------------------------------------------
	# OPTIONS Section
	#
	# This is used by sipsak to monitor the health of our sip proxy
	# ------------------------------------------------------------------------
	if (search("^From: sip:sipsak@") && 
           (method=="OPTIONS") && (!uri=~"sip:.*[@]+.*")) {
		options_reply();
		break;
	};

	# ------------------------------------------------------------------------
	# NAT Test Section
	# ------------------------------------------------------------------------
	if (nat_uac_test("3")) {

		if (method=="REGISTER" || (!search("^Record-Route:"))) {

			fix_nated_contact();

			if (method=="REGISTER") {
				fix_nated_register();
			} else if (method=="INVITE") {
				fix_nated_sdp("1");
			};

                	force_rport();
			setflag(2);
		};
	};

	# ------------------------------------------------------------------------
	# Registration Section
	# ------------------------------------------------------------------------
	if (method=="REGISTER") {

		if (!is_from_local()) {

			sl_send_reply("403", "Unknown Domain");
			break;
		};

		if (is_user_in("Request-URI", "disabled")) {

			sl_send_reply("403", "Your evaluation period has expired");
			break;
		};

		if (!www_authorize("", "subscriber")) {

			www_challenge("", "0");
			break;
		};

		if (!check_to()) {

			sl_send_reply("401", "Unauthorized");
			break;
		};

		if (!save("location")) {

			sl_reply_error();
		};

		break;

	};

	# ------------------------------------------------------------------------
	# Open Relay Section
	# ------------------------------------------------------------------------
	if (method=="INVITE") {

		if (!(is_from_local() || is_uri_host_local())) {
			sl_send_reply("403", "Please register to use our service");
			break;
		};
	};

	# ------------------------------------------------------------------------
	# Accounting Section
	# ------------------------------------------------------------------------
	if (method=="INVITE" || method=="BYE") {
		setflag(1);
	};

	# ------------------------------------------------------------------------
	# Record Route Section
	#
	# we record-route all messages -- to make sure that subsequent messages
	# will go through our proxy; that's particularly good if upstream and
	# downstream entities use different transport protocol
	# ------------------------------------------------------------------------
	if (method=="INVITE") record_route();

	# ------------------------------------------------------------------------
	# Loose Route Section
	#
	# Grant route routing if route headers present
	# ------------------------------------------------------------------------
	if (loose_route()) {
		route(2);
		break;
	};

	# ------------------------------------------------------------------------
	# PSTN Section
	#
	# this is necessary so that calls coming from the PSTN 
	# gateway are honored in the mycompany.com realm
	# ------------------------------------------------------------------------
	if (src_ip==110.50.60.70) {

		rewritehost("sip.mycompany.com");
	};

	if (!(src_ip==110.50.60.70) && (uri=~"^sip:1[0-9]{10}@")) {

		# If the number dialed is 1+ ten digits then we need to
		# determine if the ten-digit number is in our location
		# database or not. If it is then we strip off the one
		# and dial it as a normal extension, otherwise we put
		# the 1+ back on the dialed number and let it go out the
		# PSTN gateway


		strip(1);
		if (lookup("location")) {

			rewritehost("sip.mycompany.com");

		} else {

			prefix("1");
			route(3);
			break;
		};

	} else if (uri=~"^sip:911 at .*") {

		route(3);
		break;
	};

	# ------------------------------------------------------------------------
	# Alias Routing Section
	# ------------------------------------------------------------------------
	lookup("aliases");
	if (!uri==myself) {
		route(2);
		break;
	};

	# ----------------------------------------------------------------
	# Speed Dialing Section
	# ----------------------------------------------------------------
	if ((method=="INVITE") && (uri=~"^sip:[0-9]{2}@.*")) {
		sd_lookup("speed_dial");
	};

	# ----------------------------------------------------------------
	# Call Routing Section
	# ----------------------------------------------------------------
	if (!lookup("location")) {

		sl_send_reply("404", "User Not Found");
		break;
	};

	route(2);
}

route [1] {
	# this route is used only for debugging
	xlog("L_ERR", "%mb");
}

route [2] {

	if (uri=~"[@:](192\.168\.|10\.|172\.(1[6-9]|2[0-9]|3[0-1])\.)" && !search("^Route:")){
        	sl_send_reply("479", "We don't forward to private IP addresses");
	        break;
	};

	if (isflagset(2)) {
		force_rtp_proxy();
	};

	t_on_reply("1");

	if (!t_relay()) {
		sl_reply_error();
	};
}

route[3] {

	# send out emergency calls to pstn gateway immediately
	if (uri=~"^sip:911 at .*") {
		rewritehost("110.50.60.70");
		forward(uri:host, uri:port);
		break;
	};

	if (!(src_ip==67.93.12.18) | (method=="ACK") | (method=="CANCEL") | (method=="BYE")) {

		if (!proxy_authorize("", "subscriber")) {

			proxy_challenge("", "0");
			break;

		} else if ((method=="INVITE") & !check_from()) {

			log(1, "Spoofed PSTN call attempt");
			sl_send_reply("403", "Use From=ID");
			break;
		};
	};


	rewritehost("110.50.60.70");
	strip(1);

	route(2);
}

onreply_route[1] {

	if (isflagset(2) && status =~ "(180)|(183)|2[0-9][0-9]") {

		fix_nated_contact();

		# Not all 2xx messages have a content body so here we
		# make sure our Content-Length > 0 to avoide a parse error
		if (!search("^Content-Length:\ 0")) {
			force_rtp_proxy();
		};

	} else if (nat_uac_test("1")) {

		fix_nated_contact();
	};
} 



		
__________________________________ 
Do you Yahoo!? 
All your favorites on one personal page – Try My Yahoo!
http://my.yahoo.com 




More information about the sr-users mailing list