IP matching & URL matching



# IP matching
Use case:
1. Visitor country detection. White/black list for internationalization/proxy.

------
- Use radix tree
Data structure: [radix tree](https://en.wikipedia.org/wiki/Radix_tree) 
IP to ASN: [pyasn](https://pypi.python.org/pypi/pyasn) 
[ASN to Country](https://serverfault.com/questions/351123/need-to-find-users-of-asn-in-my-country)
- Convert IP range into integer range and form a interval tree
- Record every valid trail from IP range
Make a valid path decision tree (Trie tree).
- Use Accept-Language header

------
# URL matching
Use case:
1. AD blocking.
1. Smart routing/proxing.

## TODO
Read [ublock](https://github.com/gorhill/uBlock) source code. 
[Adblock Plus matching algorithms](https://adblockplus.org/blog/investigating-filter-matching-algorithms)  posted 2006, last reply 2010. 
ABP [a simpler algorithm with even better performance characteristics](https://adblockplus.org/development-builds/faster-filter-matching-algorithm) 2010. 
ABP [matcher.js](https://adblockplus.org/jsdoc/adblockpluscore/matcher.js.html) source code. 
## Thoughts
1. Domain-subfix then Trie match
1. Domain-contains then KMP search

评论

此博客中的热门博文

Windows下ShadowSocks客户端安装和配置 顺带KCP

How to Install KeePass on M1 Mac

How User Friendly is a MacOS