Compare commits
7 Commits
46a94d7c91
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| cfc5445ed9 | |||
| 6efba7de05 | |||
| 12cf5e446e | |||
| bde1152cde | |||
| 56646a87dc | |||
| 2667b35148 | |||
| 2eaac26f4a |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -8,3 +8,7 @@ db/GeoLite2-City-Locations-zh-CN.csv
|
||||
db/GeoLite2-City_20230602.tar.gz
|
||||
db/geoip2-csv-converter-v1.3.0-windows-64.zip
|
||||
.checkIP
|
||||
.DS_Store
|
||||
.idea/*
|
||||
.idea/
|
||||
main
|
||||
8
.idea/.gitignore
generated
vendored
8
.idea/.gitignore
generated
vendored
@@ -1,8 +0,0 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
9
.idea/learn.iml
generated
9
.idea/learn.iml
generated
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="Go" enabled="true" />
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
8
.idea/modules.xml
generated
8
.idea/modules.xml
generated
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/learn.iml" filepath="$PROJECT_DIR$/.idea/learn.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/vcs.xml
generated
6
.idea/vcs.xml
generated
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
14
.idea/webResources.xml
generated
14
.idea/webResources.xml
generated
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="WebResourcesPaths">
|
||||
<contentEntries>
|
||||
<entry url="file://$PROJECT_DIR$">
|
||||
<entryData>
|
||||
<resourceRoots>
|
||||
<path value="file://$PROJECT_DIR$" />
|
||||
</resourceRoots>
|
||||
</entryData>
|
||||
</entry>
|
||||
</contentEntries>
|
||||
</component>
|
||||
</project>
|
||||
12
main.go
12
main.go
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -29,9 +30,11 @@ func getIPInfoAndRespond(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// 获取IP信息
|
||||
IPinfo := modules.GetIPInformation(ip)
|
||||
fmt.Println("IP", IPinfo.IP)
|
||||
fmt.Println("IsPrivate", IPinfo.IsPrivate)
|
||||
fmt.Println("PrivateCIDR", IPinfo.PrivateCIDR)
|
||||
if IPinfo.IsPrivate != false {
|
||||
log.Println("tag:main", "IP: "+IPinfo.IP+", IsPrivate: "+strconv.FormatBool(IPinfo.IsPrivate)+", PrivateCIDR: "+IPinfo.PrivateCIDR)
|
||||
} else {
|
||||
log.Println("tag:main", "IP: "+IPinfo.IP+", IsPrivate: "+strconv.FormatBool(IPinfo.IsPrivate))
|
||||
}
|
||||
|
||||
// 检查是否为私有IP
|
||||
if IPinfo.IsPrivate == true {
|
||||
@@ -41,9 +44,6 @@ func getIPInfoAndRespond(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// 使用mmdb查询ip
|
||||
IpIformation := modules.MmdbQueryIP(IPinfo.IP)
|
||||
// 使用MySql查询ip
|
||||
//dsn := modules.Readconfig()
|
||||
//IpIformation := modules.MysqlQuery(ip, dsn)
|
||||
|
||||
log.Println("tag:main", IpIformation)
|
||||
jsonData, err := json.Marshal(IpIformation)
|
||||
|
||||
Reference in New Issue
Block a user