Permalink
Browse files

slightly improve master security and switch back to port 9999 for the…

… master
  • Loading branch information...
1 parent af929c3 commit 2666975a6cb7415d8e10e28252a48e852eb6c641 @mkjones committed Oct 18, 2011
Showing with 6 additions and 1 deletion.
  1. +5 −0 master.py
  2. +1 −1 spotnado.py
View
@@ -1,5 +1,6 @@
import tornado.ioloop
import tornado.web
+import re
# Runs on a master server somewhere outside the local network.
# Takes a POST request with a single param ('addr') and stores
@@ -16,6 +17,10 @@ class RegisterHandler(tornado.web.RequestHandler):
def post(self):
internal_addr = self.get_argument('addr')
+ if not re.match('([\d]{1,3}\.){3}\d{1,3}$', internal_addr):
+ self.write('Invalid addr.')
+ return
+
external_addr = self.request.remote_ip
RegisterHandler.addrs[external_addr] = internal_addr
self.write(external_addr)
View
@@ -47,7 +47,7 @@ def post(self):
# clients can simply hit the master's URL, and it'll know where to
# redirect them so they hit this server (whatever IP it happens to be on)
local_addr = socket.gethostbyname(socket.gethostname())
- f = urllib2.urlopen("http://a.mkjon.es/register", "addr=%s" % (local_addr))
+ f = urllib2.urlopen("http://a.mkjon.es:9999/register", "addr=%s" % (local_addr))
print "Local address: %s, reported remote address; %s" % (
local_addr,
f.readline())

0 comments on commit 2666975

Please sign in to comment.