davehorton / drachtio-fs-load-balancing-proxy

Load-balancing SIP proxy for Freeswitch
http://davehorton.github.io/drachtio-fs-load-balancing-proxy/
MIT License
24 stars 12 forks source link
drachtio freeswitch proxy sip

drachtio logo

drachtio-fs-load-balancing-proxy is a nodejs-based SIP load balancer for Freeswitch servers.

It is based on the high-performance drachtio signaling resource framework, which in turn utilizes the sofia SIP stack.

The need to load balance SIP traffic across a horizontal cluster of Freeswitch servers is a common requirement. While other solutions exist (e.g. Kamailio), the solution presented here may be more desirable to nodejs developers who prefer Javascript over proprietary and cryptic configuration-driven logic. Additionally, the underlying framework provides tools to build a wider range of VoIP applications beyond simple SIP proxies.

drachtio is an open-source, nodejs-based ecosystem for creating any kind of VoIP server-based application: registrar, proxy, back-to-back user agent, and many others. Furthermore, when coupled with the drachtio media resource function, rich media-processing applications can be easily built as well. Nodejs developers experienced with the express or connect middleware frameworks will find drachtio very familiar.

Getting Started

Note: API documentation on the key application classes can be found here

The prerequisites: you will need to install a drachtio SIP server somewhere in your network to handle the SIP message processing.

The basics:

$ git clone git@github.com:davehorton/drachtio-fs-load-balancing-proxy.git
$ cd fs-load-balancing-proxy
$ npm install

Next, copy lib/config.example.js to config.js, and edit to specify the coordinates of your freeswitch servers, as well as your drachtio server process.

Then fire it up!

$ node app.js

Blacklisting SIP scanners

The proxy can optionally examine the SIP headers on incoming messages and based on regex patterns, add the source address to an iptables chain. The most useful configuration is to have a specific iptables chain set up for this, e.g 'LOGDROP', and include it from the input chain. Any requests that match the specified patterns will result in the sending address being added to that chain with a DROP action. Review lib/blacklist-regex.json.example and copy it to lib/blacklist-regex.json, edit as needed.

You can also optionally enforce a specific domain on requests, and blacklist any senders that generate requests for different domains.

Hacking the code

Contributors are welcome! Feel free to fork the repo and send me pull requests for any features or bug fixes.

The code is pretty simple, and there isn't that much of it. Here are a few notes to get you started:

License

MIT