mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-11-04 16:40:21 +00:00
feat: 服务器信息API
This commit is contained in:
1 parent
d70ebf4d20
commit
3984c466a9
3 files changed
+161
-26
No files matched your search
@@ -6,6 +6,7 @@ import (
|
||||
"math/rand"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
@@ -68,3 +69,27 @@ func IPDesensitize(ipAddr string) string {
|
||||
ipAddr = ipv6Desensitize(ipAddr)
|
||||
return ipAddr
|
||||
}
|
||||
|
||||
// SplitIPAddr 传入/分割的v4v6混合地址,返回v4和v6地址与有效地址
|
||||
func SplitIPAddr(v4v6Bundle string) (string, string, string) {
|
||||
ipList := strings.Split(v4v6Bundle, "/")
|
||||
ipv4 := ""
|
||||
ipv6 := ""
|
||||
validIP := ""
|
||||
if len(ipList) > 1 {
|
||||
// 双栈
|
||||
ipv4 = ipList[0]
|
||||
ipv6 = ipList[1]
|
||||
validIP = ipv4
|
||||
} else if len(ipList) == 1 {
|
||||
// 仅ipv4|ipv6
|
||||
if strings.Contains(ipList[0], ":") {
|
||||
ipv6 = ipList[0]
|
||||
validIP = ipv6
|
||||
} else {
|
||||
ipv4 = ipList[0]
|
||||
validIP = ipv4
|
||||
}
|
||||
}
|
||||
return ipv4, ipv6, validIP
|
||||
}
|
||||
Reference in new issue
Block a user