• Print

Author Topic: Logging IPs with ULX Possible?! Let's see how!  (Read 4408 times)

0 Members and 1 Guest are viewing this topic.

Offline Snugzz

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Logging IPs with ULX Possible?! Let's see how!
« on: October 05, 2015, 01:48:12 pm »
After numerous trolls on my server that would come back with a family shared account I decided to ban their IP. Well I couldn't do so without their actual IP. Yes I could take the long way and go through my console and then get it that way and then "ban ip XX.XX.XX.XX" but who has time for that! ULX comes ready to log IPs.  ;D ;D ;D ;D.

Here's how!

1) Navigate to your install of ULX ( Normally garrysmod>addon>ulx).
2) Nroceed further into the files (garrysmod>addon>ulx>lua>ulx>log.lua)
3) Open log.lua
4) Go to line 191, here you can see 
Code: Lua
  1. local function playerInitialSpawn( ply )
  2.         local ip = ply:IPAddress()
  3.         local seconds = os.time() - (joinTimer[ip] or mapStartTime)
  4.         joinTimer[ip] = nil
  5.  
  6.         local txt = string.format( "Client \"%s\" spawned in server <%s> (took %i seconds).", ply:Nick(), ply:SteamID(), seconds )
  7.         if logEvents:GetBool() then
  8.                 ulx.logString( txt )
  9.         end
  10.  
  11.         if logJoinLeaveEcho:GetBool() then
  12.                 echoToAdmins( txt )
  13.         end
  14. end
  15. hook.Add( "PlayerInitialSpawn", "ULXLogInitialSpawn", playerInitialSpawn, HOOK_MONITOR_HIGH )
  16.  
As you can see they still have the function left within ULX. Now it's just a matter of slightly editting the few lines of code to log IP addresses.

AS I have been unsuccessful with logging them this way I just editted a script to work just about the same way :P

Here for you want to take the easy way out.
Code: Lua
  1. hook.Add("PlayerInitialSpawn", "SaveIP", function( p )
  2.     if p:IPAddress() != nil then
  3.         file.Append("ips.txt", "Player "..p:Nick().." has connected from the IP: "..p:IPAddress().." and with the Steam ID: "..p:SteamID().."\n")
  4.     end
  5. end)
  6.  

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Logging IPs with ULX Possible?! Let's see how!
« Reply #1 on: October 05, 2015, 04:17:48 pm »
I wouldn't recommend using IPs as a permanent ban, as most people connecting to Gmod servers are on DHCP.
That, and we took IPs out of ULX for protection of clients (security exploits)

If I were a troll, I could get around your IP ban with a family account in less than 3-4 minutes, faster if my router weren't more than 5 years old.
I'd recommend using any number of Steam API family check scripts.
This one here, though I never tested, seemed like it would work in theory.
/index.php/topic,7021.0.html#msg35081 />Though it just checks for shared accounts, it could be used as basis for banning.



"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Timmy

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 252
  • Karma: 168
  • Code monkey
Re: Logging IPs with ULX Possible?! Let's see how!
« Reply #2 on: October 05, 2015, 05:13:33 pm »
I will also link my addon if that's okay.

> /index.php/topic,9087.0.html#msg46380

I wrote it to combat players that avoid bans via Family Sharing, a few months ago. It will automagically ban the parent account that owns the game as well as any child accounts trying to access via Steam Family Sharing. It makes use of the Steam Web API to do that. You can find instructions on how to set it up inside the topic.

Edit: Aww, sweet! I'm a Jr. Member now. ^-^
« Last Edit: May 31, 2018, 01:41:55 am by Timmy »

  • Print