Ejemplo n.º 1
0
    def get_roa(self, ip_address: str):
        """Gets the ROA of the route/prefix containing the given IP address.

        Args:
            ip_address (str): The IP address to lookup.
        """
        if not bogons.is_public_ip(ip_address):
            raise ValueError(f"{ip_address} is not a public IP address")

        endpoint = "roa"
        resp = self._bgpstuff_request(f"{endpoint}/{ip_address}")

        self.roa = resp["Response"]["ROA"]
Ejemplo n.º 2
0
    def get_origin(self, ip_address: str):
        """Gets the origin AS for the given IP address.

        Args:
            ip_address (str): The IP address to lookup.
        """
        if not bogons.is_public_ip(ip_address):
            raise ValueError(f"{ip_address} is not a public IP address")

        endpoint = "origin"
        resp = self._bgpstuff_request(f"{endpoint}/{ip_address}")

        self.origin = resp["Response"]["Origin"]
Ejemplo n.º 3
0
    def get_route(self, ip_address: str):
        """Gets the rib entry for the given IP address.

        Args:
            ip_address (str): The IP address to lookup.
        """
        if not bogons.is_public_ip(ip_address):
            raise ValueError(f"{ip_address} is not a public IP address")

        endpoint = "route"
        resp = self._bgpstuff_request(f"{endpoint}/{ip_address}")

        self.route = resp["Response"]["Route"]
Ejemplo n.º 4
0
    def get_as_path(self, ip_address: str):
        """Gets the AS_PATH to the given IP address.

        Args:
            ip_address (str): The IP address to lookup.
        """
        if not bogons.is_public_ip(ip_address):
            raise ValueError(f"{ip_address} is not a public IP address")

        endpoint = "aspath"
        resp = self._bgpstuff_request(f"{endpoint}/{ip_address}")

        self.as_path = resp["Response"]["ASPath"]

        if "ASSet" in resp["Response"]:
            self.as_set = resp["Response"]["ASSet"]
Ejemplo n.º 5
0
    def get_roa(self, ip_address: str):
        """Gets the ROA of the route/prefix containing the given IP address.

        Args:
            ip_address (str): The IP address to lookup.

        Returns:
            roa (str): The AS_PATH to the prefix this IP belongs to.
        TODO: Combine with self.get_as_path()
        """
        if not bogons.is_public_ip(ip_address):
            raise ValueError(f"{ip_address} is not a public IP address")

        endpoint = "roa"
        resp = self._bgpstuff_request(f"{endpoint}/{ip_address}")

        self.roa = resp["Response"]["ROA"]
Ejemplo n.º 6
0
    def get_as_path(self, ip_address: str):
        """Gets the AS_PATH to the given IP address.

        Args:
            ip_address (str): The IP address to lookup.

        Returns:
            as_path (list): The AS_PATH to the prefix this IP belongs to.
        TODO: Combine with self.get_as_set()
        """
        if not bogons.is_public_ip(ip_address):
            raise ValueError(f"{ip_address} is not a public IP address")

        endpoint = "aspath"
        resp = self._bgpstuff_request(f"{endpoint}/{ip_address}")

        self.as_path = resp["Response"]["ASPath"]
        self.as_set = resp["Response"]["ASSet"]