3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-27 21:19:31 +01:00

pr/insp: use TS6SIDGenerator in spawnServer if no SID is explicitly given

This commit is contained in:
James Lu 2015-07-11 20:09:36 -07:00
parent e250409b46
commit f8a7bc6033
2 changed files with 13 additions and 1 deletions

View File

@ -18,11 +18,20 @@ servers:
port: 7000
recvpass: "abcd"
sendpass: "abcd"
# Hostname we will use to connect to the remote server
hostname: "pylink.yournet"
# SID - required for InspIRCd and TS6 based servers. This must be three characters long.
# The first char must be a digit [0-9], and the remaining two chars may be letters [A-Z] or digits.
sid: "0AL"
# SID range - the range of SIDs PyLink is allowed to use to generate server IDs. On TS6,
# this should be a combination of digits, letters, and #'s. Each # denotes a range (0-9A-Z)
# of characters that can be used by PyLink. You will want to make sure no other servers
# are using this range. There must be at least one # in the entry.
sidrange: "8##"
# Autojoin channels
channels: ["#pylink"]
protocol: "inspircd"

View File

@ -546,10 +546,13 @@ def handle_events(irc, data):
traceback.print_exc()
continue
def spawnServer(irc, name, sid, uplink=None, desc='PyLink Server'):
def spawnServer(irc, name, sid=None, uplink=None, desc='PyLink Server'):
# -> :0AL SERVER test.server * 1 0AM :some silly pseudoserver
uplink = uplink or irc.sid
name = name.lower()
if sid is None:
irc.sidgen = utils.TS6SIDGenerator(irc.serverdata["sidrange"])
sid = irc.sidgen.next_sid()
assert len(sid) == 3, "Incorrect SID length"
if sid in irc.servers:
raise ValueError('A server with SID %r already exists!' % sid)