Script to allow IP Range?

Which hub software is the best? Where can I find script XXX? Discuss it here...(no, this is not for advertising your hub...)

Moderator: Moderators

Oatmeal
Posts: 1
Joined: 2003-09-06 02:58

Script to allow IP Range?

Post by Oatmeal » 2003-09-08 15:44

Does anyone know of a script out there that would allow me to only allow ppl with a certain IP to gain access to my hub? (ie, I live on campus and all the computer's on it are given an IP of 141.109.*.* and I only want to allow these ppl to join)

GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-08 02:46
Location: .pa.us

Post by GargoyleMT » 2003-09-09 17:00

That sounds like a problem that's typically handled by a firewall. If you're running a hub, a real hardware firewall (ie. dedicated linux box) would be very nice should you ever come under attack.

Yes, I know you asked for a script, but I think a firewall is better

whetu
Posts: 1
Joined: 2003-09-10 02:52

Re: Script to allow IP Range?

Post by whetu » 2003-09-10 03:02

Oatmeal wrote:Does anyone know of a script out there that would allow me to only allow ppl with a certain IP to gain access to my hub? (ie, I live on campus and all the computer's on it are given an IP of 141.109.*.* and I only want to allow these ppl to join)


Yes, you are looking for IPBot, here's a quick copy and paste of my modified version with all but 2 of the allow ranges removed.

Code: Select all

'=====================================
' Direct Connect Hub IP Filter script
'-------------------------------------
' version: 1.0 (010629)
'  author: [FF]yopo
'   email: [email protected]
'=====================================
' This script will check users when
' connecting to the hub, and if the
' IP number is not in the oAllow list
' it will disconnect the client.  You
' can also configure it to allow full
' A-, B- or C-subnets (see the
' examples below).  It will also send
' a message to the user.  The script
' is useful if you want to keep the
' hub open only for connection from a
' specific ISP, network or region.
'=====================================

Dim sBotName
Dim oAllow
Dim sRejectMessage

Sub Main()
  Set oAllow = CreateObject("Scripting.Dictionary")

'Set these basic parameters
  sBotName = "IPBotNZ"     ' <- name of the bot

'The message to send to denied clients
  sRejectMessage = "Sorry, no connections are allowed to those outside of New Zealand."

'Add new entries for each ip number or subnet you want to allow.
'Here are some examples of the syntax; the "descriptions" can be
'anything, except for an empty string.  Remove the examples when
'you add your own.

          oAllow("132.181.*") = "Uni"
        oAllow("192.168.*") = "Home"
       
End Sub


Sub NewUserConnected(curUser)

  Dim sIPfull
  Dim sIPc, sIPb, sIPa

  sIPfull = curUser.IP()
  sIPc = Left(sIPfull, InStrRev(sIPfull, ".") - 1)
  sIPb = Left(sIPc, InStrRev(sIPc, ".") - 1)
  sIPa = Left(sIPb, InStrRev(sIPb, ".") - 1)
  sIPa = sIPa & ".*"
  sIPb = sIPb & ".*"
  sIPc = sIPc & ".*"

  If Not (curUser.bOperator Or oAllow.Exists(sIPfull) Or _
   oAllow.Exists(sIPc) Or oAllow.Exists(sIPb) Or _
   oAllow.Exists(sIPa)) Then
    curUser.PrivateMessage CStr(sBotName), CStr(sRejectMessage)
    frmHub.DoEventsForMe
    curUser.Disconnect
  End If

End Sub

Who is online

Users browsing this forum: Google [Bot] and 0 guests