def main(): """ <Purpose> This is the main of the function. It launches a tcp client to connect to local apache server and then retrieve a file. It also has a server to listen for incoming connections from the client version of this program. <Arguments> None. <Exceptions> None. <Return> None. """ if len(sys.argv) < 4: usage() global server_address global server_port # Specify the server address and port server_address = sys.argv[1] server_port = int(sys.argv[2]) # Specify the TCP port to listen on. incoming_connection_port = int(sys.argv[3]) # Launch a TCP server to listen on from the client side. repyportability.waitforconn(repyportability.getmyip(), incoming_connection_port, tcp_file_server)
More information on geoip_server.py at http://seattle.cs.washington.edu/wiki/GeoIPServer """ import sys sys.path.append("./seattle/seattle_repy") import pygeoip import repyportability from SimpleXMLRPCServer import SimpleXMLRPCServer # Handle arguments if len(sys.argv) < 3: print "Usage: python geoip_server.py /path/to/GeoIP.dat PORT" raise RuntimeError geoipdb_filename = sys.argv[1] port = int(sys.argv[2]) # Get external IP ext_ip = repyportability.getmyip() # Create server server = SimpleXMLRPCServer((ext_ip, port), allow_none=True) # Initialize and register geoip object gic = pygeoip.GeoIP(geoipdb_filename) server.register_instance(gic) # Run the server's main loop server.serve_forever()
# 172.31.255.255/16 elif ip_int_tokens[0] == 172: if 16 <= ip_int_tokens[1] and ip_int_tokens[1] < 32: return False # Class C private addresses are in the form 192.168.*.* elif ip_int_tokens[0:2] == [192, 168]: return False return True # Handle arguments if len(sys.argv) < 3: print "Usage: python geoip_server.py /path/to/GeoIP.dat PORT" raise RuntimeError geoipdb_filename = sys.argv[1] port = int(sys.argv[2]) # Get external IP ext_ip = repyportability.getmyip() # Create server server = SimpleXMLRPCServer((ext_ip, port), allow_none=True) # Initialize and register geoip object gic = SafeGeoIPServer(geoipdb_filename) server.register_instance(gic) # Run the server's main loop server.serve_forever()