remove hard-coded key, max_age
Showing
... | @@ -3,6 +3,7 @@ | ... | @@ -3,6 +3,7 @@ |
# http://musta.sh/2012-03-04/twisted-tcp-proxy.html | # http://musta.sh/2012-03-04/twisted-tcp-proxy.html | ||
import sys | import sys | ||
from os import environ | |||
from twisted.internet import defer | from twisted.internet import defer | ||
from twisted.internet import protocol | from twisted.internet import protocol | ||
... | @@ -16,6 +17,9 @@ from websockets import WebSocketsResource, lookupProtocolForFactory | ... | @@ -16,6 +17,9 @@ from websockets import WebSocketsResource, lookupProtocolForFactory |
from django.core import signing | from django.core import signing | ||
PROXY_SECRET = environ.get('PROXY_SECRET') | |||
KEY_MAX_AGE = environ.get('KEY_MAX_AGE', 300) | |||
class ProxyClientProtocol(protocol.Protocol): | class ProxyClientProtocol(protocol.Protocol): | ||
def connectionMade(self): | def connectionMade(self): | ||
... | @@ -61,7 +65,7 @@ class VNCWebSocketHandler(Protocol): | ... | @@ -61,7 +65,7 @@ class VNCWebSocketHandler(Protocol): |
def makeConnection(self, transport): | def makeConnection(self, transport): | ||
try: | try: | ||
value = signing.loads(transport.request.args['d'][0], | value = signing.loads(transport.request.args['d'][0], | ||
key='asdasd', max_age=300) | key=PROXY_SECRET, max_age=KEY_MAX_AGE) | ||
Please
register
or
sign in
to reply
|
|
||
port = value['port'] | port = value['port'] | ||
host = value['host'] | host = value['host'] | ||
except: | except: | ||
... | ... |