Compare commits

..

7 Commits

Author SHA1 Message Date
cfc5445ed9 Update main.go 2024-08-28 17:49:12 +08:00
6efba7de05 Update .gitignore 2024-08-28 16:55:15 +08:00
12cf5e446e Merge branch 'master' of https://gitea.kimgo.cn/wsy182/check_ip 2024-04-20 17:43:32 +08:00
bde1152cde Update .gitignore 2024-04-20 16:11:04 +08:00
56646a87dc delete
delete idea dir
2024-04-20 16:09:51 +08:00
2667b35148 Update .gitignore 2024-04-20 16:08:46 +08:00
2eaac26f4a Update .gitignore 2024-04-20 16:08:18 +08:00
7 changed files with 11 additions and 52 deletions

4
.gitignore vendored
View File

@@ -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
View File

@@ -1,8 +0,0 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

9
.idea/learn.iml generated
View File

@@ -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
View File

@@ -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
View File

@@ -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
View File

@@ -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
View File

@@ -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)