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"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/net/proxy"
|
||||
"github.com/bitly/go-simplejson"
|
||||
)
|
||||
|
||||
@ -176,6 +176,22 @@ func updateIP(domainID int64, subDomainID string, subDomainName string, ip strin
|
||||
|
||||
func postData(url string, content url.Values) (string, error) {
|
||||
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)
|
||||
req, _ := http.NewRequest("POST", "https://dnsapi.cn" + url, strings.NewReader(values.Encode()))
|
||||
|
||||
|
@ -22,6 +22,7 @@ type Settings struct {
|
||||
LogPath string `json:"log_path"`
|
||||
LogSize int `json:"log_size"`
|
||||
LogNum int `json:"log_num"`
|
||||
Socks5Proxy string `json:"socks5_proxy"`
|
||||
}
|
||||
|
||||
//LoadSettings -- Load settings from config file
|
||||
|
Loading…
x
Reference in New Issue
Block a user