Changeset View
Changeset View
Standalone View
Standalone View
source/tools/XpartaMuPP/XpartaMuPP.py
Show First 20 Lines • Show All 633 Lines • ▼ Show 20 Lines | if __name__ == '__main__': | ||||
optp.add_option('-e', '--elo', help='set rating bot username', | optp.add_option('-e', '--elo', help='set rating bot username', | ||||
action='store', dest='xratingsbot', | action='store', dest='xratingsbot', | ||||
default="disabled") | default="disabled") | ||||
# ejabberd server options | # ejabberd server options | ||||
optp.add_option('-s', '--server', help='address of the ejabberd server', | optp.add_option('-s', '--server', help='address of the ejabberd server', | ||||
action='store', dest='xserver', | action='store', dest='xserver', | ||||
default="localhost") | default="localhost") | ||||
optp.add_option('-P', '--port', help='ejabberd server port', | |||||
action='store', dest='xport', type='int', | |||||
default=5222) | |||||
opts, args = optp.parse_args() | opts, args = optp.parse_args() | ||||
# Setup logging. | # Setup logging. | ||||
logging.basicConfig(level=opts.loglevel, | logging.basicConfig(level=opts.loglevel, | ||||
format='%(asctime)s %(levelname)-8s %(message)s', datefmt='%Y-%m-%d %H:%M:%S') | format='%(asctime)s %(levelname)-8s %(message)s', datefmt='%Y-%m-%d %H:%M:%S') | ||||
# XpartaMuPP | # XpartaMuPP | ||||
xmpp = XpartaMuPP(opts.xlogin+'@'+opts.xdomain+'/CC', opts.xpassword, opts.xroom+'@conference.'+opts.xdomain, opts.xnickname, opts.xratingsbot+'@'+opts.xdomain+'/CC') | xmpp = XpartaMuPP(opts.xlogin+'@'+opts.xdomain+'/CC', opts.xpassword, opts.xroom+'@conference.'+opts.xdomain, opts.xnickname, opts.xratingsbot+'@'+opts.xdomain+'/CC') | ||||
xmpp.register_plugin('xep_0030') # Service Discovery | xmpp.register_plugin('xep_0030') # Service Discovery | ||||
xmpp.register_plugin('xep_0004') # Data Forms | xmpp.register_plugin('xep_0004') # Data Forms | ||||
xmpp.register_plugin('xep_0045') # Multi-User Chat # used | xmpp.register_plugin('xep_0045') # Multi-User Chat # used | ||||
xmpp.register_plugin('xep_0060') # PubSub | xmpp.register_plugin('xep_0060') # PubSub | ||||
xmpp.register_plugin('xep_0199') # XMPP Ping | xmpp.register_plugin('xep_0199') # XMPP Ping | ||||
if xmpp.connect((opts.xserver, 5222)): | if xmpp.connect((opts.xserver, opts.xport)): | ||||
Dunedan: Instead of adding a port option to the bots, I suggest to remove the`--server` option as well… | |||||
xmpp.process(threaded=False) | xmpp.process(threaded=False) | ||||
else: | else: | ||||
logging.error("Unable to connect") | logging.error("Unable to connect") |
Wildfire Games · Phabricator
Instead of adding a port option to the bots, I suggest to remove the`--server` option as well and to call xmpp.connect() without any arguments. Without providing an address tuple to xmpp.connect() SleekXMPP tries to figure out the server and port using DNS SRV records to figure out the responsible XMPP server for the given JID (see https://wiki.xmpp.org/web/SRV_Records#XMPP_SRV_records) and falls back to using the domain from the JID as server and the default port 5222 in case no SRV record can be found (https://github.com/fritzy/SleekXMPP/blob/7075a3b7fa857fc8f9db60da9d01fa1a11806659/sleekxmpp/clientxmpp.py#L154-L156),
So removing the --server option instead of adding a --port option would keep the bots functioning as they are, remove the need for 2 additional options to provide to them and would be more standard compliant, as it'd honor DNS SRV records. For XMPP server operators that'd mean that they'd have to add a SRV-DNS-record if they want to use a non-default port, something they should do anyway.