mirror of
https://github.com/m13253/dns-over-https.git
synced 2026-10-15 09:01:50 +00:00
Disable logging by default
This commit is contained in:
@@ -40,17 +40,19 @@ type Client struct {
|
||||
bootstrap string
|
||||
timeout uint
|
||||
noECS bool
|
||||
verbose bool
|
||||
udpServer *dns.Server
|
||||
tcpServer *dns.Server
|
||||
httpClient *http.Client
|
||||
}
|
||||
|
||||
func NewClient(addr, upstream, bootstrap string, timeout uint, noECS bool) (c *Client, err error) {
|
||||
func NewClient(addr, upstream, bootstrap string, timeout uint, noECS, verbose bool) (c *Client, err error) {
|
||||
c = &Client {
|
||||
addr: addr,
|
||||
upstream: upstream,
|
||||
timeout: timeout,
|
||||
noECS: noECS,
|
||||
verbose: verbose,
|
||||
}
|
||||
c.udpServer = &dns.Server {
|
||||
Addr: addr,
|
||||
@@ -140,7 +142,9 @@ func (c *Client) handlerFunc(w dns.ResponseWriter, r *dns.Msg, isTCP bool) {
|
||||
questionType = strconv.Itoa(int(question.Qtype))
|
||||
}
|
||||
|
||||
fmt.Printf("%s - - [%s] \"%s IN %s\"\n", w.RemoteAddr(), time.Now().Format("02/Jan/2006:15:04:05 -0700"), questionName, questionType)
|
||||
if c.verbose{
|
||||
fmt.Printf("%s - - [%s] \"%s IN %s\"\n", w.RemoteAddr(), time.Now().Format("02/Jan/2006:15:04:05 -0700"), questionName, questionType)
|
||||
}
|
||||
|
||||
requestURL := fmt.Sprintf("%s?name=%s&type=%s", c.upstream, url.QueryEscape(questionName), url.QueryEscape(questionType))
|
||||
|
||||
|
||||
+2
-1
@@ -29,9 +29,10 @@ func main() {
|
||||
bootstrap := flag.String("bootstrap", "", "The bootstrap DNS server to resolve the address of the upstream resolver")
|
||||
timeout := flag.Uint("timeout", 10, "Timeout for upstream request")
|
||||
noECS := flag.Bool("no-ecs", false, "Disable EDNS0-Client-Subnet, do not send client's IP address")
|
||||
verbose := flag.Bool("verbose", false, "Enable logging")
|
||||
flag.Parse()
|
||||
|
||||
client, err := NewClient(*addr, *upstream, *bootstrap, *timeout, *noECS)
|
||||
client, err := NewClient(*addr, *upstream, *bootstrap, *timeout, *noECS, *verbose)
|
||||
if err != nil { log.Fatalln(err) }
|
||||
_ = client.Start()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user