Author Topic: VIXCheck - IP range script needs a few changes!!!  (Read 2838 times)

0 Members and 1 Guest are viewing this topic.

Offline Azmodan

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
VIXCheck - IP range script needs a few changes!!!
« on: 20 October, 2003, 11:00:35 »
Hi guys i have a script that someone(sorry dont know who made it)  made for me.  It reads IP ranges from a txt file and checks to see if the user(on newconnection) has an IP that falls into the IP Range listed in the txt file..

My question is how do i change it from them receiving the message "Non_VIX_IP_Detected!" (if they arnt in the IP list) to stopping them from entering altogether?  It would be better if they never had a chance to enter the hub at all.. but it will have to send them a message once they have been rejected..

The Ranger.dat text looks like:

-----------------------------------
[VIX_IP_Detected!]        <-------this is the msg they get if thier IP falls into this range.
150.101.144.0 - 150.101.159.255
150.101.208.0 - 150.101.223.255
-----------------------------------

the Code is below:


---------------------------------------------------
ipRanges = {}


function compute(ip)

local s, e, a, b, c, d = strfind(ip, "^(%d+).(%d+).(%d+).(%d+)$")

if s then return a*16777216 + b*65536 + c*256 + d end return 0

end


function checkrange(table, ip)

return foreachi(table, function(id, tmp)

if (%ip >= tmp[1]) and (%ip <= tmp[2]) then return tmp end

end)

end


function load(name, data)

ipRanges[name] = ipRanges[name] or {}

gsub(data, "(%S+) %- (%S+)", function(s, e)

s, e = compute(s), compute(e)

tinsert(ipRanges[%name], { s, e })

end)

end


function Main()

local f = openfile("ranger.dat", "r") assert(f, "ranger.dat")

local file = read(f, "*a") closefile(f) gsub(file, "%[(%S+)%]([%c%d%s%-%.]+)", load)

end


function NewUserConnected(user)

local ip, isp = compute(user.sIP)

for name, range in ipRanges do

if checkrange(range, ip) then isp = name break end

end isp = isp or "Non_VIX_IP_Detected!" user:SendData(" "..isp)

end
---------------------------------------------------



Cheers guys ;-)

PtokaX forum

VIXCheck - IP range script needs a few changes!!!
« on: 20 October, 2003, 11:00:35 »

Offline tezlo

  • Triple Ace
  • **
  • Posts: 225
  • Karma: +1/-0
(No subject)
« Reply #1 on: 21 October, 2003, 00:15:40 »
must have been me..
just change the whole NewUserConnected function to
Code: [Select]
function NewUserConnected(user)
local ip, isp = compute(user.sIP)
for name, range in ipRanges do
if checkrange(range, ip) then isp = name break end
end
if isp then user:SendData(" "..isp)
else user:SendData("*** You dont belong here.") user:Disconnect() end
end

Offline Azmodan

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
(No subject)
« Reply #2 on: 22 October, 2003, 11:39:00 »
yep thx Tezlo, btw can i block these users before they enter the hub, NewUserConnected(user) function allows them to enter then disconnects them..


Also this script is designed to check the file for "allowed" IP ranges, how can i modify it so any IP ranges in the file will reject the user?

thx mate
« Last Edit: 22 October, 2003, 12:01:28 by Azmodan »

Offline Azmodan

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
(No subject)
« Reply #3 on: 24 October, 2003, 12:28:31 »
can anyone help me with the above post ????

Offline tezlo

  • Triple Ace
  • **
  • Posts: 225
  • Karma: +1/-0
(No subject)
« Reply #4 on: 24 October, 2003, 21:13:37 »
1. yes.. either with your firewall
or EnableFullData() and check/kick them on $ValidateNick

2. easiest to do would be a special section in ranger.dat
and check it before the "allowed" ranges.. would that do?

Offline c h i l l a

  • Lord
  • ***
  • Posts: 347
  • Karma: +1/-0
(No subject)
« Reply #5 on: 24 October, 2003, 23:48:47 »
good but enablefulldata unless its changed isn't need with validatenick ;).

Offline Azmodan

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
(No subject)
« Reply #6 on: 25 October, 2003, 02:14:55 »
yep that would work well Tezlo, could either make the Ranger.dat file contain only NON allowed ranges OR add both allowed/non allowed!

Offline tezlo

  • Triple Ace
  • **
  • Posts: 225
  • Karma: +1/-0
(No subject)
« Reply #7 on: 25 October, 2003, 06:24:21 »
make a section called [BLOCK] in ranger.dat
and replace NewUserConnected() with this one..
Code: [Select]
function DataArrival(user, data)
if user.bOperator or strsub(data, 1, 13) ~= "$ValidateNick" then return end
local ip, isp = compute(user.sIP)
if not checkrange(ipRanges["BLOCK"], ip) then
for name, range in ipRanges do
if checkrange(range, ip) then return end
end
end user:SendData(denyMsg) user:Disconnect()
end

PtokaX forum

(No subject)
« Reply #7 on: 25 October, 2003, 06:24:21 »