| 1 |
""" |
| 2 |
An XMPP Ping client as a standalone server via s2s. |
| 3 |
|
| 4 |
This ping client accepts and initiates server-to-server connections using |
| 5 |
dialback and listens on C{127.0.1.1} with the domain set to the default |
| 6 |
hostname of this machine. |
| 7 |
""" |
| 8 |
|
| 9 |
import socket |
| 10 |
|
| 11 |
from twisted.application import service, strports |
| 12 |
from twisted.words.protocols.jabber.jid import JID |
| 13 |
from tx_xmpp import component, server |
| 14 |
from pinger import Pinger |
| 15 |
|
| 16 |
# Configuration parameters |
| 17 |
|
| 18 |
S2S_PORT = 'tcp:5269:interface=127.0.1.1' |
| 19 |
SECRET = 'secret' |
| 20 |
DOMAIN = socket.gethostname() |
| 21 |
OTHER_DOMAIN = 'localhost' |
| 22 |
LOG_TRAFFIC = True |
| 23 |
|
| 24 |
|
| 25 |
# Set up the Twisted application |
| 26 |
|
| 27 |
application = service.Application("Pinger Server") |
| 28 |
|
| 29 |
router = component.Router() |
| 30 |
|
| 31 |
serverService = server.ServerService(router, domain=DOMAIN, secret=SECRET) |
| 32 |
serverService.logTraffic = LOG_TRAFFIC |
| 33 |
|
| 34 |
s2sFactory = server.XMPPS2SServerFactory(serverService) |
| 35 |
s2sFactory.logTraffic = LOG_TRAFFIC |
| 36 |
s2sService = strports.service(S2S_PORT, s2sFactory) |
| 37 |
s2sService.setServiceParent(application) |
| 38 |
|
| 39 |
pingerComponent = component.InternalComponent(router, DOMAIN) |
| 40 |
pingerComponent.logTraffic = LOG_TRAFFIC |
| 41 |
pingerComponent.setServiceParent(application) |
| 42 |
|
| 43 |
pingerHandler = Pinger(JID(OTHER_DOMAIN), JID(DOMAIN)) |
| 44 |
pingerHandler.setHandlerParent(pingerComponent) |