Skip to content

Commit

Permalink
feat: TokenFileName
Browse files Browse the repository at this point in the history
  • Loading branch information
shifengbin authored and CendioOssman committed Feb 8, 2024
1 parent 43c371f commit 0427f63
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions websockify/token_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@ def lookup(self, token):

return super().lookup(token)

class TokenFileName(BasePlugin):
# source is a directory
# token is filename
# contents of file is host:port
def __init__(self, src):
super().__init__(src)
if not os.path.isdir(src):
raise Exception("TokenFileName plugin requires a directory")

def lookup(self, token):
token = os.path.basename(token)
path = os.path.join(self.source, token)
if os.path.exists(path):
return open(path).read().strip().split(':')
else:
return None


class BaseTokenAPI(BasePlugin):
# source is a url with a '%s' in it where the token
Expand Down

0 comments on commit 0427f63

Please sign in to comment.