| 1 |
""" |
| 2 |
An XMPP Ping server as a standalone server with external component service. |
| 3 |
|
| 4 |
This ping responder server uses the C{ping} domain, and also accepts External |
| 5 |
Component connections on port C{5347}, but only on C{127.0.0.1}. |
| 6 |
""" |
| 7 |
|
| 8 |
from twisted.application import service, strports |
| 9 |
from tx_xmpp import component |
| 10 |
from tx_xmpp.ping import PingHandler |
| 11 |
|
| 12 |
# Configuration parameters |
| 13 |
|
| 14 |
EXT_PORT = 'tcp:5347:interface=127.0.0.1' |
| 15 |
SECRET = 'secret' |
| 16 |
DOMAIN = 'ping' |
| 17 |
LOG_TRAFFIC = True |
| 18 |
|
| 19 |
|
| 20 |
# Set up the Twisted application |
| 21 |
|
| 22 |
application = service.Application("XMPP Ping Server") |
| 23 |
|
| 24 |
router = component.Router() |
| 25 |
|
| 26 |
componentServerFactory = component.XMPPComponentServerFactory(router, SECRET) |
| 27 |
componentServerFactory.logTraffic = LOG_TRAFFIC |
| 28 |
componentServer = strports.service(EXT_PORT, componentServerFactory) |
| 29 |
componentServer.setServiceParent(application) |
| 30 |
|
| 31 |
pingComponent = component.InternalComponent(router, DOMAIN) |
| 32 |
pingComponent.logTraffic = LOG_TRAFFIC |
| 33 |
pingComponent.setServiceParent(application) |
| 34 |
|
| 35 |
pingHandler = PingHandler() |
| 36 |
pingHandler.setHandlerParent(pingComponent) |