forked from jperon/lunatik_snihook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dev.moon
31 lines (26 loc) · 863 Bytes
/
dev.moon
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
-- SPDX-FileCopyrightText: (c) 2024 jperon <cataclop@hotmail.com>
-- SPDX-License-Identifier: MIT OR GPL-2.0-only
:new = require"device"
:map = require"rcu"
_true = require"data".new 1
stat: {:IRUSR, :IWUSR} = require"linux"
:log_level = require"snihook.config"
logger = require"log"
:concat, :sort = table
nop = -> -- Do nothing
(whitelist) ->
log = logger log_level, "snihook"
read = ->
lst = {}
map whitelist, => lst[#lst+1] = @
sort lst
concat(lst, ",") .. "\n"
write = (s) =>
for action, domain in s\gmatch"(%S+)%s(%S+)"
if action == "+"
whitelist[domain] = _true
log.info"Added #{domain} to whitelist"
elseif action == "-"
whitelist[domain] = nil
log.info"Removed #{domain} from whitelist"
new name: "sni_whitelist", mode: (IRUSR | IWUSR), open: nop, release: nop, :read, :write