def CheckDestination(self): if (self.dst_ip in self.wan_subnet): Int = Interface() dst_mac = Int.IPtoMAC(self.dst_ip) if (not dst_mac): run(f'ping {self.dst_ip} -c 1', shell=True) self.dst_mac = Int.IPtoMAC(self.dst_ip) else: self.dst_mac = dst_mac
def __init__(self, action): TLSRelay.action = action self.path = os.environ['HOME_DIR'] with open(f'{self.path}/data/config.json', 'r') as settings: self.setting = json.load(settings) self.lan_int = self.setting['Settings']['Interface']['Inside'] TLSRelay.wan_int = self.setting['Settings']['Interface']['Outside'] self.dnsserver = self.setting['Settings']['DNSServers'] Int = Interface() self.lan_ip = Int.IP(self.lan_int) self.wan_ip = Int.IP(self.wan_int) dfg = Int.DefaultGateway() dfg_mac = Int.IPtoMAC(dfg) self.wan_mac = Int.MAC(self.wan_int) self.lan_mac = Int.MAC(self.lan_int) wan_subnet = Int.WANSubnet(self.wan_int, dfg) self.wan_info = [dfg_mac, wan_subnet] TLSRelay.connections = {'Clients': {}} TLSRelay.active_connections = {'Clients': {}} TLSRelay.tcp_handshakes = {'Clients': {}} self.nat_ports = {} ## RAW Sockets which actually handle the traffic. TLSRelay.lan_sock = socket(AF_PACKET, SOCK_RAW) self.lan_sock.bind((self.lan_int, 3)) self.wan_sock = socket(AF_PACKET, SOCK_RAW) self.wan_sock.bind((self.wan_int, 3)) self.tls_ports = {443} TLSRelay.tcp_info = []