mirror of
https://github.com/taigrr/godns
synced 2025-01-18 04:03:25 -08:00
commit
3812d21c42
@ -9,7 +9,7 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"golang.org/x/net/proxy"
|
||||||
"github.com/bitly/go-simplejson"
|
"github.com/bitly/go-simplejson"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -176,8 +176,24 @@ func updateIP(domainID int64, subDomainID string, subDomainName string, ip strin
|
|||||||
|
|
||||||
func postData(url string, content url.Values) (string, error) {
|
func postData(url string, content url.Values) (string, error) {
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
|
|
||||||
|
if configuration.Socks5Proxy != "" {
|
||||||
|
|
||||||
|
log.Println("use socks5 proxy:" + configuration.Socks5Proxy)
|
||||||
|
|
||||||
|
dialer, err := proxy.SOCKS5("tcp", configuration.Socks5Proxy, nil, proxy.Direct)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("can't connect to the proxy:", err)
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
httpTransport := &http.Transport{}
|
||||||
|
client.Transport = httpTransport
|
||||||
|
httpTransport.Dial = dialer.Dial
|
||||||
|
}
|
||||||
|
|
||||||
values := generateHeader(content)
|
values := generateHeader(content)
|
||||||
req, _ := http.NewRequest("POST", "https://dnsapi.cn"+url, strings.NewReader(values.Encode()))
|
req, _ := http.NewRequest("POST", "https://dnsapi.cn" + url, strings.NewReader(values.Encode()))
|
||||||
|
|
||||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||||
req.Header.Set("User-Agent", fmt.Sprintf("GoDNS/0.1 (%s)", configuration.Email))
|
req.Header.Set("User-Agent", fmt.Sprintf("GoDNS/0.1 (%s)", configuration.Email))
|
||||||
|
@ -22,6 +22,7 @@ type Settings struct {
|
|||||||
LogPath string `json:"log_path"`
|
LogPath string `json:"log_path"`
|
||||||
LogSize int `json:"log_size"`
|
LogSize int `json:"log_size"`
|
||||||
LogNum int `json:"log_num"`
|
LogNum int `json:"log_num"`
|
||||||
|
Socks5Proxy string `json:"socks5_proxy"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//LoadSettings -- Load settings from config file
|
//LoadSettings -- Load settings from config file
|
||||||
|
Loading…
x
Reference in New Issue
Block a user