mirror of https://github.com/hykilpikonna/AquaDX
[F] Ignore geoip not found error
parent
6f9b686317
commit
c7a4902af0
|
@ -1,6 +1,7 @@
|
||||||
package icu.samnyan.aqua.net.utils
|
package icu.samnyan.aqua.net.utils
|
||||||
|
|
||||||
import com.maxmind.geoip2.DatabaseReader
|
import com.maxmind.geoip2.DatabaseReader
|
||||||
|
import com.maxmind.geoip2.exception.AddressNotFoundException
|
||||||
import ext.Bool
|
import ext.Bool
|
||||||
import ext.Str
|
import ext.Str
|
||||||
import jakarta.annotation.PostConstruct
|
import jakarta.annotation.PostConstruct
|
||||||
|
@ -78,7 +79,9 @@ class GeoIP(
|
||||||
return try {
|
return try {
|
||||||
val ipa = InetAddress.getByName(ip)
|
val ipa = InetAddress.getByName(ip)
|
||||||
geoLite.country(ipa)?.country?.isoCode ?: ""
|
geoLite.country(ipa)?.country?.isoCode ?: ""
|
||||||
} catch (e: Exception) {
|
}
|
||||||
|
catch (e: AddressNotFoundException) { "" }
|
||||||
|
catch (e: Exception) {
|
||||||
log.error("Failed to get country from IP $ip", e)
|
log.error("Failed to get country from IP $ip", e)
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue