mirror of https://github.com/bjdgyc/anylink.git
修复 ipv6 记录显示不全的问题
This commit is contained in:
parent
262af4ac8e
commit
ff9b7c7dcc
|
@ -46,7 +46,7 @@ type UserActLog struct {
|
||||||
Username string `json:"username" xorm:"varchar(60)"`
|
Username string `json:"username" xorm:"varchar(60)"`
|
||||||
GroupName string `json:"group_name" xorm:"varchar(60)"`
|
GroupName string `json:"group_name" xorm:"varchar(60)"`
|
||||||
IpAddr string `json:"ip_addr" xorm:"varchar(32)"`
|
IpAddr string `json:"ip_addr" xorm:"varchar(32)"`
|
||||||
RemoteAddr string `json:"remote_addr" xorm:"varchar(32)"`
|
RemoteAddr string `json:"remote_addr" xorm:"varchar(42)"`
|
||||||
Os uint8 `json:"os" xorm:"not null default 0 Int"`
|
Os uint8 `json:"os" xorm:"not null default 0 Int"`
|
||||||
Client uint8 `json:"client" xorm:"not null default 0 Int"`
|
Client uint8 `json:"client" xorm:"not null default 0 Int"`
|
||||||
Version string `json:"version" xorm:"varchar(15)"`
|
Version string `json:"version" xorm:"varchar(15)"`
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/bjdgyc/anylink/base"
|
"github.com/bjdgyc/anylink/base"
|
||||||
|
"github.com/bjdgyc/anylink/pkg/utils"
|
||||||
"github.com/ivpusic/grpool"
|
"github.com/ivpusic/grpool"
|
||||||
"github.com/spf13/cast"
|
"github.com/spf13/cast"
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
@ -78,7 +79,8 @@ func (ua *UserActLogProcess) Add(u UserActLog, userAgent string) {
|
||||||
u.Os = os_idx
|
u.Os = os_idx
|
||||||
u.Client = client_idx
|
u.Client = client_idx
|
||||||
u.Version = ver
|
u.Version = ver
|
||||||
u.RemoteAddr = strings.Split(u.RemoteAddr, ":")[0]
|
// u.RemoteAddr = strings.Split(u.RemoteAddr, ":")[0]
|
||||||
|
u.RemoteAddr = utils.GetAddrIp(u.RemoteAddr)
|
||||||
// remove extra characters
|
// remove extra characters
|
||||||
infoSlice := strings.Split(u.Info, " ")
|
infoSlice := strings.Split(u.Info, " ")
|
||||||
infoLen := len(infoSlice)
|
infoLen := len(infoSlice)
|
||||||
|
|
|
@ -3,6 +3,7 @@ package utils
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"net"
|
"net"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Long2ip(i uint32) net.IP {
|
func Long2ip(i uint32) net.IP {
|
||||||
|
@ -15,3 +16,16 @@ func Ip2long(ip net.IP) uint32 {
|
||||||
ip = ip.To4()
|
ip = ip.To4()
|
||||||
return binary.BigEndian.Uint32(ip)
|
return binary.BigEndian.Uint32(ip)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetAddrIp 获取ip端口地址的ip数据
|
||||||
|
func GetAddrIp(s string) string {
|
||||||
|
if strings.Contains(s, ":") {
|
||||||
|
ss := s[:strings.LastIndex(s, ":")]
|
||||||
|
if strings.HasPrefix(ss, "[") {
|
||||||
|
return strings.Trim(ss, "[]")
|
||||||
|
}
|
||||||
|
return ss
|
||||||
|
}
|
||||||
|
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue