Rs2Soft: Eximius - DC++

Please login or register.

Login with username, password and session length
Advanced search  

News:

We are not releasing new version soon.

Author Topic: Confirm DNS 1.0d LUA 5.1x [Strict][Eximius]  (Read 222 times)

0 Members and 1 Guest are viewing this topic.

Mutor

  • RS2Soft Scripter
  • Full Member
  • ****
  • Gender: Male
  • Posts: 130
  • Eximius
    • WWW
Confirm DNS 1.0d LUA 5.1x [Strict][Eximius]
« on: March 10, 2010, 01:07:15 AM »
Not tested much, comments welcome.

Code: [Select]
--[[

Confirm DNS 1.0d LUA 5.1x [Strict][Eximius]

By Mutor 02/21/08

Confirm user logins by hostname [protect users with dynamic IP]


+Changes from 1.0b
+Added report only to available actions.
+Added option to report all connection to ops, requested by philoum
~Updated file/path declaration

+Changes from 1.0c 02/28/10
+Added DNS option in lieu of hostname [for those using DNS systems like no-ip]
-Removed oprion to add online registered users to Protected table  at script start

+Changes from 1.0d 03/09/10
~Converted for use with Eximius 03/09/10
]]


--/ Script Specs, change this and I'll find you and kill you! /--
ScriptDev = "Mutor"
ScriptName = "Confirm DNS"
ScriptVersion = "1.0d"
ScriptDate = "03/09/10"
--//--


local Bot,OpNick,Scp = frmHub:GetHubBotName(),"Mutor","Confirm DNS 1.0d"
-- Add protected nicks and full/partial hostnames as second value or "" as second and DNS as third value
Protect = {
--{"User Nick","WAN or LAN hostname"}
{"Mutor","east.verizon.net","mutor.no-ip.com"},-- Partial [WAN] Host entry
{"[OP]Mutor","","mutor.no-ip.com"},-- Full DNS [WAN] entry
{"Unregistered","THUNDERBIRD"},-- Full [LAN] entry
}
-- Action to take: 0 = none, 1 = disconnect, 2 = redirect, 3 = report only
local Action = 0
-- Redirect address if Action = 2 ["" = *default main redirect address from hub (*must be set)]
local RdAdd = ""
-- Assume hostanme is valid if resolution fails? true/false
local BadHostOk = true
-- Cache addy's to file? true/false
local Save2File = false
-- Path/filename to save user data.
local HostFile = "Hosts.dat"
-- Always report user connections in pm's to ops
local LoginReport = true

Main = function()
Scp = "Confirm DNS 1.0d"
local Path = frmHub:GetStartupPath().."\\Scripts\\"
if not HostFile:find("^"..Path,1,true) then HostFile = Path..HostFile end
if loadfile(HostFile) then
dofile(HostFile)
else
SaveFile(HostFile,Protect,"Protect")
end
if RdAdd:len() == 0 then RdAdd = frmHub:GetRedirectAddress() or "127.0.0.1" end
Action = math.max(1,Action) Action = math.min(2,Action)
SendChatToOps(Bot,Scp.." has been started. Memory usage: "..Mem())
end

OnError = function(msg)
local user = GetUserByName(OpNick)
if user then user:SendData(Bot,msg) end
end

OnExit = function()
SendChatToOps(Bot,Scp.." has been stopped. Freeing "..Mem().." of memory.")
end

NewUserConnected = function(user)
for i,v in ipairs(Protect) do
if user.sName:lower() == v[1]:lower() then
local disallow = true
if v[3] then
local ip = Web:ResolveDns(v[3])
if not ip then
if BadHostOk then disallow = false end
OnError("Dns for: "..user.sName.." resolution of "..v[3].."failed.")
else
if ip == user.sIp then disallow = false end
OnError("Dns: "..user.sName..": "..ip.." / "..v[3])
if LoginReport then
local msg = "User Connected: "..user.sName.."   IP : "..
"[ "..user.sIp.." ]   DNS: ' "..v[3].." '|"
SendPmToOps(Bot,msg)
end
end
else
local host = Web:ReverseDNS(user.sIp)
if not host then
if BadHostOk then disallow = false end
else
if host:lower() == v[2]:lower() or host:lower():find( v[2]:lower(),1,true) then disallow = false end
OnError("Host: "..user.sName..": "..host.." / "..v[2])
if LoginReport then
local msg = "User Connected: "..user.sName.."   IP : "..
"[ "..user.sIp.." ]   Host String: ' "..v[2].." ', Host Name: ' "..host.." '|"
SendPmToOps(Bot,msg)
end
end
end
if disallow and Action > 0 then
local t = {"disconnected","redirected"}
local s = user.sName..", your hostname does not match "..
"our records. You will be "..t[Action]..".|"
if Action == 1 then
user:SendData("<"..Bot.."> "..s.."|")
user:Disconnect()
return 1
elseif Action == 2 then
user:SendData("<"..Bot.."> "..s.."|")
user:Redirect(RdAdd)
return 1
elseif Action == 3 then
local rpt = user.sName.."'s host name has changed from ' "..
v[2].." ' to ' "..host.." '|"
SendPmToOps(Bot,rpt)
end
end
break
end
end
end
OpConnected = NewUserConnected

Serialize = function(tTable, sTableName, hFile, sTab)
sTab = sTab or "";
hFile:write(sTab..sTableName.." = {\n" )
for key, value in ipairs(tTable) do
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key)
if(type(value) == "table") then
Serialize(value, sKey, hFile, sTab.."\t")
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value)
hFile:write( sTab.."\t"..sKey.." = "..sValue)
end
hFile:write( ",\n")
end
hFile:write( sTab.."}")
end

SaveFile = function(file,table, tablename )
local hFile = io.open (file , "wb")
Serialize(table, tablename, hFile)
hFile:close()
end

Mem = function() collectgarbage("collect") return string.format("%-.2f Kb.",collectgarbage("count")) end
« Last Edit: March 10, 2010, 01:50:29 AM by Mutor »
Logged
Respectfully,

Mutor

[ Mutor's Eximius ]

lUk3f1l3w4lK3R

  • Jr. Member
  • **
  • Posts: 63
  • Ňô Ĉŕĕāţĭŏň Ŵĭţĥŏũţ Ďĕŝţŕũĉţĭŏň
Re: Confirm DNS 1.0d LUA 5.1x [Strict][Eximius]
« Reply #1 on: March 10, 2010, 03:03:58 PM »
Also with this script i did some tests.
Didnt get any errors.
Thx Mutor for converting also this script for Eximius.

Good job as allways.
Logged
•••OS: ••• 
•WinXP Pro SP2•
•••Hub: •••
•Eximius 2.1.0•
•••Bots:•••
•NoPubHub•ConfirmDNS•DNSLookup•ClientCheck•FeedWatch•MessageBoard•
•IMDBSearch•MLinkLib•ReaderCommands•Translator•CMDReport•LagCheck•
•PortCheck•TopTen•TopHubbers•ShareTool•Reboot•ASCii-Talk•5 Games•

Yeppy

  • Jr. Member
  • **
  • Gender: Male
  • Posts: 75
  • d(^_^)b
Re: Confirm DNS 1.0d LUA 5.1x [Strict][Eximius]
« Reply #2 on: May 01, 2010, 04:32:22 PM »
Does it work with an ip range instead of dns ?
Logged
Good quality will be known among your ennemies before ever you meet them my friend

Mutor

  • RS2Soft Scripter
  • Full Member
  • ****
  • Gender: Male
  • Posts: 130
  • Eximius
    • WWW
Re: Confirm DNS 1.0d LUA 5.1x [Strict][Eximius]
« Reply #3 on: May 01, 2010, 08:57:27 PM »
No, ISP's get/lose ranges all the time, so that would not be wise.
You may use a partial hostname as often the current IP is included
in that hostname. See examples in the script.
Logged
Respectfully,

Mutor

[ Mutor's Eximius ]
Pages: [1]
« previous next »