update: 当 ip.sb 触发 cloudflare 5s 墙的时候 自动退出

This commit is contained in:
sjlleo
2022-05-25 17:25:26 +08:00
parent dbecfd880d
commit f81a0b3da3

View File

@@ -4,6 +4,7 @@ import (
"io/ioutil"
"log"
"net/http"
"os"
"time"
"github.com/tidwall/gjson"
@@ -26,6 +27,11 @@ func IPSB(ip string) (*IPGeoData, error) {
body, _ := ioutil.ReadAll(content.Body)
res := gjson.ParseBytes(body)
if res.Get("country").String() == "" {
// 什么都拿不到证明被Cloudflare风控了
os.Exit(1)
}
return &IPGeoData{
Asnumber: res.Get("asn").String(),
Country: res.Get("country").String(),