blob: 38e2f60df511d59afb6b92e228632fa77efc7537 (
plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
package verify
const (
AreaAvailableID = 80018499
SelfMadeAvailableID = 80197526
NonSelfMadeAvailableID = 70143836
NetworkUnrachable = -2
AreaUnavailable = -1
AreaAvailable = 0
UnblockSelfMadeMovie = 1
UnblockNonSelfMadeMovie = 2
CustomMovieBlock = 3
CustomMovieUnblock = 4
NetflixURL_PREFIX = "https://www.netflix.com/title/"
)
type Verify interface {
Execute() *VerifyResponse
}
type FinalResult struct {
Res map[int]VerifyResponse
}
type VerifyResult struct {
Config
response chan *VerifyResponse
}
type Config struct {
LocalAddr string
Custom string
}
type VerifyResponse struct {
Type int
StatusCode int
CountryCode string
CountryName string
}
type UnblockTestResult struct {
movieID int
CountryCode string
err error
}
func NewVerify(c Config) *FinalResult {
var finalResult FinalResult
finalResult.Res = make(map[int]VerifyResponse)
vr := VerifyResult{Config: c}
ch := make(chan *VerifyResponse)
vr.response = ch
defer close(ch)
go vr.IPv4Verifier()
go vr.IPv6Verifier()
for i := 0; i < 2; i++ {
if res, err := <-ch; err {
finalResult.Res[res.Type] = *res
}
}
return &finalResult
}
func (vr *VerifyResult) IPv4Verifier() {
verify := &IPv4Verifier{Config: vr.Config}
vr.response <- verify.Execute()
}
func (vr *VerifyResult) IPv6Verifier() {
verify := &IPv6Verifier{Config: vr.Config}
vr.response <- verify.Execute()
}
|