访问日志增加区域和ISP信息

This commit is contained in:
GoEdgeLab
2020-11-05 11:51:42 +08:00
parent 7f4bd06bbb
commit a3bd0e816d
2 changed files with 38 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ import (
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"
"net/http"
"strings"
)
type ViewPopupAction struct {
@@ -82,5 +83,34 @@ func (this *ViewPopupAction) RunGet(params struct {
}
this.Data["wafInfo"] = wafMap
// 地域相关
var regionMap maps.Map = nil
regionResp, err := this.RPC().IPLibraryRPC().LookupIPRegion(this.AdminContext(), &pb.LookupIPRegionRequest{Ip: accessLog.RemoteAddr})
if err != nil {
this.ErrorPage(err)
return
}
region := regionResp.Region
if region != nil {
pieces := []string{}
if len(region.Country) > 0 {
pieces = append(pieces, region.Country)
}
if len(region.Region) > 0 {
pieces = append(pieces, region.Region)
}
if len(region.Province) > 0 {
pieces = append(pieces, region.Province)
}
if len(region.City) > 0 {
pieces = append(pieces, region.City)
}
regionMap = maps.Map{
"full": strings.Join(pieces, " "),
"isp": region.Isp,
}
}
this.Data["region"] = regionMap
this.Show()
}

View File

@@ -112,5 +112,13 @@
<td>IP</td>
<td>{{accessLog.remoteAddr}}</td>
</tr>
<tr v-if="region != null">
<td>区域</td>
<td>{{region.full}}</td>
</tr>
<tr v-if="region.isp.length > 0">
<td>ISP</td>
<td>{{region.isp}}</td>
</tr>
</table>
</div>