mirror of
https://github.com/jlu5/PyLink.git
synced 2025-01-23 02:34:09 +01:00
relay: make spawning of subservers toggleable
This commit is contained in:
parent
55b642ea30
commit
9e07949730
@ -39,6 +39,10 @@ relay:
|
|||||||
# will see yours.
|
# will see yours.
|
||||||
show_ips: false
|
show_ips: false
|
||||||
|
|
||||||
|
# Whether subservers should be spawned for each relay network (requires reload to change).
|
||||||
|
# Defaults to true.
|
||||||
|
spawn_servers: true
|
||||||
|
|
||||||
servers:
|
servers:
|
||||||
yournet:
|
yournet:
|
||||||
# Server IP, port, and passwords
|
# Server IP, port, and passwords
|
||||||
|
@ -164,6 +164,12 @@ def getPrefixModes(irc, remoteirc, channel, user, mlist=None):
|
|||||||
def getRemoteSid(irc, remoteirc):
|
def getRemoteSid(irc, remoteirc):
|
||||||
"""Gets the remote server SID representing remoteirc on irc, spawning
|
"""Gets the remote server SID representing remoteirc on irc, spawning
|
||||||
it if it doesn't exist."""
|
it if it doesn't exist."""
|
||||||
|
try:
|
||||||
|
spawnservers = irc.conf['relay']['spawn_servers']
|
||||||
|
except KeyError:
|
||||||
|
spawnservers = True
|
||||||
|
if not spawnservers:
|
||||||
|
return irc.sid
|
||||||
with spawnlocks_servers[irc.name]:
|
with spawnlocks_servers[irc.name]:
|
||||||
try:
|
try:
|
||||||
sid = relayservers[irc.name][remoteirc.name]
|
sid = relayservers[irc.name][remoteirc.name]
|
||||||
@ -245,16 +251,11 @@ def getRemoteUser(irc, remoteirc, user, spawnIfMissing=True):
|
|||||||
else:
|
else:
|
||||||
realhost = None
|
realhost = None
|
||||||
ip = '0.0.0.0'
|
ip = '0.0.0.0'
|
||||||
try:
|
u = remoteirc.proto.spawnClient(nick, ident=ident,
|
||||||
u = remoteirc.proto.spawnClient(nick, ident=ident,
|
|
||||||
host=host, realname=realname,
|
host=host, realname=realname,
|
||||||
modes=modes, ts=userobj.ts,
|
modes=modes, ts=userobj.ts,
|
||||||
opertype=opertype, server=rsid,
|
opertype=opertype, server=rsid,
|
||||||
ip=ip, realhost=realhost).uid
|
ip=ip, realhost=realhost).uid
|
||||||
except ValueError:
|
|
||||||
log.exception('(%s) Failed to spawn relay user %s on %s.', irc.name,
|
|
||||||
nick, remoteirc.name)
|
|
||||||
return
|
|
||||||
remoteirc.users[u].remote = (irc.name, user)
|
remoteirc.users[u].remote = (irc.name, user)
|
||||||
remoteirc.users[u].opertype = opertype
|
remoteirc.users[u].opertype = opertype
|
||||||
away = userobj.away
|
away = userobj.away
|
||||||
@ -999,7 +1000,11 @@ def handle_disconnect(irc, numeric, command, args):
|
|||||||
if irc.name in v:
|
if irc.name in v:
|
||||||
del relayusers[k][irc.name]
|
del relayusers[k][irc.name]
|
||||||
if k[0] == irc.name:
|
if k[0] == irc.name:
|
||||||
del relayusers[k]
|
try:
|
||||||
|
handle_quit(irc, k[1], 'PYLINK_DISCONNECT', {'text': 'Home network lost connection.'})
|
||||||
|
del relayusers[k]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
for name, ircobj in world.networkobjects.items():
|
for name, ircobj in world.networkobjects.items():
|
||||||
if name != irc.name:
|
if name != irc.name:
|
||||||
rsid = getRemoteSid(ircobj, irc)
|
rsid = getRemoteSid(ircobj, irc)
|
||||||
|
Loading…
Reference in New Issue
Block a user