1#
2# $Id$
3#
4# demo script showing how to set-up usrloc replication
5#
6
7# ----------- global configuration parameters ------------------------
8
9debug=3          # debug level (cmd line: -dddddddddd)
10fork=no
11log_stderror=yes # (cmd line: -E)
12
13# ------------------ module loading ----------------------------------
14
15#set module path
16mpath="/usr/local/lib/kamailio/modules/"
17
18loadmodule "db_mysql.so"
19loadmodule "sl.so"
20loadmodule "tm.so"
21loadmodule "maxfwd.so"
22loadmodule "usrloc.so"
23loadmodule "registrar.so"
24loadmodule "auth.so"
25loadmodule "auth_db.so"
26
27# ----------------- setting module-specific parameters ---------------
28
29# digest generation secret; use the same in backup server;
30# also, make sure that the backup server has sync'ed time
31modparam("auth", "secret", "alsdkhglaksdhfkloiwr")
32
33# -------------------------  request routing logic -------------------
34
35# main routing logic
36
37route{
38
39	# initial sanity checks -- messages with
40	# max_forwars==0, or excessively long requests
41	if (!mf_process_maxfwd_header("10")) {
42		sl_send_reply("483","Too Many Hops");
43		exit;
44	};
45	if (msg:len >=  2048 ) {
46		sl_send_reply("513", "Message too big");
47		exit;
48	};
49
50	# if the request is for other domain use UsrLoc
51	# (in case, it does not work, use the following command
52	# with proper names and addresses in it)
53	if (uri==myself) {
54
55		if (method=="REGISTER") {
56
57			# verify credentials
58			if (!www_authorize("foo.bar", "subscriber")) {
59				www_challenge("foo.bar", "0");
60				exit;
61			};
62
63			# if ok, update contacts and ...
64			save("location");
65			# ... if this REGISTER is not a replica from our
66			# peer server, replicate to the peer server
67			if (!src_ip==backup.foo.bar) {
68				t_replicate("sip:backup.foo.bar:5060");
69			};
70			exit;
71		};
72		# do whatever else appropriate for your domain
73		log("non-REGISTER\n");
74	};
75}
76
77