def on_accept(self): forward = Forward().start(self.dst_addr, self.dst_port) clientsock, clientaddr = self.server.accept() if forward: if self.tls_type == 'start-tls': forward, cmd = libtlsd.pass_to_daemon(forward, 'start-tls') else: clientsock, cmd = libtlsd.pass_to_daemon(clientsock, 'recv-tls') 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()
def on_accept(self): forward = Forward().start(self.dst_addr, self.dst_port) clientsock, clientaddr = self.server.accept() if forward: if self.tls_type == 'start-tls': forward, cmd = libtlsd.pass_to_daemon(forward, 'start-tls') else: clientsock, cmd = libtlsd.pass_to_daemon( clientsock, 'recv-tls') 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()
#!/usr/bin/env python import os import sys import socket import time import libtlsd print "Creating connection to server" HOST = "rp2.oslo.practicum.os3.nl" # The remote host PORT = 10000 USER_INPUT = False conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: conn.connect((HOST, PORT)) conn, cmd, status, msg = libtlsd.pass_to_daemon(conn, "start-tls " + HOST + " no-dnssec;ignore-bogus") if status > 0: print msg sys.exit(0) print "Identity of peer is: %s" % msg while USER_INPUT: x = raw_input(">") if x == "quit": cmd.sendall("quit") break conn.send(x) print "sent", x
import libtlsd sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) HOST = '0.0.0.0' PORT = 10000 sock.bind((HOST, PORT)) sock.listen(1) print "Listening on port %d" % PORT while True: try: conn, address = sock.accept() print "Incoming", address conn, cmd, status, msg = libtlsd.pass_to_daemon( conn, 'recv-tls no-dnssec') if status > 0: print msg sys.exit(0) print "Identity of peer is: %s" % msg while (True): try: buf = conn.recv(1024) print 'Received: %d %s' % (len(buf), buf.rstrip()) if (len(buf) <= 0): break except KeyboardInterrupt: print "Ctrl C - Terminating Session; Press Ctrl+C again to stop the server"
#!/usr/bin/env python import os import sys import socket import time import libtlsd print "Creating connection to server" HOST = 'rp2.oslo.practicum.os3.nl' # The remote host PORT = 10000 USER_INPUT = False conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: conn.connect((HOST, PORT)) conn, cmd, status, msg = libtlsd.pass_to_daemon( conn, 'start-tls ' + HOST + ' no-dnssec;ignore-bogus') if status > 0: print msg sys.exit(0) print "Identity of peer is: %s" % msg while USER_INPUT: x = raw_input(">") if (x == 'quit'): cmd.sendall('quit') break conn.send(x) print "sent", x
import libtlsd sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) HOST = '0.0.0.0' PORT = 10000 sock.bind((HOST, PORT)) sock.listen(1) print "Listening on port %d" % PORT while True: try: conn, address = sock.accept() print "Incoming", address conn, cmd, status, msg = libtlsd.pass_to_daemon(conn, 'recv-tls no-dnssec') if status > 0: print msg sys.exit(0) print "Identity of peer is: %s" % msg while(True): try: buf = conn.recv(1024) print 'Received: %d %s' % (len(buf), buf.rstrip()) if(len(buf) <= 0): break except KeyboardInterrupt: print "Ctrl C - Terminating Session; Press Ctrl+C again to stop the server"