You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kamailio/modules_s/mangler/mangler.cfg

107 lines
2.5 KiB

#
# $Id$
#
# simple quick-start config script
#
# WARNING: replace PUBLIC_IP with the public ip of the nat box
# (e.g.: 213.34.65.56 )
# ----------- global configuration parameters ------------------------
#debug=3 # debug level (cmd line: -dddddddddd)
#fork=no
#log_stderror=yes
check_via=no # (cmd. line: -v)
dns=no # (cmd. line: -r)
rev_dns=no # (cmd. line: -R)
#port=5060
#children=4
fifo="/tmp/ser_fifo"
mhomed=yes
disable_tls=yes
# ------------------ module loading ----------------------------------
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"
/* for the search() export */
loadmodule "modules/textops/textops.so"
loadmodule "modules/mangler/mangler.so"
# Uncomment this if you want digest authentication
# mysql.so must be loaded !
#loadmodule "/usr/lib/ser/modules/auth.so"
# ----------------- setting module-specific parameters ---------------
# seting separator for encoded contact
modparam("mangler","contact_flds_separator","*")
# -- usrloc params --
#modparam("usrloc", "db_mode", 0)
# ------------------------- 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 ( msg:len > max_len ) {
sl_send_reply("513", "Message too big");
break;
};
record_route();
/* replace PUBLIC_IP with the public ip of the nat box
(e.g.: 213.34.65.56 )*/
/* outgoing connection */
if (src_ip == 10.0.0.0/8 || src_ip == 192.168.0.0/16 ){
/* we mangle the contact address and ports in SDP part of the
* message */
if (method == "INVITE"){
sdp_mangle_ip("0.0.0.0/0","PUBLIC_IP");
/* diferent mangling based on what phone we use */
if (src_ip==10.0.0.1) sdp_mangle_port("+1000");
if (src_ip==10.0.0.2) sdp_mangle_port("-1000");
};
if (search("Contact: .*@(10\.|111\.)")){
/* we seem to have a private address on a Contact which is not
* valid */
encode_contact("enc_prefix","PUBLIC_IP");
};
/*
#if ser is behind a NAT and NAT box has port forwarding
#on port 5060 set to our ser private address ...
record_route(PUBLIC_IP);
*/
};
/* we received something for a local phone */
if (uri=~"enc_prefix*"){
decode_contact();
};
# forward to current uri now
forward(uri:host, uri:port);
break;
}