Â
Karoo Configuration Samples
Sample 1
Topology
sip.cfg
// Some comments here listeners : { interfaces = ( { default = true; ip-address = "10.0.40.5"; external-address = "10.0.40.5"; tcp-enabled = false; sip-port = 5060; }, { ip-address = "192.168.2.2"; external-address = "192.168.2.2"; tcp-enabled = false; sip-port = 5060; } ); /**************************************************************************** * The default interface address used to send out requests if not explicitly* * set using the java script sendInterfaceAddress() function. This is also * * used by Karoo Bridge command line utilities like the --reset-log-level * * to send the SIP RPC request to the running Karoo Bridge instance. * ****************************************************************************/ default-interface-address = "10.0.40.5"; /**************************************************************************** * The default interface port used to send out requests if not explicitly * * set using the java script sendInterfacePort() function * ****************************************************************************/ default-interface-port = 5060; /**************************************************************************** * The low value marker for the TCP client port range * ****************************************************************************/ sip-tcp-port-base = 10000; /**************************************************************************** * The high value marker for the TCP client port range * ****************************************************************************/ sip-tcp-port-max = 15000; /**************************************************************************** * The low value marker for the RTP proxy port range * ****************************************************************************/ rtp-proxy-port-base = 30000; /**************************************************************************** * The high value marker for the RTP proxy port range * ****************************************************************************/ rtp-proxy-port-max = 60000; /**************************************************************************** * The read timeout for RTP Proxy before it decides to automatically * * tear down the RTP channel. This is expressed in seconds. * ****************************************************************************/ rtp-proxy-read-timeout = 600; /**************************************************************************** * The number of worker threads for the RTP proxy. Take note that Karoo * * Bridge uses async IO and the number here does not limit the number of RTP* * channels that can be supported. This threadpool will be shared equally * * by all RTP channels. 30 threads has been tested to be enough to cater * * to 1000 RTP proxy sessions * ****************************************************************************/ rtp-proxy-transport-thread-count = 30; /*************************************************************************** * Karoo has a built-in STUN server. STUN would only work if the server * * Karoo Bridge is installed in has two or more NICs directly routable from* * the WAN. The addresses must be different. Virtual IP is also ok but is* * not advised. If you don't want to use the default port you can include * * a port with the address separated with a colon. * * Example: stun-primary-ip = 10.0.40.5:3478 * ***************************************************************************/ stun-primary-ip = ""; stun-secondary-ip = ""; /*************************************************************************** * Karoo bridge uses libfreeswitch for sip trunking and transcoding * * functions. These values set the listener port for the internal event * * layer handler. Since freeswitch is configured independently, the sip * * address used by freeswitch must be made known to Karoo as well * ***************************************************************************/ switch-event-listener-port = 9000; switch-sip-listener-ip = "10.0.40.5"; switch-sip-listener-port = 5080; switch-sip-context = "sofia/karoo"; /**************************************************************************** * The packet rate ratio allows the transport to detect a potential DoS * * attack. It works by detecting the packet read rate per second as * * designated by the upper limit. If the value of packet rate is 50/100, * * the maximum packet rate before the SBC raises the alert level if a * * potential denial of service attack is 100 packets per second. * * When this happens, the transport layer checks if there is a particular * * IP that is sending more than its allowable rate of 50 packets per second.* * If the sender is violating the threshold, it will be banned for 1 hour * * which is the third parameter of 3600 seconds. * ****************************************************************************/ packet-rate-ratio = "50/100/3600"; /***************************************************************************** * One may statically define a list of known IP addresses or networks so that* * they get immunity against the packet-rate-ratio algorithm. This would * * normally contain the ip addresses of known traffic sources or destinations* * like the local iPBX or trunk gateways. For Call Centers with predictive * * or progressive dialers in the network, it would be wise to also white-list* * those applications. * *****************************************************************************/ packet-rate-white-list = ( /* {source-ip = "192.168.1.10";\}, */ {source-network = "1.1.1.1/4";\} \); \}; user-agent : \{ /**************************************************************************** * Show your appreciation by not changing this value * ****************************************************************************/ user-agent-name = "OSS Karoo Bridge"; /**************************************************************************** * Karoo bridge uses the contact header to store some states about sip * * session. It can either do thi by storing a unique id as the user info of* * the contact-uri or by storing it as a contact paramameter. If your * * switch/pbx supports paramaters in contact, setting the two parameters * * below to true is the recommended value. * ****************************************************************************/ register-state-in-contact-params=false; dialog-state-in-contact-params=true; \};
routs.js
function Route() { this.sendRegister( "user", "myitsp.com", "passwd", "proxy.myitsp.com", 1800, 0); this.sendRegister( "user2", "myitsp.com", "passwd2", "proxy.myitsp.com", 1800, 0); } Route.prototype = new RouteProfile(); Route.prototype.isRoutable = function() { if (is_mysipdomain_routable(this)) return true; else return false; }
mydomain.com.js
function is_mysipdomain_routable(profile) { var ifaceAddr = profile.sipMessage.getInterfaceAddress(); var ifacePort = profile.sipMessage.getInterfacePort(); var ds = profile.sipMessage.getRequestUriUser(); var domain = profile.sipMessage.getFromHost(); var ts = profile.sipMessage.getToUser(); if (is_my_pbx_routable(profile, ifaceAddr, ifacePort, ds, domain, ts)) return true; else if (is_my_sip_trunk_routable(profile, ifaceAddr, ifacePort, ds, domain)) return true; } function is_my_sip_trunk_routable(profile, ifaceAddr, ifacePort, ds, domain) { if (typeof ds != "string") return false; // // Check if the packet came in using the LAN interface // if ( ifaceAddr != sip_interface_address[1] || ifacePort != sip_interface_port[1]) return false; // // Route it to our ITSP // profile.setTargetDomain("myitsp.com"); profile.setTargetAddress("udp", "proxy.myitsp.com", "5060"); // // Use the WAN interface to send it out // profile.setInterfaceAddress(sip_interface_address[0], sip_interface_port[0]); // // Bridge it using our account // var pattern=/\b((\d\d\d)|((1)\d\d\d))?(\d{7})\b/; var pattern2=/\b9((\d\d\d)|((1)\d\d\d))?(\d{7})\b/; var pattern_ac=/\b(1?(\d\d\d))\b/; var pattern_am=/\b((\d\d\d)(\d\d\d)?)\b/; if ( pattern.test(ds) == true ) { profile.sipMessage.setRequestUriUser( "1" + (ds.replace(pattern, "$1").replace(pattern_ac, "$2") + "888").replace(pattern_am, "$2") + ds.replace(pattern, "$5") ); profile.sipMessage.setFromUser("user"); profile.bridge("user", "passwd"); } else if ( pattern2.test(ds) == true ) { profile.sipMessage.setRequestUriUser( "1" + (ds.replace(pattern2, "$1").replace(pattern_ac, "$2") + "888").replace(pattern_am, "$2") + ds.replace(pattern2, "$5") ); profile.sipMessage.setFromUser("user2"); profile.bridge("user2", "passwd2"); } else return false; return true; } function is_my_pbx_routable(profile, ifaceAddr, ifacePort, ds, domain, ts) { if (typeof domain != "string") return false; // // Check if the packet came in using the WAN interface // if ( ifaceAddr != sip_interface_address[0] || ifacePort != sip_interface_port[0]) return false; // // Check if the domain is valid // if (domain != "mydomain.com") return false; // // route it to our PBX // profile.setTargetDomain("mydomain.com"); profile.setTargetAddress("udp", "sipx.mydomain.com", "5060"); // // Use the LAN interface to send it out // profile.setInterfaceAddress(sip_interface_address[1], sip_interface_port[1]); // profile.setInterfaceAddress("192.168.2.2", "5060"); // // Check if the source address is the ITSP. If yes, bridge it // if (profile.sipMessage.getSourceAddress() == "10.0.168.10") { if (ts == "1XXXXXXX181") { profile.sipMessage.setRequestUriUser("501"); profile.bridge("501", "sipxpasswd"); } else if (ts == "1XXXXXXX139") { profile.sipMessage.setRequestUriUser("503"); profile.bridge("503", "sipxpasswd"); } else if (ts == "1XXXXXXXX07") { profile.sipMessage.setRequestUriUser("504"); profile.bridge("504", "sipxpasswd"); } else if (ts == "1XXXXXXXX82") { profile.sipMessage.setRequestUriUser("1XXXXXXXX82"); profile.bridge("514", "sipxpasswd"); } else if (ts == "1XXXXXXXX67") { profile.sipMessage.setRequestUriUser("501"); profile.bridge("501", "sipxpasswd"); } } return true; }