Package: roa-checker
roa_checkerThis package contains a trie of ROAs for fast prefix-origin pair lookupsUsageInstallationTestingDevelopment/ContributingHistoryLicenceUsageroa_checkerfromipaddressimportip_networkfromroa_checkerimportROAChecker,ROARouted,ROAValiditydeftest_tree():# TODO: Break up into unit teststrie=ROAChecker()cidrs=[ip_network(x)forxin["1.2.0.0/16","1.2.3.0/24","1.2.3.4"]]routed_origin=1forcidrincidrs:trie.insert(cidr,routed_origin,cidr.prefixlen)forcidrincidrs:asserttrie.get_roa(cidr,routed_origin).prefix==cidrvalidity,routed=trie.get_validity(cidr,routed_origin)assertvalidity,routed==(ROAValidity.VALID,ROARouted.ROUTED,)assertROAValidity.is_unknown(validity)isFalseassertROAValidity.is_invalid(validity)isFalseassertROAValidity.is_valid(validity)isTruenon_routed_cidrs=[ip_network(x)forxin["2.2.0.0/16","2.2.3.0/24","2.2.3.4"]]non_routed_origin=0forcidrinnon_routed_cidrs:trie.insert(cidr,non_routed_origin,cidr.prefixlen)forcidrinnon_routed_cidrs:asserttrie.get_roa(cidr,non_routed_origin).prefix==cidrasserttrie.get_validity(cidr,routed_origin)==(ROAValidity.INVALID_ORIGIN,ROARouted.NON_ROUTED,)validity,routed=trie.get_validity(ip_network("1.0.0.0/8"),routed_origin)assertvalidity==ROAValidity.UNKNOWNassertrouted==ROARouted.UNKNOWNvalidity,routed=trie.get_validity(ip_network("255.255.255.255"),routed_origin)assertvalidity==ROAValidity.UNKNOWNassertrouted==ROARouted.UNKNOWNassertROAValidity.is_unknown(validity)isTrueassertROAValidity.is_invalid(validity)isFalseassertROAValidity.is_valid(validity)isFalsevalidity,routed=trie.get_validity(ip_network("1.2.4.0/24"),routed_origin)assertvalidity==ROAValidity.INVALID_LENGTHassertrouted==ROARouted.ROUTEDassertROAValidity.is_unknown(validity)isFalseassertROAValidity.is_invalid(validity)isTrueassertROAValidity.is_valid(validity)isFalsevalidity,routed=trie.get_validity(ip_network("1.2.3.0/24"),routed_origin+1)assertvalidity==ROAValidity.INVALID_ORIGINassertrouted==ROARouted.ROUTEDassertROAValidity.is_unknown(validity)isFalseassertROAValidity.is_invalid(validity)isTrueassertROAValidity.is_valid(validity)isFalsevalidity,routed=trie.get_validity(ip_network("1.2.4.0/24"),routed_origin+1)assertvalidity==ROAValidity.INVALID_LENGTH_AND_ORIGINassertrouted==ROARouted.ROUTEDassertROAValidity.is_unknown(validity)isFalseassertROAValidity.is_invalid(validity)isTrueassertROAValidity.is_valid(validity)isFalsevalidity,routed=trie.get_validity(ip_network("1.2.0.255"),routed_origin)assertvalidity==ROAValidity.INVALID_LENGTHassertrouted==ROARouted.ROUTEDvalidity,routed=trie.get_validity(ip_network("1.3.0.0/16"),routed_origin)assertvalidity==ROAValidity.UNKNOWNassertrouted==ROARouted.UNKNOWNvalidity,routed=trie.get_validity(ip_network("1.2.0.255"),routed_origin)assertvalidity==ROAValidity.INVALID_LENGTHassertrouted==ROARouted.ROUTEDInstallationroa_checkerInstall python and pip if you have not already. Then run:pip3installroa_checkerThis will install the package and all of it's python dependencies.If you want to install the project for development:gitclonehttps://github.com/jfuruness/roa_checker.gitcdroa_checker
pip3install-e.[test]pre-commitinstallTo test the development package:TestingTestingroa_checkerAfter installation for development:cdroa_checker
python3-mpytestroa_checkerTo run all tests:toxDevelopment/Contributingroa_checkerFork it!Create your feature branch:git checkout -b my-new-featureCommit your changes:git commit -am 'Add some feature'Push to the branch:git push origin my-new-featureSubmit a pull requestEmail me atjfuruness@gmail.comif I don't see it after a whileHistoryroa_checker1.1.3 Dependency updates1.1.2 Added ROA to top level import1.1.1 mypy and linter fixes1.1.0 Updated test deps1.0.0 Updated package structure, typing, linters, etc, made ROAValidity contains multiple invalid types0.0.1 First working versionLicenseroa_checkerBSD License (see license file)