File: pinger_s2s.tac

package info (click to toggle)
python-tx-xmpp 0.10.1.post1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,468 kB
  • sloc: python: 12,915; makefile: 3
file content (44 lines) | stat: -rw-r--r-- 1,250 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""
An XMPP Ping client as a standalone server via s2s.

This ping client accepts and initiates server-to-server connections using
dialback and listens on C{127.0.1.1} with the domain set to the default
hostname of this machine.
"""

import socket

from twisted.application import service, strports
from twisted.words.protocols.jabber.jid import JID
from tx_xmpp import component, server
from pinger import Pinger

# Configuration parameters

S2S_PORT = 'tcp:5269:interface=127.0.1.1'
SECRET = 'secret'
DOMAIN = socket.gethostname()
OTHER_DOMAIN = 'localhost'
LOG_TRAFFIC = True


# Set up the Twisted application

application = service.Application("Pinger Server")

router = component.Router()

serverService = server.ServerService(router, domain=DOMAIN, secret=SECRET)
serverService.logTraffic = LOG_TRAFFIC

s2sFactory = server.XMPPS2SServerFactory(serverService)
s2sFactory.logTraffic = LOG_TRAFFIC
s2sService = strports.service(S2S_PORT, s2sFactory)
s2sService.setServiceParent(application)

pingerComponent = component.InternalComponent(router, DOMAIN)
pingerComponent.logTraffic = LOG_TRAFFIC
pingerComponent.setServiceParent(application)

pingerHandler = Pinger(JID(OTHER_DOMAIN), JID(DOMAIN))
pingerHandler.setHandlerParent(pingerComponent)