3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 01:09:22 +01:00

core: SID and hostname options are now optional (#282)

Hostname defaults to a fallback hardcoded in world.fallback_hostname, while SID defaults to None (protocol modules have to deal with this themselves)
This commit is contained in:
James Lu 2016-07-28 22:22:47 -07:00
parent f45cb3a583
commit f4922743fc
4 changed files with 13 additions and 8 deletions

View File

@ -44,8 +44,8 @@ class Irc():
self.loghandlers = [] self.loghandlers = []
self.name = netname self.name = netname
self.conf = conf self.conf = conf
self.sid = None
self.serverdata = conf['servers'][netname] self.serverdata = conf['servers'][netname]
self.sid = self.serverdata["sid"]
self.botdata = conf['bot'] self.botdata = conf['bot']
self.bot_clients = {} self.bot_clients = {}
self.protoname = proto.__name__.split('.')[-1] # Remove leading pylinkirc.protocols. self.protoname = proto.__name__.split('.')[-1] # Remove leading pylinkirc.protocols.
@ -99,7 +99,6 @@ class Irc():
(Re)sets an IRC object to its default state. This should be called when (Re)sets an IRC object to its default state. This should be called when
an IRC object is first created, and on every reconnection to a network. an IRC object is first created, and on every reconnection to a network.
""" """
self.sid = self.serverdata["sid"]
self.botdata = self.conf['bot'] self.botdata = self.conf['bot']
self.pingfreq = self.serverdata.get('pingfreq') or 90 self.pingfreq = self.serverdata.get('pingfreq') or 90
self.pingtimeout = self.pingfreq * 3 self.pingtimeout = self.pingfreq * 3
@ -272,13 +271,16 @@ class Irc():
hashtype, fp) hashtype, fp)
if checks_ok: if checks_ok:
# All our checks passed, get the protocol module to connect self.sid = self.serverdata.get("sid")
# and run the listen loop. # All our checks passed, get the protocol module to connect and run the listen
# loop. This also updates any SID values should the protocol module do so.
self.proto.connect() self.proto.connect()
log.info('(%s) Enumerating our own SID %s', self.name, self.sid) log.info('(%s) Enumerating our own SID %s', self.name, self.sid)
self.servers[self.sid] = IrcServer(None, self.serverdata['hostname'], host = self.serverdata.get('hostname', world.fallback_hostname)
internal=True, desc=self.serverdata.get('serverdesc')
self.servers[self.sid] = IrcServer(None, host, internal=True,
desc=self.serverdata.get('serverdesc')
or self.botdata['serverdesc']) or self.botdata['serverdesc'])
log.info('(%s) Starting ping schedulers....', self.name) log.info('(%s) Starting ping schedulers....', self.name)

View File

@ -27,7 +27,7 @@ def spawn_service(irc, source, command, args):
ident = irc.serverdata.get("%s_ident" % name) or conf.conf.get(name, {}).get('ident') or sbot.ident or name ident = irc.serverdata.get("%s_ident" % name) or conf.conf.get(name, {}).get('ident') or sbot.ident or name
# TODO: make this configurable? # TODO: make this configurable?
host = irc.serverdata["hostname"] host = irc.serverdata.get("hostname", world.fallback_hostname)
# Spawning service clients with these umodes where supported. servprotect usage is a # Spawning service clients with these umodes where supported. servprotect usage is a
# configuration option. # configuration option.

View File

@ -11,7 +11,7 @@ class ClientbotWrapperProtocol(Protocol):
super().__init__(irc) super().__init__(irc)
# Remove conf key checks for those not needed for Clientbot. # Remove conf key checks for those not needed for Clientbot.
self.conf_keys -= {'recvpass', 'sendpass'} self.conf_keys -= {'recvpass', 'sendpass', 'sid', 'sidrange', 'hostname'}
# This is just a fallback. Actual casemapping is fetched by handle_005() # This is just a fallback. Actual casemapping is fetched by handle_005()
self.casemapping = 'ascii' self.casemapping = 'ascii'

View File

@ -22,3 +22,6 @@ exttarget_handlers = {}
started = threading.Event() started = threading.Event()
source = "https://github.com/GLolol/PyLink" # CHANGE THIS IF YOU'RE FORKING!! source = "https://github.com/GLolol/PyLink" # CHANGE THIS IF YOU'RE FORKING!!
# Fallback hostname used in various places internally when hostname isn't configured.
fallback_hostname = 'pylink.int'