All Projects → Phineas → domain-lookup-tree

Phineas / domain-lookup-tree

Licence: MPL-2.0 license
A tree structure in Rust optimized for looking up domain names, with wildcard support

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to domain-lookup-tree

Acl4ssr
SSR 去广告ACL规则/SS完整GFWList规则/Clash规则碎片,Telegram频道订阅地址
Stars: ✭ 6,960 (+40841.18%)
Mutual labels:  acl, acl-rules
emqx-auth-mysql
Authentication, ACL with MySQL Database
Stars: ✭ 52 (+205.88%)
Mutual labels:  acl
daemonize-me
Rust library to ease the task of creating daemons
Stars: ✭ 34 (+100%)
Mutual labels:  rust-crate
browser-acl
Simple acceess control (ACL) library for the browser inspired by Laravel's guards and policies.
Stars: ✭ 36 (+111.76%)
Mutual labels:  acl
sqlalchemy-adapter
SQLAlchemy Adapter for PyCasbin
Stars: ✭ 53 (+211.76%)
Mutual labels:  acl
linguistic-style-transfer-pytorch
Implementation of "Disentangled Representation Learning for Non-Parallel Text Style Transfer(ACL 2019)" in Pytorch
Stars: ✭ 55 (+223.53%)
Mutual labels:  acl
objection-authorize
isomorphic, "magical" authorization integration with Objection.js 🎉
Stars: ✭ 71 (+317.65%)
Mutual labels:  acl
CoSky
High-performance, low-cost microservice governance platform. Service Discovery and Configuration Service | 高性能、低成本微服务治理平台
Stars: ✭ 57 (+235.29%)
Mutual labels:  dns
balboa
server for indexing and querying passive DNS observations
Stars: ✭ 42 (+147.06%)
Mutual labels:  dns
Acl
The Hoa\Acl library.
Stars: ✭ 27 (+58.82%)
Mutual labels:  acl
simdutf8
SIMD-accelerated UTF-8 validation for Rust.
Stars: ✭ 426 (+2405.88%)
Mutual labels:  rust-crate
laminas-permissions-acl
Provides a lightweight and flexible access control list (ACL) implementation for privileges management
Stars: ✭ 29 (+70.59%)
Mutual labels:  acl
opentab
开源的轻应用后端(Open Tiny App Backend),轻量,高效,易部署。
Stars: ✭ 27 (+58.82%)
Mutual labels:  acl
DPDK SURICATA-4 1 1
dpdk infrastructure for software acceleration. Currently working on RX and ACL pre-filter
Stars: ✭ 81 (+376.47%)
Mutual labels:  acl
A-Persona-Based-Neural-Conversation-Model
No description or website provided.
Stars: ✭ 22 (+29.41%)
Mutual labels:  acl
zf3-circlical-user
Turnkey Authentication, Identity, and RBAC for Laminas and Zend Framework 3. Supports Doctrine and Middleware.
Stars: ✭ 35 (+105.88%)
Mutual labels:  acl
sqlx-adapter
Asynchronous casbin adapter for mysql, postgres, sqlite based on sqlx-rs
Stars: ✭ 27 (+58.82%)
Mutual labels:  acl
ansible-role-dns
Install and configure dns on your system.
Stars: ✭ 39 (+129.41%)
Mutual labels:  dns
position-rank
PositionRank: An Unsupervised Approach to Keyphrase Extraction from Scholarly Documents
Stars: ✭ 89 (+423.53%)
Mutual labels:  acl
crates-io-cn
Source code of crates-io.cn, also tools sets for sync crates.io
Stars: ✭ 20 (+17.65%)
Mutual labels:  rust-crate

domain-lookup-tree

Overview

DomainLookupTree is a data structure which provides efficient domain name lookup matching with support for wildcard entries.

Requirements for this implementation:

  • Given a domain name, determine if it matches an entry in the tree
  • There can be an ever-growing amount of tree entries
  • Entries can be absolute matches, e.g.: www.google.com
  • Entries may be wildcard entries, which is denoted in the entry by providing a leading dot, e.g.: .twitter.com, .en.wikipedia.org, .giggl.app
  • Wildcard entries can not be embedded

To achieve this, we implement a simple tree-style structure which has a root structure that contains a HashMap of nodes. These nodes can then contain other node decendants, and also be marked as "wildcard" which means theres a rule that matches that domain level and all of its decendants.

If, when performing a lookup, the domain contains segments deeper than the wildcard match, it can continue to traverse the tree until it exhausts its lookup options. At that point, the deepest wildcard entry found would be returned, if no absolute match was found.

It's good to keep in mind that, when traversing the tree, domain names are sorted by top level to infinite n-level, or in simpler terms, in reverse. This means that if "google.com" is looked up in the tree, it would split by ".", reverse the vector, then first perform a root node lookup for "com", and so on.

Walking down the tree - the story of a lookup: Let's say have a DomainLookupTree with an entry ".giggl.app" which means that the tree looks like this:

app
└── giggl [wildcard]

A rule lookup for "canary.giggl.app" is requested. First, "app" is matched, but it's not a wildcard, so it's ignored. We now check the decendants of "app" for "giggl" - it matches, and it's a wildcard match, so we store it within the context of the lookup. This lookup will now 100% return a match, even if it isn't absolute. Anyway, we now check the decendants of "giggl" for "canary", though it doesn't exist, and the traversal ends. Now, we didn't have an absolute match, but we did have a wildcard match earlier on for ".giggl.app", so we successfully return the result ".giggl.app" from the lookup function.

Usage

First, add domain-lookup-tree to your Cargo.toml:

[dependencies]
domain-lookup-tree = "0.1"

Now you can import and use the domain_lookup_tree::DomainLookupTree type:

extern crate domain_lookup_tree;
use domain_lookup_tree::DomainLookupTree;

let mut tree = DomainLookupTree::new();

// Insert some domains

tree.insert(".google.com"); // prefix with a dot to denote a wildcard entry
tree.insert("api.twitter.com");
tree.insert("phineas.io");

// Perform lookups

tree.lookup("www.google.com");
// => Some(".google.com")

tree.lookup("twitter.com");
// => None

tree.lookup("api.twitter.com");
// => Some("api.twitter.com")
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].