Added BadIPDetection
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
@file:Suppress("MemberVisibilityCanBePrivate")
|
||||
|
||||
package net.axay.kspigot.ipaddress.badipdetectionservices
|
||||
|
||||
import net.axay.kspigot.ipaddress.BadIPDetectionResult
|
||||
import net.axay.kspigot.ipaddress.BadIPDetectionService
|
||||
import net.axay.kspigot.languageextensions.getStringOrNull
|
||||
import org.json.JSONObject
|
||||
|
||||
class GetIPIntel(
|
||||
private val intensity: Float = 0.99f,
|
||||
private val contactEmail: String = "foo@bar.com"
|
||||
) : BadIPDetectionService("getipintel.net") {
|
||||
|
||||
override fun requestString(ip: String) = "http://check.getipintel.net/check.php?ip=$ip&contact=$contactEmail"
|
||||
|
||||
override fun interpreteResult(result: JSONObject): BadIPDetectionResult {
|
||||
val probability = result.getStringOrNull("result")?.toFloatOrNull()
|
||||
?: return BadIPDetectionResult.ERROR
|
||||
return if (probability >= intensity) BadIPDetectionResult.GENERAL_BAD else BadIPDetectionResult.GOOD
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
@file:Suppress("MemberVisibilityCanBePrivate")
|
||||
|
||||
package net.axay.kspigot.ipaddress.badipdetectionservices
|
||||
|
||||
import net.axay.kspigot.ipaddress.BadIPDetectionResult
|
||||
import net.axay.kspigot.ipaddress.BadIPDetectionService
|
||||
import net.axay.kspigot.languageextensions.getStringOrNull
|
||||
import org.json.JSONObject
|
||||
|
||||
class IPHub(
|
||||
private val ifStrict: Boolean = false
|
||||
) : BadIPDetectionService("iphub.info") {
|
||||
|
||||
override fun requestString(ip: String) = "http://v2.api.iphub.info/ip/$ip"
|
||||
|
||||
override fun interpreteResult(result: JSONObject): BadIPDetectionResult {
|
||||
val ifBlock = result.getStringOrNull("block")?.toInt() ?: return BadIPDetectionResult.ERROR
|
||||
return if (ifBlock == 1 || (ifStrict && ifBlock == 2)) BadIPDetectionResult.GENERAL_BAD else BadIPDetectionResult.GOOD
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
package net.axay.kspigot.ipaddress.badipdetectionservices
|
||||
|
||||
import net.axay.kspigot.ipaddress.BadIPDetectionResult
|
||||
import net.axay.kspigot.ipaddress.BadIPDetectionService
|
||||
import net.axay.kspigot.languageextensions.getStringOrNull
|
||||
import org.json.JSONObject
|
||||
|
||||
class IPInfo(
|
||||
private val token: String
|
||||
) : BadIPDetectionService("ipinfo.io") {
|
||||
|
||||
override fun requestString(ip: String) = "https://ipinfo.io/$ip/privacy?token=$token"
|
||||
|
||||
override fun interpreteResult(result: JSONObject): BadIPDetectionResult {
|
||||
return when {
|
||||
result.getStringOrNull("vpn").toBoolean() -> BadIPDetectionResult.VPN
|
||||
result.getStringOrNull("proxy").toBoolean() -> BadIPDetectionResult.PROXY
|
||||
result.getStringOrNull("tor").toBoolean() -> BadIPDetectionResult.TOR
|
||||
result.getStringOrNull("hosting").toBoolean() -> BadIPDetectionResult.HOSTING
|
||||
else -> BadIPDetectionResult.GOOD
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
package net.axay.kspigot.ipaddress.badipdetectionservices
|
||||
|
||||
import net.axay.kspigot.ipaddress.BadIPDetectionResult
|
||||
import net.axay.kspigot.ipaddress.BadIPDetectionService
|
||||
import net.axay.kspigot.languageextensions.getStringOrNull
|
||||
import org.json.JSONObject
|
||||
|
||||
class VPNBlocker : BadIPDetectionService("vpnblocker.net") {
|
||||
|
||||
override fun requestString(ip: String) = "http://api.vpnblocker.net/v2/json/$ip"
|
||||
|
||||
override fun interpreteResult(result: JSONObject): BadIPDetectionResult {
|
||||
val isBad = result.getStringOrNull("host-ip")
|
||||
return when {
|
||||
isBad != null -> if (isBad.toBoolean()) BadIPDetectionResult.GENERAL_BAD else BadIPDetectionResult.GOOD
|
||||
else -> {
|
||||
val remaining = result.getStringOrNull("remaining_requests")?.toIntOrNull()
|
||||
?: return BadIPDetectionResult.ERROR
|
||||
if (remaining <= 0) BadIPDetectionResult.LIMIT else BadIPDetectionResult.ERROR
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user