Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent eca991d commit 42ded89Copy full SHA for 42ded89
1 file changed
Demo/pysvr/pysvr.py
@@ -48,14 +48,15 @@ def main_thread(port):
48
print "Listening on port", port, "..."
49
while 1:
50
(conn, addr) = sock.accept()
51
+ if addr[0] != conn.getsockname()[0]:
52
+ conn.close()
53
+ print "Refusing connection from non-local host", addr[0], "."
54
+ continue
55
thread.start_new_thread(service_thread, (conn, addr))
56
del conn, addr
57
58
def service_thread(conn, addr):
59
(caddr, cport) = addr
- if caddr != socket.gethostbyname(socket.gethostname()):
- print "Connection from", caddr, "not accepted."
- return
60
print "Thread %s has connection from %s.\n" % (str(thread.get_ident()),
61
caddr),
62
stdin = conn.makefile("r")
0 commit comments