mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-11-04 16:40:21 +00:00
通知内 IP 脱敏
This commit is contained in:
1 parent
c81bb41264
commit
c4e5dc01e0
9 files changed
+76
-8
No files matched your search
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/hex"
|
||||
"math/rand"
|
||||
"os"
|
||||
"regexp"
|
||||
"time"
|
||||
"unsafe"
|
||||
)
|
||||
@@ -45,3 +46,21 @@ func MD5(plantext string) string {
|
||||
func IsWindows() bool {
|
||||
return os.PathSeparator == '\\' && os.PathListSeparator == ';'
|
||||
}
|
||||
|
||||
var ipv4Re = regexp.MustCompile(`(\d*\.).*(\.\d*)`)
|
||||
|
||||
func ipv4Desensitize(ipv4Addr string) string {
|
||||
return ipv4Re.ReplaceAllString(ipv4Addr, "$1****$2")
|
||||
}
|
||||
|
||||
var ipv6Re = regexp.MustCompile(`(\w*:\w*:).*(:\w*:\w*)`)
|
||||
|
||||
func ipv6Desensitize(ipv6Addr string) string {
|
||||
return ipv6Re.ReplaceAllString(ipv6Addr, "$1****$2")
|
||||
}
|
||||
|
||||
func IPDesensitize(ipAddr string) string {
|
||||
ipAddr = ipv4Desensitize(ipAddr)
|
||||
ipAddr = ipv6Desensitize(ipAddr)
|
||||
return ipAddr
|
||||
}
|
||||
Reference in new issue
Block a user