Software /
code /
prosody-modules
Comparison
mod_anti_spam/trie.lib.lua @ 6208:e20901443eae draft
Merge
author | Trần H. Trung <xmpp:trần.h.trung@trung.fun> |
---|---|
date | Mon, 17 Mar 2025 23:42:11 +0700 |
parent | 5883:259ffdbf8906 |
child | 6211:750d64c47ec6 |
comparison
equal
deleted
inserted
replaced
5945:805515dd2960 | 6208:e20901443eae |
---|---|
1 local bit = require "prosody.util.bitcompat"; | 1 local bit = require "util.bitcompat"; |
2 | 2 |
3 local trie_methods = {}; | 3 local trie_methods = {}; |
4 local trie_mt = { __index = trie_methods }; | 4 local trie_mt = { __index = trie_methods }; |
5 | 5 |
6 local function new_node() | 6 local function new_node() |
118 if #existing == 0 then | 118 if #existing == 0 then |
119 self:remove(item); | 119 self:remove(item); |
120 end | 120 end |
121 end | 121 end |
122 | 122 |
123 function trie_methods:has_ip(item) | 123 function trie_methods:contains_ip(item) |
124 item = item.packed; | 124 item = item.packed; |
125 local node = self.root; | 125 local node = self.root; |
126 local len = #item; | 126 local len = #item; |
127 for i = 1, len do | 127 for i = 1, len do |
128 if node.terminal then | 128 if node.terminal then |