implement tunnel case properly
https://<hostname>:<webport>/?tunneled=1 uses 127.0.0.1:<websocketport> for the websocket. This allows tunneling.
This commit is contained in:
+9
-5
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import time
|
||||
import threading
|
||||
@@ -31,19 +30,24 @@ class Args:
|
||||
hostname = socket.gethostname()
|
||||
if '.' not in hostname:
|
||||
hostname += '.psi.ch'
|
||||
# args['wsaddr'] = f'{hostname}:{webport}'
|
||||
args['wsaddr'] = f'127.0.0.1:{webport}'
|
||||
self.hostname = hostname
|
||||
self.webport = webport
|
||||
self.port = int(port)
|
||||
self.html = args.pop('html')
|
||||
self.args = args
|
||||
print(self.html, self.port, self.args)
|
||||
|
||||
|
||||
args = Args(*sys.argv[1:])
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
return render_template(f'{args.html}', **args.args)
|
||||
if request.args.get('tunneled'):
|
||||
wsaddr = f'127.0.0.1:{args.webport}'
|
||||
else:
|
||||
wsaddr = f'{args.hostname}:{args.webport}'
|
||||
return render_template(f'{args.html}', wsaddr=wsaddr, **args.args)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host="0.0.0.0", port=args.port, debug=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user