diff options
author | sjlleo <[email protected]> | 2022-05-21 08:04:59 +0800 |
---|---|---|
committer | sjlleo <[email protected]> | 2022-05-21 08:04:59 +0800 |
commit | 58b3823ded61031ba9ea5272ddd30429e69012ed (patch) | |
tree | a799aec32975e0648ff19e1c18348817eebc9ad8 | |
parent | 360e55128b7501eb3ece655aef35d9b9ae7324ea (diff) |
Add: Custom Movie
-rw-r--r-- | printer/printer.go | 9 | ||||
-rw-r--r-- | util/util.go | 3 | ||||
-rw-r--r-- | verify/ipv4.go | 50 | ||||
-rw-r--r-- | verify/ipv6.go | 48 | ||||
-rw-r--r-- | verify/verify.go | 12 |
5 files changed, 79 insertions, 43 deletions
diff --git a/printer/printer.go b/printer/printer.go index 7fbcef7..61b4472 100644 --- a/printer/printer.go +++ b/printer/printer.go @@ -8,7 +8,7 @@ import ( const ( AUTHOR = "@sjlleo" - VERSION = "v3.0 Alpha" + VERSION = "v3.0" RED_PREFIX = "\033[1;31m" GREEN_PREFIX = "\033[1;32m" YELLOW_PREFIX = "\033[1;33m" @@ -45,7 +45,12 @@ func printResult(ipVersion string, vResponse verify.VerifyResponse) { case code == 2: fmt.Println(GREEN_PREFIX + "您的出口IP完整解锁Netflix,支持非自制剧的观看" + RESET_PREFIX) fmt.Println(CYAN_PREFIX + "NF所识别的IP地域信息:" + vResponse.CountryName + RESET_PREFIX) + case code == 3: + fmt.Println(YELLOW_PREFIX + "您的出口IP无法观看此电影" + RESET_PREFIX) + case code == 4: + fmt.Println(GREEN_PREFIX + "您的出口IP可以观看此电影" + RESET_PREFIX) + fmt.Println(CYAN_PREFIX + "NF所识别的IP地域信息:" + vResponse.CountryName + RESET_PREFIX) default: - fmt.Println(YELLOW_PREFIX + "IPv4解锁检测失败,但是可以正常观看" + RESET_PREFIX) + fmt.Println(YELLOW_PREFIX + "解锁检测失败,请稍后重试" + RESET_PREFIX) } } diff --git a/util/util.go b/util/util.go index cce561b..3184ff4 100644 --- a/util/util.go +++ b/util/util.go @@ -1,12 +1,9 @@ package util import ( - "fmt" "strings" ) -const Netflix = "https://www.netflix.com/title/" - func CountryCodeToCountryName(Code string) string { countryName := []string{"美国", "阿富汗", "奥兰群岛", "阿尔巴尼亚", "阿尔及利亚", "美属萨摩亚", "安道尔", "安哥拉", "安圭拉", "南极洲", "安提瓜和巴布达", "阿根廷", "亚美尼亚", "阿鲁巴", "澳大利亚", "奥地利", "阿塞拜疆", "巴哈马", "巴林", "孟加拉国", "巴巴多斯", "白俄罗斯", "比利时", "伯利兹", "贝宁", "百慕大", "不丹", "玻利维亚", "波黑", "博茨瓦纳", "布维岛", "巴西", "英属印度洋领地", "文莱", "保加利亚", "布基纳法索", "布隆迪", "柬埔寨", "喀麦隆", "加拿大", "佛得角", "开曼群岛", "中非", "乍得", "智利", "中国", "圣诞岛", "科科斯(基林)群岛", "哥伦比亚", "科摩罗", "刚果(布)", "刚果(金)", "库克群岛", "哥斯达黎加", "科特迪瓦", "克罗地亚", "古巴", "塞浦路斯", "捷克", "丹麦", "吉布提", "多米尼克", "多米尼加", "厄瓜多尔", "埃及", "萨尔瓦多", "赤道几内亚", "厄立特里亚", "爱沙尼亚", "埃塞俄比亚", "福克兰群岛(马尔维纳斯)", "法罗群岛", "斐济", "芬兰", "法国", "法属圭亚那", "法属波利尼西亚", "法属南部领地", "加蓬", "冈比亚", "格鲁吉亚", "德国", "加纳", "直布罗陀", "希腊", "格陵兰", "格林纳达", "瓜德罗普", "关岛", "危地马拉", "格恩西岛", "几内亚", "几内亚比绍", "圭亚那", "海地", "赫德岛和麦克唐纳岛", "梵蒂冈", "洪都拉斯", "香港", "匈牙利", "冰岛", "印度", "印度尼西亚", "伊朗", "伊拉克", "爱尔兰", "英国属地曼岛", "以色列", "意大利", "牙买加", "日本", "泽西岛", "约旦", "哈萨克斯坦", "肯尼亚", "基里巴斯", "朝鲜", "韩国", "科威特", "吉尔吉斯斯坦", "老挝", "拉脱维亚", "黎巴嫩", "莱索托", "利比里亚", "利比亚", "列支敦士登", "立陶宛", "卢森堡", "澳门", "前南马其顿", "马达加斯加", "马拉维", "马来西亚", "马尔代夫", "马里", "马耳他", "马绍尔群岛", "马提尼克", "毛利塔尼亚", "毛里求斯", "马约特", "墨西哥", "密克罗尼西亚联邦", "摩尔多瓦", "摩纳哥", "蒙古", "黑山", "蒙特塞拉特", "摩洛哥", "莫桑比克", "缅甸", "纳米比亚", "瑙鲁", "尼泊尔", "荷兰", "荷属安的列斯", "新喀里多尼亚", "新西兰", "尼加拉瓜", "尼日尔", "尼日利亚", "纽埃", "诺福克岛", "北马里亚纳", "挪威", "阿曼", "巴基斯坦", "帕劳", "巴勒斯坦", "巴拿马", "巴布亚新几内亚", "巴拉圭", "秘鲁", "菲律宾", "皮特凯恩", "波兰", "葡萄牙", "波多黎各", "卡塔尔", "留尼汪", "罗马尼亚", "俄罗斯联邦", "卢旺达", "圣赫勒拿", "圣基茨和尼维斯", "圣卢西亚", "圣皮埃尔和密克隆", "圣文森特和格林纳丁斯", "萨摩亚", "圣马力诺", "圣多美和普林西比", "沙特阿拉伯", "塞内加尔", "塞尔维亚", "塞舌尔", "塞拉利昂", "新加坡", "斯洛伐克", "斯洛文尼亚", "所罗门群岛", "索马里", "南非", "南乔治亚岛和南桑德韦奇岛", "西班牙", "斯里兰卡", "苏丹", "苏里南", "斯瓦尔巴岛和扬马延岛", "斯威士兰", "瑞典", "瑞士", "叙利亚", "台湾", "塔吉克斯坦", "坦桑尼亚", "泰国", "东帝汶", "多哥", "托克劳", "汤加", "特立尼达和多巴哥", "突尼斯", "土耳其", "土库曼斯坦", "特克斯和凯科斯群岛", "图瓦卢", "乌干达", "乌克兰", "阿联酋", "英国", "美国本土外小岛屿", "乌拉圭", "乌兹别克斯坦", "瓦努阿图", "委内瑞拉", "越南", "英属维尔京群岛", "美属维尔京群岛", "瓦利斯和富图纳", "西撒哈拉", "也门", "赞比亚", "津巴布韦"} countryCode := []string{"us", "af", "ax", "al", "dz", "as", "ad", "ao", "ai", "aq", "ag", "ar", "am", "aw", "au", "at", "az", "bs", "bh", "bd", "bb", "by", "be", "bz", "bj", "bm", "bt", "bo", "ba", "bw", "bv", "br", "io", "bn", "bg", "bf", "bi", "kh", "cm", "ca", "cv", "ky", "cf", "td", "cl", "cn", "cx", "cc", "co", "km", "cg", "cd", "ck", "cr", "ci", "hr", "cu", "cy", "cz", "dk", "dj", "dm", "do", "ec", "eg", "sv", "gq", "er", "ee", "et", "fk", "fo", "fj", "fi", "fr", "gf", "pf", "tf", "ga", "gm", "ge", "de", "gh", "gi", "gr", "gl", "gd", "gp", "gu", "gt", "gg", "gn", "gw", "gy", "ht", "hm", "va", "hn", "hk", "hu", "is", "in", "id", "ir", "iq", "ie", "im", "il", "it", "jm", "jp", "je", "jo", "kz", "ke", "ki", "kp", "kr", "kw", "kg", "la", "lv", "lb", "ls", "lr", "ly", "li", "lt", "lu", "mo", "mk", "mg", "mw", "my", "mv", "ml", "mt", "mh", "mq", "mr", "mu", "yt", "mx", "fm", "md", "mc", "mn", "me", "ms", "ma", "mz", "mm", "na", "nr", "np", "nl", "an", "nc", "nz", "ni", "ne", "ng", "nu", "nf", "mp", "no", "om", "pk", "pw", "ps", "pa", "pg", "py", "pe", "ph", "pn", "pl", "pt", "pr", "qa", "re", "ro", "ru", "rw", "sh", "kn", "lc", "pm", "vc", "ws", "sm", "st", "sa", "sn", "rs", "sc", "sl", "sg", "sk", "si", "sb", "so", "za", "gs", "es", "lk", "sd", "sr", "sj", "sz", "se", "ch", "sy", "tw", "tj", "tz", "th", "tl", "tg", "tk", "to", "tt", "tn", "tr", "tm", "tc", "tv", "ug", "ua", "ae", "gb", "um", "uy", "uz", "vu", "ve", "vn", "vg", "vi", "wf", "eh", "ye", "zm", "zw"} 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 { |