Home > Uncategorized > Verlihub: отключаем поиск акадовцам

Verlihub: отключаем поиск акадовцам

February 19th, 2009 Leave a comment Go to comments

Дабы не грузить исходящий канал бесполезными запросами на поиск от акадовцев, пишем небольшой lua скрипт:

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
aRange = {
["127.0.0.1-127.0.0.255"] = 1,
["10.128.0.1-10.128.255.254"] = 1,
["10.129.0.1-10.129.255.254"] = 1,
["10.130.0.1-10.130.255.254"] = 1,
["192.168.0.1-192.168.255.254"] = 1,
["213.79.108.1-213.79.111.254"] = 1,
["172.16.127.1-172.16.127.255"] = 1,
}
 
function VH_OnParsedMsgSearch(nick,data)
 
    res, myinfo = VH:GetMyINFO(nick)
    _, _, sharess = string.find(myinfo,"(%d+)$$")
    _, ip = VH:GetUserIP(nick)
 
    local Allow,Range = Func.CheckIP(GetIP(nick))
 
    if (Allow == 0) then
        VH:SendDataToUser("$To: Case From: Verlihub $<VerliHub> user: "..nick..", data: "..data.."", "Case")
        return 0
    else
        VH:SendDataToUser("$To: Case From: Verlihub $<VerliHub> user: "..nick..", data: "..data.."", "Case")
        return 1
    end
end
 
Func = {}
 
Func.ComIP = function(curIP)
    local _,_,a,b,c,d = string.find(curIP, "(%d+).(%d+).(%d+).(%d+)")
    return a*16777216 + b*65536 + c*256 + d
end
 
Func.CheckIP = function(curIP)
    local _,_,a,b,c,d = string.find(curIP, "(%d*).(%d*).(%d*).(%d*)")
    if ( tonumber(a) and tonumber(b) and tonumber(c) and tonumber(d) ) then
        local UserIP = Func.ComIP(curIP)
        if UserIP then
            for Range, Table in pairs(aRange) do
                local _,_,R1,R2 = string.find(Range, "(%S+)-(%S+)")
                Range1 = Func.ComIP(R1)
                Range2 = Func.ComIP(R2)
                if UserIP >= Range1 and UserIP <= Range2 then
                    return 1,Range
                end
            end
        end
    end
    return 0
end
 
function GetIP(sNick)
    res, ip = VH:GetUserIP(sNick)
    return ip
end

Кладем скрипт в файл /usr/local/etc/verlihub/scripts/search.lua и в чате dc набираем команду:

1
!luaload /usr/local/etc/verlihub/scripts/search.lua
Tags: ,
  1. No comments yet.
  1. No trackbacks yet.