Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local GeoIP = "http://www.telize.com/geoip/" -- A GeoIP API
- local function isLocalIP(ip)
- return ip == '127.0.0.1' or string.sub(ip, 1, 8) == '192.168.'
- end
- function proxyCheck()
- --IP Proxy Check
- local thePlayer = source
- local ip = getPlayerIP(thePlayer)
- if not ip then
- outputDebugString("[BANS] Couldn't get player IP, letting him in..")
- return false
- end
- callRemote(GeoIP .. ip, function(data)
- if type(data) ~= "table" then -- Error
- outputDebugString("[BANS] Issue retriveing proxy information: "..data)
- return false
- end
- local country_code = data.country_code
- local longitude = data.longitude
- local latitude = data.latitude
- local count = 0
- for _ in pairs(data) do count = count + 1 end
- -- Conditions
- if (count == 0) then -- Failed to retrieve information. Let them in.
- outputDebugString("[BANS] Couldn't get any info..")
- return false
- elseif isLocalIP( ip ) then
- outputDebugString( "[BANS] Local IP detected: "..ip )
- return false
- elseif count == 1 then -- Only returned the IP address meaning either their IP is spoofed or internal.
- outputDebugString("[BANS] Spoofed: ".. ip)
- outputChatBox("There is a issue with your IP address. Please contact us at www.olwgaming.net", thePlayer, 255, 0, 0)
- kickPlayer(thePlayer, "There is a issue with your IP address.")
- return true
- elseif (not country_code) or (country_code == "A1") or (not longitude) or (not latitude) or (longitude == 0 and latitude == 0) then
- outputChatBox("Your IP address is not genuine. Please connct without using a proxy service.", thePlayer, 255, 0, 0)
- exports.global:sendMessageToAdmins("[BANS] Rejected connection from IP: '"..ip.."' as it has automatically been detected as non-genuine.")
- kickPlayer(thePlayer, "Your IP address is not genuine.")
- return true
- end
- end )
- return false
- end
- addEventHandler("onPlayerJoin", getRootElement(), proxyCheck)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement