(log *logrus.Logger, queue *settings.TaskQueue)
| 97 | } |
| 98 | |
| 99 | func GetPublicIP(log *logrus.Logger, queue *settings.TaskQueue) string { |
| 100 | |
| 101 | defPublicIPSites := []string{ |
| 102 | "https://myip.biturl.top/", |
| 103 | "https://ip4.seeip.org/", |
| 104 | "https://ipecho.net/plain", |
| 105 | "https://api-ipv4.ip.sb/ip", |
| 106 | "https://api.ipify.org/", |
| 107 | "http://myexternalip.com/raw", |
| 108 | } |
| 109 | |
| 110 | customPublicIPSites := make([]string, 0) |
| 111 | if queue.CheckPublicIPTargetSite != "" { |
| 112 | // 自定义了公网IP查询网站 |
| 113 | tSites := strings.Split(queue.CheckPublicIPTargetSite, ";") |
| 114 | if tSites != nil && len(tSites) > 0 { |
| 115 | customPublicIPSites = append(customPublicIPSites, tSites...) |
| 116 | } |
| 117 | } else { |
| 118 | customPublicIPSites = append(customPublicIPSites, defPublicIPSites...) |
| 119 | } |
| 120 | |
| 121 | for i, publicIPSite := range customPublicIPSites { |
| 122 | log.Debugln("[GetPublicIP]", i, publicIPSite) |
| 123 | publicIP := getPublicIP(publicIPSite) |
| 124 | |
| 125 | matcheds := regex_things.ReMatchIP.FindAllString(publicIP, -1) |
| 126 | |
| 127 | if publicIP != "" || matcheds == nil || len(matcheds) == 0 { |
| 128 | log.Infoln("[GetPublicIP]", publicIP) |
| 129 | return publicIP |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | return "" |
| 134 | } |
| 135 | |
| 136 | // DownFile 从指定的 url 下载文件 |
| 137 | func DownFile(l *logrus.Logger, urlStr string) ([]byte, string, error) { |
no test coverage detected