Compare commits

...

7 Commits

Author SHA1 Message Date
Star Brilliant
12df47f45f Release 1.3.2 2018-04-17 03:28:36 +08:00
Star Brilliant
450c10a594 Fix version number in User-Agent 2018-04-17 03:27:42 +08:00
Star Brilliant
e7c4450787 Fix build system 2018-04-17 03:27:21 +08:00
Star Brilliant
bd5ef5d61e Fix build 2018-04-16 21:36:26 +08:00
Star Brilliant
ff0e9529cb Update User-Agent 2018-04-16 21:35:33 +08:00
Star Brilliant
627e2d639d Release 1.3.1 2018-04-16 13:59:03 +08:00
Star Brilliant
7d5cf98d2b Fix the "address already in use" issue 2018-04-16 13:58:38 +08:00
8 changed files with 64 additions and 26 deletions

View File

@@ -4,6 +4,14 @@ This Changelog records major changes between versions.
Not all changes are recorded. Please check git log for details. Not all changes are recorded. Please check git log for details.
## Version 1.3.2
- Fix version string in HTTP User-Agent
## Version 1.3.1
- Fix the "address already in use" issue
## Version 1.3.0 ## Version 1.3.0
- Breaking change: Add client / server support for multiple listen address - Breaking change: Add client / server support for multiple listen address

View File

@@ -2,6 +2,7 @@
GOBUILD=go build GOBUILD=go build
GOGET=go get -d -v GOGET=go get -d -v
GOGET_UPDATE=go get -d -u -v
PREFIX=/usr/local PREFIX=/usr/local
ifeq ($(shell uname),Darwin) ifeq ($(shell uname),Darwin)
CONFDIR=/usr/local/etc/dns-over-https CONFDIR=/usr/local/etc/dns-over-https
@@ -40,6 +41,8 @@ uninstall:
fi fi
deps: deps:
@# I am not sure if it is the correct way to keep the common library updated
$(GOGET_UPDATE) github.com/m13253/dns-over-https/json-dns
$(GOGET) ./doh-client ./doh-server $(GOGET) ./doh-client ./doh-server
doh-client/doh-client: deps doh-client/client.go doh-client/config.go doh-client/google.go doh-client/ietf.go doh-client/main.go json-dns/error.go json-dns/globalip.go json-dns/marshal.go json-dns/response.go json-dns/unmarshal.go doh-client/doh-client: deps doh-client/client.go doh-client/config.go doh-client/google.go doh-client/ietf.go doh-client/main.go json-dns/error.go json-dns/globalip.go json-dns/marshal.go json-dns/response.go json-dns/unmarshal.go

View File

@@ -154,24 +154,24 @@ func (c *Client) newHTTPClient() error {
} }
func (c *Client) Start() error { func (c *Client) Start() error {
result := make(chan error, len(c.udpServers)+len(c.tcpServers)) results := make(chan error, len(c.udpServers)+len(c.tcpServers))
for _, srv := range append(c.udpServers, c.tcpServers...) { for _, srv := range append(c.udpServers, c.tcpServers...) {
go func(srv *dns.Server) { go func(srv *dns.Server) {
err := srv.ListenAndServe() err := srv.ListenAndServe()
if err != nil { if err != nil {
log.Println(err) log.Println(err)
} }
result <- err results <- err
}(srv) }(srv)
} }
for i := 0; i < cap(result); i++ { for i := 0; i < cap(results); i++ {
err := <-result err := <-results
if err != nil { if err != nil {
return err return err
} }
} }
close(result) close(results)
return nil return nil
} }

View File

@@ -92,7 +92,7 @@ func (c *Client) generateRequestGoogle(w dns.ResponseWriter, r *dns.Msg, isTCP b
} }
} }
req.Header.Set("Accept", "application/json, application/dns-message, application/dns-udpwireformat") req.Header.Set("Accept", "application/json, application/dns-message, application/dns-udpwireformat")
req.Header.Set("User-Agent", "DNS-over-HTTPS/1.1 (+https://github.com/m13253/dns-over-https)") req.Header.Set("User-Agent", jsonDNS.USER_AGENT)
c.httpClientMux.RLock() c.httpClientMux.RLock()
resp, err := c.httpClient.Do(req) resp, err := c.httpClient.Do(req)
c.httpClientMux.RUnlock() c.httpClientMux.RUnlock()

View File

@@ -154,7 +154,7 @@ func (c *Client) generateRequestIETF(w dns.ResponseWriter, r *dns.Msg, isTCP boo
req.Header.Set("Content-Type", "application/dns-message") req.Header.Set("Content-Type", "application/dns-message")
} }
req.Header.Set("Accept", "application/dns-message, application/dns-udpwireformat, application/json") req.Header.Set("Accept", "application/dns-message, application/dns-udpwireformat, application/json")
req.Header.Set("User-Agent", "DNS-over-HTTPS/1.1 (+https://github.com/m13253/dns-over-https)") req.Header.Set("User-Agent", jsonDNS.USER_AGENT)
c.httpClientMux.RLock() c.httpClientMux.RLock()
resp, err := c.httpClient.Do(req) resp, err := c.httpClient.Do(req)
c.httpClientMux.RUnlock() c.httpClientMux.RUnlock()

View File

@@ -43,8 +43,5 @@ func main() {
} }
server := NewServer(conf) server := NewServer(conf)
err = server.Start() _ = server.Start()
if err != nil {
log.Fatalln(err)
}
} }

View File

@@ -75,32 +75,35 @@ func (s *Server) Start() error {
if s.conf.Verbose { if s.conf.Verbose {
servemux = handlers.CombinedLoggingHandler(os.Stdout, servemux) servemux = handlers.CombinedLoggingHandler(os.Stdout, servemux)
} }
listeners := make(chan error, len(s.conf.Listen)) results := make(chan error, len(s.conf.Listen))
for _, addr := range s.conf.Listen { for _, addr := range s.conf.Listen {
if s.conf.Cert != "" || s.conf.Key != "" { go func(addr string) {
go func() { var err error
listeners <- http.ListenAndServeTLS(addr, s.conf.Cert, s.conf.Key, servemux) if s.conf.Cert != "" || s.conf.Key != "" {
}() err = http.ListenAndServeTLS(addr, s.conf.Cert, s.conf.Key, servemux)
continue } else {
} err = http.ListenAndServe(addr, servemux)
go func() { }
listeners <- http.ListenAndServe(addr, servemux) if err != nil {
}() log.Println(err)
}
results <- err
}(addr)
} }
// wait for all handlers // wait for all handlers
for i := 0; i < cap(listeners); i++ { for i := 0; i < cap(results); i++ {
err := <-listeners err := <-results
if err != nil { if err != nil {
return err return err
} }
} }
close(listeners) close(results)
return nil return nil
} }
func (s *Server) handlerFunc(w http.ResponseWriter, r *http.Request) { func (s *Server) handlerFunc(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Server", "DNS-over-HTTPS/1.1 (+https://github.com/m13253/dns-over-https)") w.Header().Set("Server", jsonDNS.USER_AGENT)
w.Header().Set("X-Powered-By", "DNS-over-HTTPS/1.1 (+https://github.com/m13253/dns-over-https)") w.Header().Set("X-Powered-By", jsonDNS.USER_AGENT)
if r.Form == nil { if r.Form == nil {
const maxMemory = 32 << 20 // 32 MB const maxMemory = 32 << 20 // 32 MB

27
json-dns/version.go Normal file
View File

@@ -0,0 +1,27 @@
/*
DNS-over-HTTPS
Copyright (C) 2017-2018 Star Brilliant <m13253@hotmail.com>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
package jsonDNS
const VERSION = "1.3.2"
const USER_AGENT = "DNS-over-HTTPS/" + VERSION + " (+https://github.com/m13253/dns-over-https)"