MCPcopy
hub / github.com/ChineseSubFinder/ChineseSubFinder / GetPublicIP

Function GetPublicIP

pkg/util.go:99–134  ·  view source on GitHub ↗
(log *logrus.Logger, queue *settings.TaskQueue)

Source from the content-addressed store, hash-verified

97}
98
99func 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 下载文件
137func DownFile(l *logrus.Logger, urlStr string) ([]byte, string, error) {

Callers 4

GetMethod · 0.92
GetA4kMethod · 0.92
GetExMethod · 0.92
GetSubtitleBestMethod · 0.92

Calls 1

getPublicIPFunction · 0.85

Tested by

no test coverage detected