Esempio n. 1
0
    def start(self):
        while True:
            try:
                client_socket, client_address = self.server_socket.accept()
                client_port = client_address[1]
                self.logger.info(f'recieved client at {client_address}')
                
                thread_name = self.format_client_name(client_address)
                connection = ClientConnection(
                    client_socket,
                    client_address,
                    self.server,
                    sslogger.ColoredLogger(thread_name),
                    self.connection_ended,
                    max_request_len=self.config.buffer,
                    connection_timeout=self.config.timeout
                )
                self.connections[client_port] = connection

                c = threading.Thread(
                    name=thread_name,
                    target=connection.run,
                )
                c.setDaemon(True)
                c.start()
            except Exception as e:
                self.logger.error(e)
                break
Esempio n. 2
0
    def start_connection(self, server_ip, server_port):
        logger = sslogger.ColoredLogger('root')

        self.config.server_ip = server_ip
        self.config.server_port = server_port

        self.proxy = Proxy(self.config, logger)
        self.proxy_thread = threading.Thread(target=self.proxy.start)
        self.proxy_thread.setDaemon(True)
        self.proxy_thread.start()

        self.main.pack_forget()
        self.render_connected(server_ip, server_port)
Esempio n. 3
0
    def start(self):
        while True:
            try:
                client_socket, client_address = self.server_socket.accept()
                self.logger.info(f'recieved client at {client_address}')

                thread_name = self._getClientName(client_address)
                connection = VPNConnection(
                    client_socket,
                    client_address,
                    sslogger.ColoredLogger(thread_name),
                    max_request_len=self.config.buffer_size,
                    connection_timeout=self.config.timeout,
                    encrypted=self.config.encrypted,
                )

                c = threading.Thread(name=thread_name, target=connection.run)
                c.setDaemon(True)
                c.start()
            except Exception as e:
                self.logger.error(e)
                break
Esempio n. 4
0
parser = argparse.ArgumentParser(description='Runs a Smokescreen VPN server.')
parser.add_argument('--hostname', metavar='HOSTNAME', type=str,
                    default='localhost',
                    help='Default: localhost. Server IP address.')
parser.add_argument('--port', '-p', metavar='PORT', type=int,
                    default=1515,
                    help='Default: 1515. Server port.')
parser.add_argument('--buffer', metavar='BUFFER_SIZE', type=int,
                    default=1000000,
                    help='Default: 1MB. Size of the buffer.')
parser.add_argument('--timeout', metavar='TIMEOUT', type=int,
                    default=10,
                    help='Default: 10. Socket timeout in seconds.')
parser.add_argument('--no-enc', dest='encrypted', action='store_const',
                    const=False, default=True,
                    help='Client won\'t establish encrypted connection')


if __name__ == '__main__':
    args = parser.parse_args()

    config = ServerConfig(
        args.hostname,
        args.port,
        args.buffer,
        args.timeout,
        args.encrypted,
    )

    s = Server(config, sslogger.ColoredLogger('root'))
    s.start()
Esempio n. 5
0
                    default='localhost',
                    help='Default: localhost. Server IP.')
parser.add_argument('--server-port',
                    '-p',
                    metavar='SERVER_PORT',
                    type=int,
                    default=1515,
                    help='Default: 1515. Server port.')
parser.add_argument('--client-port',
                    metavar='PORT',
                    type=int,
                    default=1516,
                    help='Default: 1516. Client port.')
parser.add_argument('--buffer',
                    metavar='BUFFER_SIZE',
                    type=int,
                    default=1000000,
                    help='Default: 1MB. Size of the buffer.')
parser.add_argument('--timeout',
                    metavar='TIMEOUT',
                    type=int,
                    default=10,
                    help='Default: 10. Socket timeout in seconds.')

if __name__ == '__main__':
    args = parser.parse_args()
    logger = sslogger.ColoredLogger('root')

    s = Proxy(args, logger)
    s.start()