Exemplo n.º 1
0
 def get_or_add_object(self):
     object = self.device.get_object(self.get_object_name())
     object_exists = object != None
     if not object_exists:
         object = device.Object()
         self.device.add_object(object)
     return object
Exemplo n.º 2
0
 def get_nat_service(self, service_protocol, service_name):
     if service_name == None:
         return None
     service = self.parser.device.get_object(service_name)
     if service == None:
         service = device.Object()
         service.type = device.ObjectType.SERVICE
         service.protocol = service_protocol
         service.src_port = service_name
         if service_protocol == None:
             self.parser.error(
                 f'Service object "{service_name}" not found.')
     return service
Exemplo n.º 3
0
    def get_nat_addr(self, nat, addr, object_name):
        if addr != None:
            nat_addr = device.Object(addr=device.Addr(addr))
        elif object_name == 'interface':
            nat_addr = device.Object(nat.outside_interface.custom_name)
            nat_addr.addr = nat.outside_interface.primary_addr()
            if nat_addr.addr == None:
                self.parser.error(
                    f'Interface "{nat.outside_interface.custom_name}" '
                    'used in nat without primary address.')
        elif object_name == 'any':
            nat_addr = device.Object('any')
            nat_addr.addr = device.Addr('0.0.0.0', 0)
        else:
            nat_addr = self.parser.device.get_object(object_name)
            if nat_addr == None:
                nat_addr = device.Object(object_name)
                self.parser.error(f'Network object "{object_name}" '
                                  'not found.')

        if nat_addr.type == None:
            nat_addr.type = device.ObjectType.NETWORK
        return nat_addr
Exemplo n.º 4
0
 def __init__(self, parser, object=None):
     self.parser = parser
     self.object = object
     if self.object == None:
         self.object = device.Object()