# ----------- global configuration parameters
------------------------
debug=3 #
debug level (cmd line:
-dddddddddd)
fork=yes
log_stderror=yes # (cmd line:
-E)
check_via=no # (cmd. line:
-v)
dns=no # (cmd.
line: -r)
rev_dns=no # (cmd. line:
-R)
port=5060
children=4
fifo="/tmp/openser_fifo"
# ------------------ module loading
----------------------------------
mpath="/usr/local/lib/openser/modules/"
loadmodule "sl.so"
loadmodule
"tm.so"
loadmodule "rr.so"
loadmodule "maxfwd.so"
loadmodule
"usrloc.so"
loadmodule "registrar.so"
loadmodule
"textops.so"
loadmodule "mysql.so"
loadmodule "domain.so"
loadmodule
"mediaproxy.so"
# mediaproxy
modparam("mediaproxy", "mediaproxy_socket",
"/var/run/proxydispatcher.sock")
modparam("mediaproxy", "natping_interval",
20)
# registrar
modparam("registrar", "nat_flag",
6)
modparam("registrar", "default_expires", 60)
modparam("registrar",
"min_expires", 30)
modparam("registrar", "use_domain", 1)
modparam("usrloc", "use_domain", 1)
modparam("usrloc",
"db_mode", 0)
modparam("rr", "enable_full_lr", 1)
# ------------------------- request routing logic
-------------------
# main routing logic
route {
if (!mf_process_maxfwd_header("10"))
{
sl_send_reply("483", "Demasiados
Saltos");
};
if (msg:len >= 2048 )
{
sl_send_reply("513", "Message too
big");
return;
};
if
(method==INVITE) {
if (client_nat_test("3"))
{
setflag(6);
use_media_proxy();
route(1);
return;
}
};
if
(method==BYE || method==CANCEL)
{
end_media_session();
};
if
(method==REGISTER)
{
route(2);
return;
};
if
(method==INVITE)
{
route(3);
return;
}
if
(!t_relay()) {
sl_reply_error();
};
}
# TODOS
route[1] {
t_on_reply("1");
if (!t_relay())
{
if (method==INVITE || method==ACK)
{
end_media_session();
};
sl_reply_error();
};
}
# REGISTER
route[2] {
if (client_nat_test("3")) {
log(1, "Se
registro un cliente
NAT");
setflag(6);
fix_contact();
force_rport();
};
sl_send_reply("100",
"Trying");
if (!save("location"))
{
sl_reply_error();
};
}
# INVITE
route[3] {
if (client_nat_test("3"))
{
setflag(7);
force_rport();
fix_contact();
}
if
(!lookup("location")) {
sl_send_reply("404", "No se encuentra el
destino.");
return;
}
if
(isflagset(6) ||isflagset(7))
{
use_media_proxy();
}
route(1);
}
onreply_route[1] {
if ((isflagset(6) || isflagset(7)) &&
(status=~"(180)|(183)|2[0-9][0-9]"))
{
use_media_proxy();
}
if
(client_nat_test("1")) {
fix_contact();
}
}
----------------------------------------------------------------------------------------------------------------------
File: mediaproxy.ini
;
; Configuration file for MediaProxy
;
[Dispatcher]
;
; Section for configuring the proxy
dispatcher
;
; The following options are available here:
;
;
start Boolean value that
specifies if to start the
dispatcher.
;
Default value: Yes
;
; socket
Path to the UNIX socket where the dispatcher receives
commands
;
from SER. This should match the value for mediaproxy_socket
in
;
openser.cfg. Use the keyword None to disable listening on
a
;
local
socket.
;
Default value: /var/run/proxydispatcher.sock
;
;
listen Network address where the
dispatcher receives commands
from
;
a remote Mediaproxy to close sessions for which media
did
;
timeout.
;
Valid values for this
are:
;
;
-
Default
;
when using this keyword it will listen on
0.0.0.0:25061
;
-
address[:port]
;
listen on the specified address and
port
;
address can be an IP a hostname or the keyword Any
;
(in which case it will listen on 0.0.0.0). If address
is
;
a hostname, that should map in DNS to an IP
address
;
present on the machine, through an A
record.
;
If port is missing assume
25061.
;
;
Default value: Default
;
;
group Put the socket in this
group and make it group
writable.
;
Default value: openser
;
; defaultProxy Default mediaproxy to use in
case the From/To
domains
;
involved in the call don't define
any.
;
Valid values for this
are:
;
;
-
None
;
don't use any default proxies. domains
without
;
mediaproxy SRV records won't
work
;
-
/path/to/unix/socket
;
use a single MediaProxy server identified by the
given
;
UNIX socket
path
;
-
IP_or_hostname[:port]
;
use a single MediaProxy server identified by its
network
;
address. The network address consists of an IP
address
;
or a hostname and an optional port number separated
by
;
a double colon. If port is missing 25060 will be
assumed.
;
Examples:
;
10.0.0.1 (connect to 10.0.0.1 on port
25060)
;
10.0.0.1:90 (connect to 10.0.0.1 on port
90)
;
mp1.mydomain.com
;
mp1.mydomain.com:7000
;
-
domain://domain_name
;
Use all MediaProxies defined by domain_name,
honoring
;
their priority and weight to create a cluster of
proxies
;
with fallback and load balancing
capabilities.
;
;
Default value:
/var/run/mediaproxy.sock
;
start = yes
socket = /var/run/proxydispatcher.sock
group =
openser
defaultProxy = /var/run/mediaproxy.sock
[MediaProxy]
;
; Section for configuring the MediaProxy
server
;
; The following options are available here:
;
;
start Boolean value that
specifies if to start the RTP proxy
server.
;
Default value: Yes
;
; socket
Path to the UNIX socket where MediaProxy receives
commands
;
from the dispatcher or SER. Use the keyword None to
disable
;
listening on a local
socket.
;
Default value: /var/run/mediaproxy.sock
;
;
group Put the socket in this
group and make it group
writable.
;
Default value: openser
;
;
listen Network address where
MediaProxy receives commands
from
;
a remote
dispatcher.
;
Valid values for this
are:
;
;
-
None
;
don't listen for network connections at
all
;
-
address[:port]
;
listen on the specified address and
port
;
address can be an IP a hostname or the keyword Any
;
(in which case it will listen on 0.0.0.0). If address
is
;
a hostname, that should map in DNS to an IP
address
;
present on the machine, through an A
record.
;
If port is missing assume
25060.
;
;
Default value: None
;
;
allow List of addresses that are
allowed to connect to
this
;
MediaProxy server and send
commands.
;
They are specified as a comma separated list of entries,
with
;
each entry being specified in the CIDR network/mask
notation
;
(ex.
10.0.0.0/8)
;
;
In addition simple IP addresses or hostnames are allowed,
in
;
which case the mask is considered to be
32.
;
;
In addition to network ranges/addresses 2 keywords can be
used
;
for this
option:
;
None to specify that none is allowed to connect (not
very
;
useful but this is the default for security
reasons)
;
Any to specify that anyone is allowed to
connect
;
(dangerous!)
;
;
Example: allow = 10.0.0.0/24, home-pc.mydomain.com,
1.2.3.4
;
;
Default value:
None
;
; proxyIP IP address to use to talk to
the phones. If not specified,
the
;
first found will be used. However first found usually
means
;
first defined in /etc/hosts which may not be what you
want.
;
If you find that the address that's automatically selected
is
;
not the one you want, you can specify the right one using
this
;
option. The address must be one that's present on one of
the
;
host's interfaces.
;
; portRange The range of
ports to use for proxying the rtp
streams.
;
This option is specified as minport:maxport with minport
and
;
maxport being even numbers in the range
1024-65536
;
Default value: 60000:65000
;
;
TOS Mark all
forwarded RTP packets with this specific TOS
value.
;
Unless you know what TOS means, leave this option
alone.
;
The TOS value can be specified either as a decimal number
or
;
as a hex number in the 0xnn
format.
;
Default value: 0xb8
;
; idleTimeout Expire idle sessions after
this much
time.
;
Default 60 seconds
;
; holdTimeout Expire calls on hold after
this much
time.
;
Default value is 3600 seconds
;
; forceClose Forcibly
close a RTP session after this many seconds even
if
;
it's still active. If forceClose is 0, then a session is
never
;
closed no matter how long it
lasts.
;
Default value: 0
;
start = yes
socket =
/var/run/mediaproxy.sock
group = openser
listen = None
allow =
None
proxyIP = 216.55.240.84
portRange = 60000:65000
TOS =
0xb8
idleTimeout = 60
holdTimeout = 3600
forceClose = 0
accounting =
off
[Accounting]
dbaccounting = off
[Database]
user = dbuser
password = dbpass
host =
dbhost
database = radius
table = radacct