utils

package
v1.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendCreate

func AppendCreate(name string) (*os.File, error)

func CheckVersion

func CheckVersion(old, version string) bool

func DataRoot

func DataRoot(elem ...string) string

func ExtractHost

func ExtractHost(rawURL string) string

func ExtractURLs

func ExtractURLs(text string) []string

func FindOffset

func FindOffset(file *os.File, target string) (int64, error)

func FindStringInFile

func FindStringInFile(filepath string, target string) bool

func FindStringSubmatch

func FindStringSubmatch(reg, str string) []string

func GetCheckRedirectFunc

func GetCheckRedirectFunc(errUseLastResponse bool) func(req *defaultHttp.Request, via []*defaultHttp.Request) error

GetCheckRedirectFunc 辅助函数:获取 CheckRedirect 函数

func GetHash

func GetHash(body []byte, method string) ([]byte, error)

func GetMainDomain

func GetMainDomain(domain string) string

func GetMatchVersion

func GetMatchVersion(defaultMatchDir string) (string, error)

func GetPartString

func GetPartString(part string, data map[string]interface{}) (interface{}, bool)

func GetProtocolAndHost

func GetProtocolAndHost(url string) (string, string)

从url中辨别协议,分离 协议 和 域名

func GetProtocolHostAndPort

func GetProtocolHostAndPort(path string) (string, string, int)

GetProtocolHostAndPort 返回 三个值 以下是案例 http://[A01F::0]:8000/ -> http, [A01F::0], 8000 http://[A01F::0]/a -> http, [A01F::0], 80 https://[A01F::0]/ -> https, [A01F::0], 443 [A01F::0]:8000 -> http, [A01F::0], 8000 [A01F::0] -> http, [A01F::0], 80 127.0.0.1:8000 -> http, 127.0.0.1, 8000 http://127.0.0.1:8000/?a=1 -> http, 127.0.0.1 8000 https://127.0.0.1 -> https, 127.0.0.1 443

func GetProxyFunc

func GetProxyFunc(proxy, auth string) func(*defaultHttp.Request) (*url.URL, error)

GetProxyFunc 辅助函数:获取代理设置函数

func GetProxyURL

func GetProxyURL(proxy, auth string) (*url.URL, error)

func GetRequestPackage

func GetRequestPackage(request *http.Request) string

func GetResponsePackage

func GetResponsePackage(response *defaultHttp.Response, body []byte, getBody bool) string

func GetTrueUrl

func GetTrueUrl(text *url.URL) string

func IsSubdomainOrSameDomain

func IsSubdomainOrSameDomain(orl string, link string) bool

func IsValidDomain

func IsValidDomain(domain string) bool

IsValidDomain 使用正则表达式检查字符串是否是有效的域名

func JoinPath

func JoinPath(target, path string) string

func ListFilesWithExtension

func ListFilesWithExtension(rootPath string, extensions ...string) ([]string, error)

func MatchString

func MatchString(reg, str string) bool

func NewProxyDialer

func NewProxyDialer(proxyUrl, proxyAuth string) (proxy.Dialer, error)

func Nunzip

func Nunzip(p string, zipReader *zip.Reader) error

func ParseProxyAuth

func ParseProxyAuth(auth string) (string, string, bool)

ParseProxyAuth 辅助函数:解析代理授权信息(格式为“username:password”)

func RandStr

func RandStr(length int) string

func ReadFile

func ReadFile(filename string) (string, error)

ReadFile 从指定文件中读取数据

func RemoveDuplicateAndEmptyStrings

func RemoveDuplicateAndEmptyStrings(arr []string) []string

移除字符串重复的、为空的的字符串

func RemoveDuplicateStrings

func RemoveDuplicateStrings(arr []string) []string

RemoveDuplicateStrings 字符串数组去重

func ReplaceStringsInFile

func ReplaceStringsInFile(templateFile, oldString, newString string) error

ReplaceStringsInFile 用于读取文件,替换其中的特定字符串,并在原文件上进行修改

func ToString

func ToString(data interface{}) string

ToString converts an interface to string in a quick way

func Unzip

func Unzip(p string, reader *bytes.Reader) error

Unzip 覆盖解压

func WriteFile

func WriteFile(filename string, string2 string) error

WriteFile 将数据写入指定文件

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL