PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Morbid on 25 March, 2004, 17:40:08

Title: Block Client
Post by: Morbid on 25 March, 2004, 17:40:08
I have  ran a search and have not found what I am looking for, if there is a post in here about this than I am sorry I overlooked it...


This may sound strange to you guys...but anyone have a script that will block NMDC (all versions)...I would rather it pop up in pm telling them that their client is not allowed in my hub and to go to http://sourceforge.net/projects/dcplusplus/ and update. The reason is that most my users run zdc++ and  and the two clients do not like each other...

Thank you for your time.
Title:
Post by: nErBoS on 26 March, 2004, 02:46:18
Hi,

Which clients do you accept in your Hub ???

Best regards, nErBoS
Title:
Post by: Morbid on 26 March, 2004, 12:24:32
Actually I am not sure all the names of the clients...I know I do accept Rev-Connect, Zdc++,Cdz++,bcdc++,dc++..there are others....I just do not know them I think Odc is another...but not too sure...I tried the settings in ptokax but they don't seem to work, and they reset themselves on hub restart. There has to be a way to block just NMDC I just can't figure it out...

Sorry I cannot be too specific...
Title:
Post by: majinsoftware on 26 March, 2004, 21:24:42
no sure who made it but i found it in a zip of hundreds of scripts. i made a few changes for my hub but it should work.

---------------------------------------------------------------------
kb = 1024
gb = kb*kb*kb
tb = kb*kb*kb*kb
---------------------------------------------------------------------
Bot = "Z-LeZ"

--Level Checks / 1:on/0:off

LC = {
  • = 0,   -- Check Masters
  • [1] = 0,   -- Check Operators
    [2] = 0,   -- Check VIPs
    [3] = 1,   -- Check REGs
    [-1] = 1,   -- Check Users
    }

    -- Client Settings
    -------------------------------------------------
    -- Allow Clients / 1:on/0:off
    AllowDCPP = 1      -- DC++
    AllowODC = 1         -- oDC
    AllowNMDC2 = 0      -- Neo Modus DC 2
    AllowDCGUI = 1      -- DCGUI
    AllowDCPRO = 0      -- DC:PRO
    AllowBCDC = 0      -- BCDC++
    AllowCZDC = 1      -- CZDC++
    AllowPDC = 0         -- Phantom DC++
    AllowIDC = 1         -- Italian DC++
    AllowNOTAG = 0      -- No Tag Client ex: Neo Modus DC 1
    AllowFAKE = 0         -- Fake Client (Fake Taging)

    -- Client Settings
    MinSlots = 1      -- Min Slots
    MaxSlots = 99      -- Max Slots
    MaxHubs = 40      -- Max Hubs for users
    LockBW = 2      -- Min Bandwidh Lock

    -- Version Checks
    DCPPver = "0.201"         -- DC++ Min. Version
    ODCver = "5.2"         -- oDC Min. Version
    NMDC2ver = "2.02"      -- Neo Modus DC 2 Min. Version
    DCPROver = "0.2.2.10"      -- DC:PRO Min. Version
    DCGUIver = "0.2.20"      -- DCGUI Min. Version
    IDCver = "1.03"         -- Italian DC++ Min. Version
    nDCver = "0.300"         -- nDC++ Min. Version

    ---------------------------------------------------------------------

    ClientTAG = {
    { "<%+%+","oDC" },
    { "{ "<%+%+","DC++" },
    { "{ "{ "http://dc.ketelhot.de","DCGUI" },
    { "{ "{ "zDC++[","zDC++" },
    { "","MS++V" },
    { "","MS++V" },
    { "{ "<.P>","Phantom DC++" },
    }


    function DataArrival(curUser,data)
       if (strsub(data,1,7) == "$MyINFO") then
          local vClient, vTag, vSpeed, vShare = ParseMyInfo(data)
          AllowClients(curUser,vClient,vTag)
       end
    end

    function ParseMyInfo(MyInfo)
       local vClient = "Unknown"
       local Bwidh = ""
       local _,_,vSpeed,sShare = strfind( MyInfo, "^%$MyINFO %$ALL [^ ]+ [^$]*%$ $([^$]+)[^$]%$[^$]*%$%s*(%d+)%$" )
       local vShare = tonumber(sShare)
          
       for i = 1,getn(ClientTAG) do
          if strfind(MyInfo,ClientTAG
[1]) then
         vClient = ClientTAG[2]
      end
   end
   
   local Version = ""
   local _,_,Slots = strfind( MyInfo, "S:(%d+)")
   local _,_,Mode = strfind( MyInfo, "M:([S,A,P])")
   local _,_, DcVer = strfind(MyInfo,"V:(%x+.%x+)")
   Version = DcVer
   if strfind(MyInfo,"      local _,_,oDCVer = strfind(MyInfo,"")
      Version = oDCVer
      vClient = "oDC"
   elseif vClient=="Italian DC++" then
      local _,_,IDCVer = strfind(MyInfo,"")
      Version = IDCVer
   end

   local Hubs = ""
   local Regged = ""
   local Opped = ""
   local _,_, gethub = strfind(MyInfo,"H:(%x+)/")
   if gethub == nil then
      _,_, Hubs = strfind(MyInfo,"H:(%x+)")
      Regged = 0
      Opped = 0
   else
      Hubs = gethub
      _,_, Regged = strfind(MyInfo,"H:%x+/(%x+)/")
      _,_, Opped = strfind(MyInfo,"H:%x+/%x+/(%x+)")
   end
   
   if strfind(MyInfo,"H:\"%d+/%d+/%d+\",S") then
      vClient = "Fake Client"
      _,_,Hubs,Regged,Opped = strfind(MyInfo,"H:\"(%x+)/(%x+)/(%x+)\"")
   end

   if strfind( MyInfo,"V:%S+(k),M") then vClient = "DC++k" end

   
   if strfind(MyInfo, "L:") then
      local _,_,Ls = strfind(MyInfo , "L:(%d+)")
      Bwidh = Ls
      vClient = "CZDC++"
   elseif strfind(MyInfo, "B:") then
      local _,_,Bs = strfind(MyInfo , "B:(%d+)")
      Bwidh = Bs
      if not vClient=="Phantom DC++" then
         vClient = "BCDC++"
      end
   elseif strfind(MyInfo, "F:") then
      local _,_,Fs = strfind(MyInfo , "F:%d+/(%d+)")
      Bwidh = Fs
   else
      Bwidh = "unlimited"
   end

   if Version == nil then Version = "0" end
   if Mode == nil then Mode = "0" end
   if Hubs == nil then Hubs = "0" end
   if Slots == nil then Slots = "0" end

   tMode = {
   ["S"] = "Socks",
   ["A"] = "Active",
   ["P"] = "Passive",
   ["0"] = "N/A",
   }
   vTag = { ["H"] = Hubs, ["S"] = Slots, ["B"] = Bwidh,["V"] = Version, ["M"] = tMode[Mode], ["RH"] = Regged,  ["OH"] = Opped}
   return vClient, vTag, vSpeed, vShare
end

function AllowClients(curUser,vClient,vTag)
   if (LC[curUser.iProfile]==1) then
      if (vClient =="oDC" and AllowODC==1) then
         CheckSlotsHubs(curUser,vTag)
         VersionCheck(curUser,vClient,vTag,ODCver,"http://gempond.com/odc")
         BandwidhCheck(curUser,vTag)
      elseif (vClient =="DC++" and AllowDCPP==1) then
         CheckSlotsHubs(curUser,vTag)
         VersionCheck(curUser,vClient,vTag,DCPPver,"http://dcplusplus.sourceforge.net")
         BandwidhCheck(curUser,vTag)
      elseif (vClient =="DC:PRO" and AllowDCPRO==1) then
         CheckSlotsHubs(curUser,vTag)
         VersionCheck(curUser,vClient,vTag,DCPROver,"http://btpro.altervista.org/index.php")
         BandwidhCheck(curUser,vTag)
      elseif (vClient =="DCGUI" and AllowDCGUI==1) then
         CheckSlotsHubs(curUser,vTag)
         VersionCheck(curUser,vClient,vTag,DCGUIver,"http://dc.ketelhot.de")
         BandwidhCheck(curUser,vTag)
      elseif (vClient =="NeoModus 2" and AllowNMDC2==1) then
         CheckSlotsHubs(curUser,vTag)
         VersionCheck(curUser,vClient,vTag,NMDC2ver,"http://neo-modus.com")
         BandwidhCheck(curUser,vTag)
      elseif (vClient =="BCDC++" and AllowBCDC==1)  then
         CheckSlotsHubs(curUser,vTag)
         VersionCheck(curUser,vClient,vTag,DCPPver,"http://utrum.dyndns.org:8000/index.html")
         BandwidhCheck(curUser,vTag)
      elseif (vClient =="CZDC++" and AllowCZDC==1) then
         CheckSlotsHubs(curUser,vTag)
         VersionCheck(curUser,vClient,vTag,DCPPver,"http://www.czdcplusplus.tk/")
         BandwidhCheck(curUser,vTag)
      elseif (vClient =="Phantom DC++" and AllowPDC==1) then
         CheckSlotsHubs(curUser,vTag)
         VersionCheck(curUser,vClient,vTag,DCPPver,"http://pdc.recoil.net.nz/index.php")
         BandwidhCheck(curUser,vTag)
      elseif (vClient =="Italian DC++" and AllowIDC==1) then
         CheckSlotsHubs(curUser,vTag)
         VersionCheck(curUser,vClient,vTag,IDCver,"http://www.p2pitalia.com/")
         BandwidhCheck(curUser,vTag)

      elseif (vClient =="Fake Client" and AllowFAKE==1) then
         CheckSlotsHubs(curUser,vTag)
         VersionCheck(curUser,vClient,vTag,DCPPver,"http://dcplusplus.sourceforge.net")
         BandwidhCheck(curUser,vTag)
      elseif (vClient =="Unknown" and AllowNOTAG==1) then

      elseif (vClient =="Fake Client" and AllowFAKE==0) then
         curUser:SendData(BotName,curUser.sName.." you are using a fake tag or client!")
         curUser:Disconnect()
      elseif (vClient =="Unknown" and AllowNOTAG==0) then
         curUser:SendData(BotName,curUser.sName.." you are using a client with no tag!")
         curUser:Disconnect()
      else
         SendPmToNick(curUser.sName, "Client Blocker", " Your DC Cleint isnt wanted here please get another one E.G MS++V at http://www.computec.dynu.com/MS++V/")
         curUser:Disconnect()
      end
   end
end

function CheckSlotsHubs(curUser,vTag)
   if (vTag["S"] == "N/A" or vTag["H"] == "N/A") then
   elseif (tonumber(vTag["S"]) < MinSlots) then
         SendPmToNick(curUser.sName, BotName,"You have too litle slots open ( "..vTag["S"].." ) Minimum slots is ( "..MinSlots.." ). ")
      curUser:Disconnect()
   elseif (tonumber(vTag["S"]) > MaxSlots) then
         SendPmToNick(curUser.sName, BotName,"You have too many slots open ( "..vTag["S"].." ) Maximum slots is ( "..MaxSlots.." ). ")
      curUser:Disconnect()
   elseif (tonumber(vTag["H"]) > MaxHubs) then
         SendPmToNick(curUser.sName, BotName,"You are in too many hubs ( "..vTag["H"].." ) Max Hubs is ( "..MaxHubs.." ). ")
      curUser:Disconnect()
   end
end

function VersionCheck(curUser,vClient,vTag,Version,Download)
   if (vClient == "DCGUI" or vClient == "DC:PRO") then
      if (vTag["V"] == "N/A") then
      elseif (vTag["V"] < Version) then
         SendPmToNick(curUser.sName, BotName,"You are using "..vClient.." version [ "..vTag["V"].." ]")
         SendPmToNick(curUser.sName, BotName,"The oldest version allowed is "..vClient.." [ "..Version.." ], you may download the latest "..vClient.." at "..Download)
         curUser:Disconnect()
      end
   else
      if (vTag["V"] == "N/A") then
      elseif (vTag["V"] < Version) then
         SendPmToNick(curUser.sName, BotName,"You are using "..vClient.." version [ "..vTag["V"].." ]")
         SendPmToNick(curUser.sName, BotName,"The oldest version allowed is "..vClient.." [ "..Version.." ], you may download the latest "..vClient.." at "..Download)
         curUser:Disconnect()
      end
   end
end

function BandwidhCheck(curUser,vTag)
   if vTag["B"] == "unlimited" then
   elseif (tonumber(vTag["B"]) < LockBW) then
         SendPmToNick(curUser.sName, BotName,"You are using a Bandwidh Locker, locked to ( "..vTag["B"].."  kB/s  ), Minimum is ( "..LockBW.." kB/s ).")
      curUser:Disconnect()
   end
end
Title:
Post by: nErBoS on 26 March, 2004, 23:20:23
Hi,

Yes i beleive that is what Morbid needs :)

Best regards, nErBoS
Title:
Post by: NightLitch on 28 March, 2004, 01:18:08
Well above script is an old one of this one that I have created.

Link to Thread HERE! (http://board.univ-angers.fr/thread.php?threadid=1562&boardid=12&styleid=1&sid=e14dfdd708e6ceac955582f8cc82c972)

/NL