mirror of
https://github.com/zu1k/nali.git
synced 2025-01-23 21:59:02 +08:00
24 lines
909 B
Go
24 lines
909 B
Go
package tools
|
|
|
|
import (
|
|
"strings"
|
|
"regexp"
|
|
)
|
|
|
|
func AddInfoIp4(origin string, ip string, info string) (result string) {
|
|
re := regexp.MustCompile("(^|[^0-9.])(" + strings.ReplaceAll(ip, ".", "\\.") + ")($|[^0-9.])")
|
|
result = re.ReplaceAllString(origin, "$1$2"+" ["+info+"]$3")
|
|
return strings.TrimRight(result, " \t")
|
|
}
|
|
|
|
func AddInfoIp6(origin string, ip string, info string) (result string) {
|
|
re := regexp.MustCompile("(^|[^0-9a-fA-F:])(" + strings.ReplaceAll(ip, ".", "\\.") + ")($|[^0-9a-fA-F:])")
|
|
result = re.ReplaceAllString(origin, "$1$2"+" ["+info+"]$3")
|
|
return strings.TrimRight(result, " \t")
|
|
}
|
|
|
|
func AddInfoDomain(origin string, domain string, info string) (result string) {
|
|
re := regexp.MustCompile("(^|[^0-9a-zA-Z-])(" + strings.ReplaceAll(domain, ".", "\\.") + ")($|[^0-9a-zA-Z-\\.])")
|
|
result = re.ReplaceAllString(origin, "$1$2"+" ["+info+"]$3")
|
|
return strings.TrimRight(result, " \t")
|
|
} |