Compare commits
2 Commits
12cf5e446e
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| cfc5445ed9 | |||
| 6efba7de05 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -11,3 +11,4 @@ db/geoip2-csv-converter-v1.3.0-windows-64.zip
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
.idea/*
|
.idea/*
|
||||||
.idea/
|
.idea/
|
||||||
|
main
|
||||||
12
main.go
12
main.go
@@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -29,9 +30,11 @@ func getIPInfoAndRespond(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// 获取IP信息
|
// 获取IP信息
|
||||||
IPinfo := modules.GetIPInformation(ip)
|
IPinfo := modules.GetIPInformation(ip)
|
||||||
fmt.Println("IP", IPinfo.IP)
|
if IPinfo.IsPrivate != false {
|
||||||
fmt.Println("IsPrivate", IPinfo.IsPrivate)
|
log.Println("tag:main", "IP: "+IPinfo.IP+", IsPrivate: "+strconv.FormatBool(IPinfo.IsPrivate)+", PrivateCIDR: "+IPinfo.PrivateCIDR)
|
||||||
fmt.Println("PrivateCIDR", IPinfo.PrivateCIDR)
|
} else {
|
||||||
|
log.Println("tag:main", "IP: "+IPinfo.IP+", IsPrivate: "+strconv.FormatBool(IPinfo.IsPrivate))
|
||||||
|
}
|
||||||
|
|
||||||
// 检查是否为私有IP
|
// 检查是否为私有IP
|
||||||
if IPinfo.IsPrivate == true {
|
if IPinfo.IsPrivate == true {
|
||||||
@@ -41,9 +44,6 @@ func getIPInfoAndRespond(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// 使用mmdb查询ip
|
// 使用mmdb查询ip
|
||||||
IpIformation := modules.MmdbQueryIP(IPinfo.IP)
|
IpIformation := modules.MmdbQueryIP(IPinfo.IP)
|
||||||
// 使用MySql查询ip
|
|
||||||
//dsn := modules.Readconfig()
|
|
||||||
//IpIformation := modules.MysqlQuery(ip, dsn)
|
|
||||||
|
|
||||||
log.Println("tag:main", IpIformation)
|
log.Println("tag:main", IpIformation)
|
||||||
jsonData, err := json.Marshal(IpIformation)
|
jsonData, err := json.Marshal(IpIformation)
|
||||||
|
|||||||
Reference in New Issue
Block a user