示例#1
0
    def on_accept(self):
        clientsock, clientaddr = self.server.accept()
        forward= clientsock.recv(buffer_size)
        print "Message received from Client:", forward
        try:
            destination_ip = forward
        except socket.gaierror:
	        #could not resolve
            print 'Hostname could not be resolved. Exiting'
            sys.exit()
        fire=Firewall('blackList.txt','whitelist.txt')
        reply=fire.input_ip(destination_ip)
        print "SEEMA REPLY"
        print reply

        if reply == "no" :
            #scloud.close()
            print "BLOCKED!!!!!!!"
            sys.exit()
        server_host = '172.31.39.102'
        server_port = 8888

        server_ip=socket.gethostbyname(server_host)
	print server_ip
        forward = Forward().start(server_ip,server_port)	
        if forward:
            print clientaddr, "has connected"
            self.input_list.append(clientsock)
            self.input_list.append(forward)
            self.channel[clientsock] = forward
            self.channel[forward] = clientsock
        else:
            print "Can't establish connection with remote server.",
            print "Closing connection with client side", clientaddr
            clientsock.close()
示例#2
0
    def on_accept(self):
        clientsock, clientaddr = self.server.accept()
        forward = clientsock.recv(buffer_size)
        print "Message received from Client:", forward
        try:
            destination_ip = forward
        except socket.gaierror:
            #could not resolve
            print 'Hostname could not be resolved. Exiting'
            sys.exit()
        fire = Firewall('blackList.txt', 'whitelist.txt')
        reply = fire.input_ip(destination_ip)
        print "SEEMA REPLY"
        print reply

        if reply == "no":
            #scloud.close()
            print "BLOCKED!!!!!!!"
            sys.exit()
        server_host = '172.31.39.102'
        server_port = 8888

        server_ip = socket.gethostbyname(server_host)
        print server_ip
        forward = Forward().start(server_ip, server_port)
        if forward:
            print clientaddr, "has connected"
            self.input_list.append(clientsock)
            self.input_list.append(forward)
            self.channel[clientsock] = forward
            self.channel[forward] = clientsock
        else:
            print "Can't establish connection with remote server.",
            print "Closing connection with client side", clientaddr
            clientsock.close()
示例#3
0
def clientthread(conn):
    #Sending message to connected client
    #conn.send('Welcome to the server. Type something and hit enter\n') #send only takes string

    #infinite loop so that function do not terminate and thread do not end.
    #Receiving from client
    data = conn.recv(1024)
    #    print("Data Received Starts")
    #    print(data)
    #    print("Data Ends")
    fire = Firewall('blackList.txt', 'whitelist.txt')
    reply = fire.input_ip(data)
    #    print "TYPE OF REPLY"
    #    print type(reply)
    #print("Reply", reply)
    #    print "REPLY IS"
    #    print reply
    conn.sendall(reply)
    #came out of loop
    conn.close()
def clientthread(conn):
    #Sending message to connected client
    #conn.send('Welcome to the server. Type something and hit enter\n') #send only takes string
     
    #infinite loop so that function do not terminate and thread do not end.
    #Receiving from client
    data = conn.recv(1024)
#    print("Data Received Starts")
#    print(data)
#    print("Data Ends")
    fire=Firewall('blackList.txt','whitelist.txt')
    reply=fire.input_ip(data)
#    print "TYPE OF REPLY"
#    print type(reply)
    #print("Reply", reply)
#    print "REPLY IS"
#    print reply
    conn.sendall(reply)
    #came out of loop
    conn.close()
示例#5
0
    def on_accept(self):
        clientsock, clientaddr = self.server.accept()
        print clientaddr[0]
        fire = Firewall('blackList.txt', 'whitelist.txt')
        reply = fire.input_ip(clientaddr[0])
        if reply == 'no':  #192.168.239.128':
            print "Sorry"
            sys.exit(1)

        forward = Forward().start(forward_to[0], forward_to[1])
        if forward:
            print clientaddr, "has connected"
            self.input_list.append(clientsock)
            self.input_list.append(forward)
            self.channel[clientsock] = forward
            self.channel[forward] = clientsock
        else:
            print "Can't establish connection with remote server.",
            print "Closing connection with client side", clientaddr
            clientsock.close()
示例#6
0
    def on_accept(self):
        clientsock, clientaddr = self.server.accept()
        print clientaddr[0]
        fire=Firewall('blackList.txt','whitelist.txt')
        reply=fire.input_ip(clientaddr[0])
        if reply == 'no' :#192.168.239.128':
            print "Sorry"
            sys.exit(1)

        forward = Forward().start(forward_to[0], forward_to[1])    		
        if forward:
            print clientaddr, "has connected"
            self.input_list.append(clientsock)
            self.input_list.append(forward)
            self.channel[clientsock] = forward
            self.channel[forward] = clientsock
        else:
            print "Can't establish connection with remote server.",
            print "Closing connection with client side", clientaddr
            clientsock.close()