فهرست منبع

initial version committed

Jiri Kuthan 22 سال پیش
والد
کامیت
e94baa72a5
1فایلهای تغییر یافته به همراه116 افزوده شده و 0 حذف شده
  1. 116 0
      examples/welcome.cfg

+ 116 - 0
examples/welcome.cfg

@@ -0,0 +1,116 @@
+#
+# $Id$
+#
+# welcome message for new subscribers; based on exec
+#
+
+# ----------- global configuration parameters ------------------------
+
+debug=3          # debug level (cmd line: -dddddddddd)
+# must be yes since REGISTER processing causes an INVITE to be sent,
+# which needs to be processed by another process
+fork=yes
+children=4
+
+# debugging
+log_stderror=yes # (cmd line: -E)
+
+mhomed=yes
+listen=192.168.2.16
+
+fifo="/tmp/ser_fifo"
+
+# ------------------ module loading ----------------------------------
+
+# Uncomment this if you want to use SQL database
+loadmodule "modules/mysql/mysql.so"
+
+loadmodule "modules/sl/sl.so"
+loadmodule "modules/tm/tm.so"
+loadmodule "modules/rr/rr.so"
+loadmodule "modules/maxfwd/maxfwd.so"
+loadmodule "modules/usrloc/usrloc.so"
+loadmodule "modules/registrar/registrar.so"
+
+loadmodule "modules/exec/exec.so"
+
+# ----------------- setting module-specific parameters ---------------
+
+# -- usrloc params --
+
+modparam("usrloc", "db_mode",   2)
+modparam("usrloc", "db_url", "sql://ser:[email protected]/ser" )
+# -------------------------  request routing logic -------------------
+
+# main routing logic
+
+route{
+
+	# initial sanity checks -- messages with
+	# max_forwards==0, or excessively long requests
+	if (!mf_process_maxfwd_header("10")) {
+		sl_send_reply("483","Too Many Hops");
+		break;
+	};
+	if (len_gt( max_len )) {
+		sl_send_reply("513", "Message too big");
+		break;
+	};
+
+	# 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();	# 1=loose routing
+
+	# loose-route processing
+	if (loose_route()) {
+		t_relay();
+		break;
+	};
+
+	log(1, "RR processing completed\n");
+
+	# if the request is for other domain use UsrLoc
+	# (in case, it does not work, use the following command
+	# with proper names and addresses in it)
+	if (uri==myself) {
+
+		if (method=="REGISTER") {
+			save("location");
+			if (!exec_msg('
+				# config: 
+				# --announcement server
+				ANS="sip:[email protected]"
+				# --SIP domain
+				DOMAIN="192.168.2.16"
+				# ----
+				# check if first time ...
+				SIP_UID=`echo $SIP_HF_TO | sed -e "s/^.*sip:\([a-zA-Z0-9_\.]*\)@.*$/\1/g"`
+				QUERY="select flag from subscriber 
+						where username=\"$SIP_UID\";
+					update subscriber set flag=\"x\" 
+						where username=\"$SIP_UID\" ";
+				mysql -Bsuser -pheslo -e "$QUERY" ser| grep "^x$" > /dev/null
+				# ... if so, c-t-d to announcement server
+				if [ "$?" -ne 0 ] ; then
+					# flag was not set to x yet -- first-time registration;
+					# initiate a call from telephone of the user to an announcement server
+					${HOME}/sip_router/examples/ctd.sh "sip:$SIP_UID@$DOMAIN" "$ANS" > /dev/null 2>&1
+				fi
+			')) {
+				sl_send_reply("500", "register/exec failed");
+				break;
+			};
+
+			break;
+		};
+
+		# native SIP destinations are handled using our USRLOC DB
+		if (!lookup("location")) {
+			sl_send_reply("404", "Not Found");
+			break;
+		};
+	};
+	t_relay();
+}