forked from ssrlive/proxypool
-
Notifications
You must be signed in to change notification settings - Fork 1
/
stream.go
61 lines (57 loc) · 1.81 KB
/
stream.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package stream
import (
"fmt"
PC "github.com/asdlokj1qpi23/proxypool/config"
"github.com/asdlokj1qpi23/proxypool/internal/cache"
"github.com/asdlokj1qpi23/proxypool/pkg/proxy"
"github.com/asdlokj1qpi23/proxypool/pkg/utils"
C "github.com/metacubex/mihomo/constant"
"github.com/metacubex/mihomo/log"
"time"
)
func RunNetflix(proxies proxy.ProxyList) proxy.ProxyList {
proxiesList := formatProxiesList(proxies)
connNum := PC.Config.StreamMaxConn
//同时连接数
if i := proxies.Len(); i < connNum {
connNum = i
}
start := time.Now()
netflixList := BatchCheck(proxiesList, connNum)
if len(netflixList) == 0 {
log.Warnln("No unlock node were found.")
return proxies
}
cache.NetflixCount = len(netflixList)
report := fmt.Sprintf("Total %d nodes test completed, %d unlock nodes, Elapsed time: %s", proxies.Len(), len(netflixList), time.Since(start).Round(time.Millisecond))
log.Infoln(report)
return NETFLIXFilter(netflixList, proxies)
}
func RunDisney(proxies proxy.ProxyList) proxy.ProxyList {
proxiesList := formatProxiesList(proxies)
start := time.Now()
connNum := PC.Config.StreamMaxConn
//同时连接数
if i := proxies.Len(); i < connNum {
connNum = i
}
disneyList := BatchDisneyCheck(proxiesList, connNum)
if len(disneyList) == 0 {
log.Warnln("No unlock node were found.")
return proxies
}
cache.DisneyCount = len(disneyList)
report := fmt.Sprintf("Total %d nodes test completed, %d unlock nodes, Elapsed time: %s", len(proxiesList), len(disneyList), time.Since(start).Round(time.Millisecond))
log.Warnln(report)
return DISNEYFilter(disneyList, proxies)
}
func formatProxiesList(proxies proxy.ProxyList) (proxiesList []C.Proxy) {
for _, p := range proxies {
pp, err := utils.ParseCustomizeProxy(p)
if err != nil {
continue
}
proxiesList = append(proxiesList, pp)
}
return proxiesList
}