Debian Codegraph @

doc/examples/ping_s2s.tac

raw
1 """
2 An XMPP Ping server as a standalone server via s2s.
3
4 This ping responder accepts and initiates server-to-server connections using
5 dialback and listens on C{127.0.0.1} with the domain C{localhost}.
6 """
7
8 from twisted.application import service, strports
9 from tx_xmpp import component, server
10 from tx_xmpp.ping import PingHandler
11
12 # Configuration parameters
13
14 S2S_PORT = 'tcp:5269:interface=127.0.0.1'
15 SECRET = 'secret'
16 DOMAIN = 'localhost'
17 LOG_TRAFFIC = True
18
19
20 # Set up the Twisted application
21
22 application = service.Application("Ping Server")
23
24 router = component.Router()
25
26 serverService = server.ServerService(router, domain=DOMAIN, secret=SECRET)
27 serverService.logTraffic = LOG_TRAFFIC
28
29 s2sFactory = server.XMPPS2SServerFactory(serverService)
30 s2sFactory.logTraffic = LOG_TRAFFIC
31 s2sService = strports.service(S2S_PORT, s2sFactory)
32 s2sService.setServiceParent(application)
33
34 pingComponent = component.InternalComponent(router, DOMAIN)
35 pingComponent.logTraffic = LOG_TRAFFIC
36 pingComponent.setServiceParent(application)
37
38 pingHandler = PingHandler()
39 pingHandler.setHandlerParent(pingComponent)