docs: 增加注释

This commit is contained in:
Mmx
2021-12-02 13:46:01 +08:00
parent 680130aaef
commit 07d66ced1e
6 changed files with 18 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ type checker struct{}
var Checker checker
// NetOk 网络状况检查
func (checker) NetOk(timeout uint) bool {
h, _, e := tool.HTTP.GetBytes(&tool.GetRequest{
Url: "https://www.baidu.com/",

View File

@@ -21,6 +21,7 @@ func Search(reg string, content string) (string, error) {
}
}
// GetIp 从响应获取本机分配到的IP
func GetIp(body string) (string, error) {
//判断原正则是否有匹配,如果无就使用新正则尝试
if ip, e := Search("id=\"user_ip\" value=\"(.*?)\"", body); e == nil {
@@ -29,20 +30,24 @@ func GetIp(body string) (string, error) {
return Search("ip : \"(.*?)\"", body)
}
// GetToken 从响应获取token
func GetToken(body string) (string, error) {
return Search("\"challenge\":\"(.*?)\"", body)
}
// GetResult 从响应获取登录结果
func GetResult(body string) (string, error) {
return Search("\"error\":\"(.+?)\"", body)
}
// Md5 编码
func Md5(content string) string {
w := md5.New()
_, _ = io.WriteString(w, content)
return fmt.Sprintf("%x", w.Sum(nil))
}
// Sha1 编码
func Sha1(content string) string {
h := sha1.New()
h.Write([]byte(content))