📜 ⬆️ ⬇️

SIP Proxy on Twisted

Pythonists are aware that there is such a miracle library for working with network protocols like Twisted. It is a bit complicated at first, but after enlightenment it becomes an absolutely necessary tool.
In the standard package it comes with many already implemented protocols - IMAP, XMPP, HTTP (in combination with URL processing and some template library is a very useful tool), etc. The number of protocols that are implemented on / for Twisted is incalculable.


I found SIP among the standard protocols - it was last updated 3 years ago, there is a Shtoom VoIP phone project, which also stalled. Nevertheless, here is a Twisted recorder for you:

#!/usr/bin/env python # coding: utf-8 from twisted.application import internet, service import sip DOMAIN='192.168.9.5' application = service.Application("JuzzCallBack") sip.RegisterProxy.registry = sip.InMemoryRegistry(DOMAIN) sip.RegisterProxy.locator = sip.RegisterProxy.registry sip.RegisterProxy.debug = True proxy = internet.UDPServer(5060,sip.RegisterProxy()) proxy.setServiceParent(application) 

')
And what is most surprising is that it works. At leisure, I want to try to make the simplest SIP-phone, it will be interesting. I will call it Shtoom ressurection, it will not even have the functions of its predecessor, and it will die on version -0.1, wait!

For home reading - blog by Andrei Smirnov . I like this particular link, since newbies often skip the Deferred theme, and it’s very vain to write with Twisted without it.

Source: https://habr.com/ru/post/73565/


All Articles