From e0e929492e2898fd937a04db99b1d1e8e9100c4b Mon Sep 17 00:00:00 2001 From: James Lu Date: Mon, 7 Aug 2017 16:31:17 -0700 Subject: [PATCH] match_host: implicitly convert string masks such as "user1" to "$pylinkacc:user1" This keeps it in line with other services packages and is way nicer to read. --- classes.py | 11 +++++++++++ example-conf.yml | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/classes.py b/classes.py index ea4d657..dcffcd6 100644 --- a/classes.py +++ b/classes.py @@ -1016,6 +1016,17 @@ class PyLinkNetworkCoreWithUtils(PyLinkNetworkCore): # Prepare a list of hosts to check against. if target in self.users: + + if not utils.isHostmask(glob): + for specialchar in '$:()': + # XXX: we should probably add proper rules on what's a valid account name + if specialchar in glob: + break + else: + # Implicitly convert matches for *sane* account names to "$pylinkacc:accountname". + log.debug('(%s) Using target $pylinkacc:%s instead of raw string %r', self.name, glob, glob) + glob = '$pylinkacc:' + glob + if glob.startswith('$'): # Exttargets start with $. Skip regular ban matching and find the matching ban handler. glob = glob.lstrip('$') diff --git a/example-conf.yml b/example-conf.yml index 386aecd..e3966d8 100644 --- a/example-conf.yml +++ b/example-conf.yml @@ -101,7 +101,7 @@ permissions: # Replace ABC123 with your PyLink account name (configured above) # in order to give yourself admin access. - "$pylinkacc:ABC123": + "ABC123": - "*" servers: