def make_subnet(clientipaddress, clientmask): "Returns a subnet string" if clientmask != "32": broadcast_address, network_address = ipv4.parse(clientipaddress, clientmask) return network_address else: return clientipaddress
def validate_listenipaddress(listenipaddress): """Check listenipaddress""" if not listenipaddress or listenipaddress == "0.0.0.0": return True, None broadcast_address, network_address = ipv4.parse(listenipaddress, 32) if not broadcast_address: return False, "Server listen ip address is not valid" return True, None
def validate_client_ip_mask(clientipaddress, clientmask): """Check clientipaddress and clientmask""" broadcast_address, network_address = ipv4.parse(clientipaddress, clientmask) if not broadcast_address: return False, "Client ip address and mask do not make a valid subnet" return True, None