diff options
author | caobug <[email protected]> | 2021-10-08 03:27:13 +0800 |
---|---|---|
committer | caobug <[email protected]> | 2021-10-08 03:27:13 +0800 |
commit | f220261d98af524dc0f603db3bc9483a2a0d5e55 (patch) | |
tree | 4bb991f8a17719f22bc727d89226f36ecced2995 | |
parent | febf26187f23bd7f98f8bd6f13fa79461fdc9b91 (diff) |
Specify network address to use
-rw-r--r-- | nf.go | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -2,6 +2,7 @@ package main import ( "crypto/tls" + "flag" "fmt" "net" "net/http" @@ -10,12 +11,12 @@ import ( "strconv" "strings" "time" - "flag" ) const Netflix = "https://www.netflix.com/title/" var method = flag.String("method","","模式选择(full/lite)") var custom = flag.String("custom","","自定义测试NF影片ID\n绝命毒师的ID是70143836") +var address = flag.String("address", "", "本机公网IP") func RequestIP(requrl string, ip string) string { if ip == "" { @@ -35,6 +36,11 @@ func RequestIP(requrl string, ip string) string { TLSClientConfig: &tls.Config{ServerName: host}, // goodryb pull Proxy: http.ProxyFromEnvironment, + DialContext: (&net.Dialer{ + LocalAddr: &net.TCPAddr{ + IP: net.ParseIP(*address), + }, + }).DialContext, }, CheckRedirect: func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse }, Timeout: 5 * time.Second, |