xmpproutertap.py 820 B

123456789101112131415161718192021222324252627282930
  1. # -*- test-case-name: twisted.words.test.test_xmpproutertap -*-
  2. #
  3. # Copyright (c) Twisted Matrix Laboratories.
  4. # See LICENSE for details.
  5. from twisted.application import strports
  6. from twisted.python import usage
  7. from twisted.words.protocols.jabber import component
  8. class Options(usage.Options):
  9. optParameters = [
  10. ('port', None, 'tcp:5347:interface=127.0.0.1',
  11. 'Port components connect to'),
  12. ('secret', None, 'secret', 'Router secret'),
  13. ]
  14. optFlags = [
  15. ('verbose', 'v', 'Log traffic'),
  16. ]
  17. def makeService(config):
  18. router = component.Router()
  19. factory = component.XMPPComponentServerFactory(router, config['secret'])
  20. if config['verbose']:
  21. factory.logTraffic = True
  22. return strports.service(config['port'], factory)