1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
# ----------- global configuration parameters ------------------------
fork=yes
port=5060
log_stderror=no
debug=3
alias=voip.anytun.org:5060
check_via=no # (cmd. line: -v)
dns=yes # (cmd. line: -r)
rev_dns=yes # (cmd. line: -R)
children=4
fifo="/tmp/openser_fifo"
fifo_db_url="mysql://anytunro:woasinidro@localhost/anytun"
# ------------------ module loading ----------------------------------
loadmodule "/usr/lib/openser/modules/mysql.so"
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/textops.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/auth.so"
loadmodule "/usr/lib/openser/modules/auth_db.so"
loadmodule "/usr/lib/openser/modules/uri_db.so"
loadmodule "/usr/lib/openser/modules/nathelper.so"
## ----------------- setting module-specific parameters ---------------
modparam("auth_db|uri_db", "db_url", "mysql://anytunro:woasinidro@localhost/anytun")
modparam("auth_db", "calculate_ha1", 1)
modparam("auth_db", "password_column", "password")
modparam("usrloc", "db_url", "mysql://anytun:woasinid@localhost/anytun")
modparam("usrloc", "db_mode", 2)
modparam("rr", "enable_full_lr", 1)
modparam("nathelper", "rtpproxy_sock", "udp:193.238.157.58:22222")
# ------------------------- request 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");
exit;
};
if (msg:len >= 2048 ) {
sl_send_reply("513", "Message too big");
exit;
};
# 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!="REGISTER")
record_route();
if (method=="BYE" || method=="CANCEL") {
unforce_rtp_proxy();
};
# subsequent messages withing a dialog should take the
# path determined by record-routing
if (loose_route()) {
route(4);
route(1);
};
if (!uri==myself) {
route(4);
route(1);
};
if (method=="ACK") {
route(1);
} if (method=="INVITE") {
route(3);
} else if (method=="REGISTER") {
route(2);
};
lookup("aliases");
if (uri!=myself) {
route(4);
route(1);
};
# native SIP destinations are handled using our USRLOC DB
if (!lookup("location")) {
sl_send_reply("404", "Not Found");
exit;
};
route(4);
route(1);
}
route[1] {
# send it out now; use stateful forwarding as it works reliably
# even for UDP2TCP
if (!t_relay()) {
sl_reply_error();
};
exit;
}
route[2] {
sl_send_reply("100", "Trying");
if (!www_authorize("","subscriber")) {
www_challenge("","0");
exit;
};
if (!check_to()) {
sl_send_reply("401", "Unauthorized");
exit;
};
consume_credentials();
if (!save("location")) {
sl_reply_error();
};
exit;
}
route[3] {
if (!proxy_authorize("","subscriber")) {
proxy_challenge("","0");
exit;
} else if (!check_from()) {
sl_send_reply("403", "Use From=ID");
exit;
};
consume_credentials();
lookup("aliases");
if (uri!=myself) {
route(4);
route(1);
};
if (!lookup("location")) {
sl_send_reply("404", "User Not Found");
exit;
};
route(4);
route(1);
}
route[4] {
if (method=="INVITE") {
force_rtp_proxy("","193.238.157.58");
};
}
onreply_route {
if (!search("^Content-Length:[ ]*0")) {
force_rtp_proxy("","193.238.157.58");
};
}
|