{"id":18078284,"url":"https://github.com/imthaghost/blacklister","last_synced_at":"2025-10-24T17:32:52.736Z","repository":{"id":101601140,"uuid":"258331627","full_name":"imthaghost/blacklister","owner":"imthaghost","description":"A radix tree implementation of a IPv4/IPv6 blacklisting application ","archived":false,"fork":false,"pushed_at":"2020-05-15T15:03:40.000Z","size":19,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-11T20:50:59.522Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imthaghost.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-23T21:11:32.000Z","updated_at":"2021-07-14T09:28:32.000Z","dependencies_parsed_at":"2023-06-06T09:45:48.806Z","dependency_job_id":null,"html_url":"https://github.com/imthaghost/blacklister","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imthaghost%2Fblacklister","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imthaghost%2Fblacklister/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imthaghost%2Fblacklister/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imthaghost%2Fblacklister/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imthaghost","download_url":"https://codeload.github.com/imthaghost/blacklister/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399818,"owners_count":20932875,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-31T12:13:27.881Z","updated_at":"2025-10-24T17:32:52.630Z","avatar_url":"https://github.com/imthaghost.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n Simply use a radix tree to blacklist ip addresses \n\u003c/p\u003e\n\u003c!-- \u003cp align=\"center\"\u003e\n   \u003ca href=\"https://goreportcard.com/report/github.com/imthaghost/goclone\"\u003e\u003cimg src=\"https://goreportcard.com/badge/github.com/imthaghost/goclone\"\u003e\u003c/a\u003e\n   \u003ca href=\"https://github.com/imthaghost/gitmoji-changelog\"\u003e\n    \u003cimg src=\"https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg\"alt=\"gitmoji-changelog\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e --\u003e\n\u003cbr\u003e\n\n\n\n## Examples\n\n```python\n\tfrom radix import radix\n\n\t# Create a new tree\n\trtree = radix.Radix()\n\n\t# Adding a node returns a RadixNode object. You can create\n\t# arbitrary members in its 'data' dict to store your data\n\trnode = rtree.add(\"10.0.0.0/8\")\n\trnode.data[\"blah\"] = \"whatever you want\"\n\n\t# You can specify nodes as CIDR addresses, or networks with\n\t# separate mask lengths. The following three invocations are\n\t# identical:\n\trnode = rtree.add(\"10.0.0.0/16\")\n\trnode = rtree.add(\"10.0.0.0\", 16)\n\trnode = rtree.add(network = \"10.0.0.0\", masklen = 16)\n\n\t# It is also possible to specify nodes using binary packed\n\t# addresses, such as those returned by the socket module\n\t# functions. In this case, the radix module will assume that\n\t# a four-byte address is an IPv4 address and a sixteen-byte\n\t# address is an IPv6 address. For example:\n\tbinary_addr = inet_ntoa(\"172.18.22.0\")\n\trnode = rtree.add(packed = binary_addr, masklen = 23)\n\n\t# Exact search will only return prefixes you have entered\n\t# You can use all of the above ways to specify the address\n\trnode = rtree.search_exact(\"10.0.0.0/8\")\n\t# Get your data back out\n\tprint rnode.data[\"blah\"]\n\t# Use a packed address\n\taddr = socket.inet_ntoa(\"10.0.0.0\")\n\trnode = rtree.search_exact(packed = addr, masklen = 8)\n\n\t# Best-match search will return the longest matching prefix\n\t# that contains the search term (routing-style lookup)\n\trnode = rtree.search_best(\"10.123.45.6\")\n\n\t# Worst-search will return the shortest matching prefix\n\t# that contains the search term (inverse routing-style lookup)\n\trnode = rtree.search_worst(\"10.123.45.6\")\n\n\t# Covered search will return all prefixes inside the given\n\t# search term, as a list (including the search term itself,\n\t# if present in the tree)\n\trnodes = rtree.search_covered(\"10.123.0.0/16\")\n\n\t# There are a couple of implicit members of a RadixNode:\n\tprint rnode.network\t# -\u003e \"10.0.0.0\"\n\tprint rnode.prefix\t# -\u003e \"10.0.0.0/8\"\n\tprint rnode.prefixlen\t# -\u003e 8\n\tprint rnode.family\t# -\u003e socket.AF_INET\n\tprint rnode.packed\t# -\u003e '\\n\\x00\\x00\\x00'\n\n\t# IPv6 prefixes are fully supported in the same tree\n\trnode = rtree.add(\"2001:DB8::/3\")\n\trnode = rtree.add(\"::/0\")\n\n\t# Use the nodes() method to return all RadixNodes created\n\tnodes = rtree.nodes()\n\tfor rnode in nodes:\n\t\tprint rnode.prefix\n\n\t# The prefixes() method will return all the prefixes (as a\n\t# list of strings) that have been entered\n\tprefixes = rtree.prefixes()\n\n\t# You can also directly iterate over the tree itself\n\t# this would save some memory if the tree is big\n\t# NB. Don't modify the tree (add or delete nodes) while\n\t# iterating otherwise you will abort the iteration and\n\t# receive a RuntimeWarning. Changing a node's data dict\n\t# is permitted.\n\tfor rnode in rtree:\n  \t\tprint rnode.prefix\n```\n## 📝 License\n\nBy contributing, you agree that your contributions will be licensed under its MIT License.\n\nIn short, when you submit code changes, your submissions are understood to be under the same [MIT License](http://choosealicense.com/licenses/mit/) that covers the project. Feel free to contact the maintainers if that's a concern.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimthaghost%2Fblacklister","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimthaghost%2Fblacklister","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimthaghost%2Fblacklister/lists"}