summaryrefslogtreecommitdiff
path: root/verify
diff options
context:
space:
mode:
Diffstat (limited to 'verify')
-rw-r--r--verify/ipv4.go50
-rw-r--r--verify/ipv6.go48
-rw-r--r--verify/verify.go12
3 files changed, 72 insertions, 38 deletions
diff --git a/verify/ipv4.go b/verify/ipv4.go
index d014fc0..b7db436 100644
--- a/verify/ipv4.go
+++ b/verify/ipv4.go
@@ -1,6 +1,7 @@
package verify
import (
+ "log"
"strconv"
"github.com/sjlleo/netflix-verify/util"
@@ -27,28 +28,42 @@ func (v *IPv4Verifier) Execute() *VerifyResponse {
v.unblockTestChan = make(chan UnblockTestResult)
defer close(v.unblockTestChan)
- go v.UnblockTest(AreaAvailableID)
- go v.UnblockTest(SelfMadeAvailableID)
- go v.UnblockTest(NonSelfMadeAvailableID)
+ if v.Custom == "" {
+ go v.UnblockTest(AreaAvailableID)
+ go v.UnblockTest(SelfMadeAvailableID)
+ go v.UnblockTest(NonSelfMadeAvailableID)
- for i := 0; i < 3; i++ {
- switch res := <-v.unblockTestChan; {
+ for i := 0; i < 3; i++ {
+ switch res := <-v.unblockTestChan; {
- case res.err != nil:
- v.unblockStatus = NetworkUnrachable
+ case res.err != nil:
+ v.unblockStatus = NetworkUnrachable
- case res.CountryCode != "":
- switch res.movieID {
- case AreaAvailableID:
- v.upgradeStatus(AreaAvailable)
- case SelfMadeAvailableID:
- v.upgradeStatus(UnblockSelfMadeMovie)
- case NonSelfMadeAvailableID:
- v.upgradeStatus(UnblockNonSelfMadeMovie)
+ case res.CountryCode != "":
+ switch res.movieID {
+ case AreaAvailableID:
+ v.upgradeStatus(AreaAvailable)
+ case SelfMadeAvailableID:
+ v.upgradeStatus(UnblockSelfMadeMovie)
+ case NonSelfMadeAvailableID:
+ v.upgradeStatus(UnblockNonSelfMadeMovie)
+ }
+ response.CountryCode = res.CountryCode
+ response.CountryName = util.CountryCodeToCountryName(res.CountryCode)
+ default:
}
+ }
+ } else {
+ if customMovieID, err := strconv.Atoi(v.Custom); err == nil {
+ go v.UnblockTest(customMovieID)
+ }
+ res := <-v.unblockTestChan
+ if res.CountryCode != "" {
+ v.unblockStatus = CustomMovieUnblock
response.CountryCode = res.CountryCode
response.CountryName = util.CountryCodeToCountryName(res.CountryCode)
- default:
+ } else {
+ v.unblockStatus = CustomMovieBlock
}
}
response.StatusCode = v.unblockStatus
@@ -63,8 +78,9 @@ func (v *IPv4Verifier) upgradeStatus(status int) {
func (v *IPv4Verifier) UnblockTest(MoiveID int) {
- testURL := util.Netflix + strconv.Itoa(MoiveID)
+ testURL := NetflixURL_PREFIX + strconv.Itoa(MoiveID)
if reCode, err := util.RequestIP(testURL, v.IP, v.LocalAddr); err != nil {
+ log.Println(reCode)
if err.Error() == "Banned" {
v.unblockTestChan <- UnblockTestResult{MoiveID, "", nil}
} else {
diff --git a/verify/ipv6.go b/verify/ipv6.go
index 05083c7..2da879d 100644
--- a/verify/ipv6.go
+++ b/verify/ipv6.go
@@ -27,28 +27,42 @@ func (v *IPv6Verifier) Execute() *VerifyResponse {
v.unblockTestChan = make(chan UnblockTestResult)
defer close(v.unblockTestChan)
- go v.UnblockTest(AreaAvailableID)
- go v.UnblockTest(SelfMadeAvailableID)
- go v.UnblockTest(NonSelfMadeAvailableID)
+ if v.Custom == "" {
+ go v.UnblockTest(AreaAvailableID)
+ go v.UnblockTest(SelfMadeAvailableID)
+ go v.UnblockTest(NonSelfMadeAvailableID)
- for i := 0; i < 3; i++ {
- switch res := <-v.unblockTestChan; {
+ for i := 0; i < 3; i++ {
+ switch res := <-v.unblockTestChan; {
- case res.err != nil:
- v.unblockStatus = NetworkUnrachable
+ case res.err != nil:
+ v.unblockStatus = NetworkUnrachable
- case res.CountryCode != "":
- switch res.movieID {
- case AreaAvailableID:
- v.upgradeStatus(AreaAvailable)
- case SelfMadeAvailableID:
- v.upgradeStatus(UnblockSelfMadeMovie)
- case NonSelfMadeAvailableID:
- v.upgradeStatus(UnblockNonSelfMadeMovie)
+ case res.CountryCode != "":
+ switch res.movieID {
+ case AreaAvailableID:
+ v.upgradeStatus(AreaAvailable)
+ case SelfMadeAvailableID:
+ v.upgradeStatus(UnblockSelfMadeMovie)
+ case NonSelfMadeAvailableID:
+ v.upgradeStatus(UnblockNonSelfMadeMovie)
+ }
+ response.CountryCode = res.CountryCode
+ response.CountryName = util.CountryCodeToCountryName(res.CountryCode)
+ default:
}
+ }
+ } else {
+ if customMovieID, err := strconv.Atoi(v.Custom); err == nil {
+ go v.UnblockTest(customMovieID)
+ }
+ res := <-v.unblockTestChan
+ if res.CountryCode != "" {
+ v.unblockStatus = CustomMovieUnblock
response.CountryCode = res.CountryCode
response.CountryName = util.CountryCodeToCountryName(res.CountryCode)
- default:
+ } else {
+ v.unblockStatus = CustomMovieBlock
}
}
response.StatusCode = v.unblockStatus
@@ -63,7 +77,7 @@ func (v *IPv6Verifier) upgradeStatus(status int) {
func (v *IPv6Verifier) UnblockTest(MoiveID int) {
- testURL := util.Netflix + strconv.Itoa(MoiveID)
+ testURL := NetflixURL_PREFIX + strconv.Itoa(MoiveID)
if reCode, err := util.RequestIP(testURL, v.IP, v.LocalAddr); err != nil {
if err.Error() == "Banned" {
v.unblockTestChan <- UnblockTestResult{MoiveID, "", nil}
diff --git a/verify/verify.go b/verify/verify.go
index 15b4f6b..38e2f60 100644
--- a/verify/verify.go
+++ b/verify/verify.go
@@ -1,15 +1,19 @@
package verify
-var AreaAvailableID = 80018499
-var SelfMadeAvailableID = 80197526
-var NonSelfMadeAvailableID = 70143836
-
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 {