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 = []
def ShowIPAddress(self, initial_load=False): Inter = Int() with open(f'{HOME_DIR}/data/config.json', 'r') as settings: setting = json.load(settings) interface_settings = setting['settings']['interface'] default_wan_mac = interface_settings['wan']['default_mac'] configured_wan_mac = interface_settings['wan']['configured_mac'] dhcp = interface_settings['wan']['dhcp'] wan_int = interface_settings['outside'] if (not configured_wan_mac): configured_wan_mac = default_wan_mac if (dhcp): wan_mode = 'dhcp' else: wan_mode = 'static' wan_ip = Inter.IP(wan_int) wan_netmask = Inter.Netmask(wan_int) wan_dfg = Inter.DefaultGateway(wan_int) if (initial_load): self.interface_settings_pending['mode'].update( {'setting': wan_mode}) else: self.Standard.ShowSend('ip-address', wan_ip) self.Standard.ShowSend('netmask', wan_netmask) self.Standard.ShowSend('default-gateway', wan_dfg) self.Standard.ShowSend('mode', wan_mode)