def __init__(self, iface): # If SO_BINDTODEVICE is present, it is possible for dhcpd to operate on Linux with more than one network interface. # man 7 socket if not hasattr(IN, "SO_BINDTODEVICE"): IN.SO_BINDTODEVICE = 25 self.iface = iface self.START_SIGNAL = True import network if network.get_ip_address(self.iface): self.ip = network.get_ip_address(self.iface) else: self.ip = '192.168.103.1' self.port = 67 self.elements_in_address = self.ip.split('.') # IP pool x.x.x.100 ~ x.x.x.150 self.offer_from = '.'.join(self.elements_in_address[0:3]) + '.100' self.offer_to = '.'.join(self.elements_in_address[0:3]) + '.150' self.subnet_mask = '255.255.255.0' self.router = self.ip self.dns_server = self.ip self.broadcast = '<broadcast>' self.file_server = self.ip self.file_name = '' # ?? if not self.file_name: self.force_file_name = False self.file_name = 'pxelinux.0' else: self.force_file_name = True self.ipxe = False self.http = False self.mode_proxy = False self.static_config = dict() self.whitelist = False self.mode_debug = False # The value of the magic-cookie is the 4 octet dotted decimal 99.130.83.99 # (or hexadecimal number 63.82.53.63) in network byte order. # (this is the same magic cookie as is defined in RFC 1497 [17]) # In module struct '!' mean Big-endian # 'I' mean unsigned int self.magic = struct.pack('!I', 0x63825363) # magic cookie. self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.sock.setsockopt(socket.SOL_SOCKET, IN.SO_BINDTODEVICE, self.iface + '\0') self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) self.sock.bind(('', self.port)) # Specific key is MAC self.leases = defaultdict(lambda: { 'ip': '', 'expire': 0, 'ipxe': self.ipxe }) self.connect_user = dict() self.connect_data = ''
def __init__(self, iface): # If SO_BINDTODEVICE is present, it is possible for dhcpd to operate on Linux with more than one network interface. # man 7 socket if not hasattr(IN, "SO_BINDTODEVICE"): IN.SO_BINDTODEVICE = 25 self.iface = iface self.START_SIGNAL = True import network if network.get_ip_address(self.iface): self.ip = network.get_ip_address(self.iface) else: self.ip = "192.168.103.1" self.port = 67 self.elements_in_address = self.ip.split(".") # IP pool x.x.x.100 ~ x.x.x.150 self.offer_from = ".".join(self.elements_in_address[0:3]) + ".100" self.offer_to = ".".join(self.elements_in_address[0:3]) + ".150" self.subnet_mask = "255.255.255.0" self.router = self.ip self.dns_server = self.ip self.broadcast = "<broadcast>" self.file_server = self.ip self.file_name = "" # ?? if not self.file_name: self.force_file_name = False self.file_name = "pxelinux.0" else: self.force_file_name = True self.ipxe = False self.http = False self.mode_proxy = False self.static_config = dict() self.whitelist = False self.mode_debug = False # The value of the magic-cookie is the 4 octet dotted decimal 99.130.83.99 # (or hexadecimal number 63.82.53.63) in network byte order. # (this is the same magic cookie as is defined in RFC 1497 [17]) # In module struct '!' mean Big-endian # 'I' mean unsigned int self.magic = struct.pack("!I", 0x63825363) # magic cookie. self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.sock.setsockopt(socket.SOL_SOCKET, IN.SO_BINDTODEVICE, self.iface + "\0") self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) self.sock.bind(("", self.port)) # Specific key is MAC self.leases = defaultdict(lambda: {"ip": "", "expire": 0, "ipxe": self.ipxe}) self.connect_user = dict() self.connect_data = ""
def __init__(self, iface, timeout=300, ftp_login=False, ssh_login=False, telnet_login=False, smtp_login=False, pop_login=False, imap_login=False, ldap_login=False, smb_login=False, rlogin_login=False, mssql_login=False, mysql_login=False, pgsql_login=False, vnc_login=False, snmp_login=False): self.iface = iface self.timeout = timeout self.ftp_login = ftp_login self.ssh_login = ssh_login self.telnet_login = telnet_login self.smtp_login = smtp_login self.pop_login = pop_login self.imap_login = imap_login self.ldap_login = ldap_login self.smb_login = smb_login self.rlogin_login = rlogin_login self.mssql_login = mssql_login self.mysql_login = mysql_login self.pgsql_login = pgsql_login self.vnc_login = vnc_login self.snmp_login = snmp_login self.network_host_list = network.network_host_ip('eth0') self.my_ip = network.get_ip_address('eht0') self.user = [] self.password = [] self.idx = len(self.user) self.return_result = "["
def __init__(self, iface, enc, ssid, password): self.wlan = iface self.ppp = 'eth0' self.enc = enc import network if network.get_ip_address(self.wlan): self.address = network.get_ip_address(self.wlan) else: self.address = '192.168.103.1' self.netmask = '255.255.255.0' self.ssid = ssid self.password = password self.dhcp = DHCPServer(self.wlan) self.dhcp_thread = threading.Thread(target=self.dhcp.run) self.dns_server = DNSServer(self.wlan, self.address) self.dns_thread = threading.Thread(target=self.dns_server.run) self.web_server = WEBServer(self.wlan, self.address) self.web_process = Process(target=self.web_server.run)
def __init__(self, iface, enc, ssid, password): self.wlan = iface self.ppp = 'eth0' self.enc = str(enc).upper() import network # Get my IP address and create thread for DHCPServer, DNSServer, WEBServer. if network.get_ip_address(self.wlan): self.address = network.get_ip_address(self.wlan) else: # If self.address is missing then Set static IP address. self.address = '192.168.103.1' self.netmask = '255.255.255.0' self.ssid = ssid self.password = password self.dhcp = DHCPServer(self.wlan) self.dhcp_thread = threading.Thread(target=self.dhcp.run) self.dns_server = DNSServer(self.wlan, self.address) self.dns_thread = threading.Thread(target=self.dns_server.run) self.web_server = WEBServer(self.wlan, self.address) self.web_process = Process(target=self.web_server.run)
def __init__(self, iface): if not hasattr(IN, "SO_BINDTODEVICE"): IN.SO_BINDTODEVICE = 25 self.iface = iface self.START_SIGNAL = True import network if network.get_ip_address(self.iface): self.ip = network.get_ip_address(self.iface) else: self.ip = '192.168.103.1' self.port = 67 self.elements_in_address = self.ip.split('.') self.offer_from = '.'.join(self.elements_in_address[0:3]) + '.100' self.offer_to = '.'.join(self.elements_in_address[0:3]) + '.150' self.subnet_mask = '255.255.255.0' self.router = self.ip self.dns_server = self.ip self.broadcast = '<broadcast>' self.file_server = self.ip self.file_name = '' if not self.file_name: self.force_file_name = False self.file_name = 'pxelinux.0' else: self.force_file_name = True self.ipxe = False self.http = False self.mode_proxy = False self.static_config = dict() self.whitelist = False self.mode_debug = False self.magic = struct.pack('!I', 0x63825363) # magic cookie self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.sock.setsockopt(socket.SOL_SOCKET, IN.SO_BINDTODEVICE, self.iface + '\0') self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) self.sock.bind(('', self.port)) # key is MAC self.leases = defaultdict(lambda: {'ip': '', 'expire': 0, 'ipxe': self.ipxe})
def __init__(self, iface, enc, ssid, password): self.wlan = iface self.ppp = 'eth0' self.enc = str(enc).upper() import network # Get my IP address and create thread for DHCPServer, DNSServer, WEBServer. if network.get_ip_address(self.wlan): self.address = network.get_ip_address(self.wlan) else: # If self.address is missing then Set static IP address. self.address = '192.168.103.1' self.netmask = '255.255.255.0' self.ssid = ssid self.password = password self.dhcp = DHCPServer(self.wlan) self.dhcp_thread = threading.Thread(target=self.dhcp.run) self.dns_server = DNSServer(self.wlan, self.address) self.dns_thread = threading.Thread(target=self.dns_server.run) self.web_server = WEBServer(self.wlan, self.address) self.web_process = Process(target=self.web_server.run) self.isRunning = False
def fetchAndUpdate(hostname, interfaces, filelocation, sheet_name): sheet_conn = GoogleSheet(filelocation, sheet_name) try: sheet_conn.connect() except: # This can also happen if network is not up yet. So go for retry. # Google Sheet: Authorization Failed. return try: sheet_conn.get_sheet1() except: # Google Sheet: Not found.s raise Exception("Google Sheet '" + sheet_name + "' not available.") # Todo: change code to update all info in one-go. # get all interface detailsa and update. Not one by one. for iface in interfaces: addr = network.get_ip_address(iface) sheet_conn.make_entry_in_gsheet([hostname, iface, addr], [0, 1], 4)