mirror of
https://github.com/m13253/dns-over-https.git
synced 2026-03-31 18:25:38 +00:00
Compare commits
49 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d9ea18607 | ||
|
|
967ca0103e | ||
|
|
6fb0df257e | ||
|
|
d00be8b698 | ||
|
|
f08eb16d0b | ||
|
|
2bda149686 | ||
|
|
299e8f9245 | ||
|
|
f3e529865a | ||
|
|
94bc8c0587 | ||
|
|
f5f03513f8 | ||
|
|
9e1f2c70cc | ||
|
|
979780c8d5 | ||
|
|
f697ba1e1e | ||
|
|
32f3ad71f7 | ||
|
|
83924dd76b | ||
|
|
e72363306b | ||
|
|
e4d309bbc0 | ||
|
|
0690c41610 | ||
|
|
244e4b5b8f | ||
|
|
a7708f71b3 | ||
|
|
d6a5c91f67 | ||
|
|
fdc1b81e42 | ||
|
|
70fc8578c7 | ||
|
|
94c223df4b | ||
|
|
b9bf6e80f4 | ||
|
|
1b7eed5afe | ||
|
|
393019fc14 | ||
|
|
604daa663f | ||
|
|
8bedfc4bab | ||
|
|
ae0333f1c2 | ||
|
|
34014d847e | ||
|
|
71eecf7b8a | ||
|
|
6e74bbd061 | ||
|
|
f212286c4f | ||
|
|
1fff629074 | ||
|
|
533ea58e67 | ||
|
|
b7b935767f | ||
|
|
f1b3133982 | ||
|
|
a519b5a9c4 | ||
|
|
80e95cd028 | ||
|
|
1d59772fad | ||
|
|
a375bea95d | ||
|
|
b98b01cc4e | ||
|
|
6276bed46f | ||
|
|
19737361ad | ||
|
|
791d2d43dd | ||
|
|
90753c3910 | ||
|
|
221240a840 | ||
|
|
b338c7ae52 |
36
.github/workflows/docker.yml
vendored
Normal file
36
.github/workflows/docker.yml
vendored
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
name: "Docker"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
environment: "Docker Hub"
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
variant: ["client", "server"]
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v2
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
-
|
||||||
|
name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
logout: true
|
||||||
|
- # TODO: port https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners
|
||||||
|
name: Build and push
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
file: ./Dockerfile.${{ matrix.variant }}
|
||||||
|
tags: m13253/dns-over-https-${{ matrix.variant }}:latest
|
||||||
|
push: true
|
||||||
|
platforms: "linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8"
|
||||||
4
.github/workflows/go.yml
vendored
4
.github/workflows/go.yml
vendored
@@ -4,13 +4,13 @@ jobs:
|
|||||||
|
|
||||||
build:
|
build:
|
||||||
name: Build
|
name: Build
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.13
|
go-version: 1.21
|
||||||
id: go
|
id: go
|
||||||
|
|
||||||
- name: Check out repository
|
- name: Check out repository
|
||||||
|
|||||||
20
Changelog.md
20
Changelog.md
@@ -4,6 +4,26 @@ 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 2.3.3
|
||||||
|
|
||||||
|
- systemd: Use DynamicUser=yes instead of User=nobody (Fixed #139)
|
||||||
|
- Migrate deprecated Go packages `ioutil` to `io` and `os`
|
||||||
|
- Fix a bug that truncates the response improperly, causing malformed DNS responsed (Fixed #144)
|
||||||
|
|
||||||
|
## Version 2.3.2
|
||||||
|
|
||||||
|
- Documentation updates, including deploying recommenation alongside DoT, thanks @gdm85
|
||||||
|
- Add unit tests for CIDR subnets parsing, thanks @gdm85
|
||||||
|
- Removing Firefox 61-62 patch
|
||||||
|
|
||||||
|
Since this version, @gdm85, @GreyXor, @Jamesits will be able to maintain this repository alongside @m13253. Anyone who contributed to this project can also apply to be a maintainer.
|
||||||
|
This is because changes in life have delayed the development of this project. By constructing a community hopefully can we restore the pace of development.
|
||||||
|
|
||||||
|
## Version 2.3.1
|
||||||
|
|
||||||
|
- No new features in this release
|
||||||
|
- Bumped versions of Go toolchain and third-party dependencies, requested by #128
|
||||||
|
|
||||||
## Version 2.3.0
|
## Version 2.3.0
|
||||||
|
|
||||||
- The repository now conforms to the Go semvar standard (Fixed #115, thanks to @leiless)
|
- The repository now conforms to the Go semvar standard (Fixed #115, thanks to @leiless)
|
||||||
|
|||||||
4
Makefile
4
Makefile
@@ -3,9 +3,9 @@
|
|||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
|
|
||||||
ifeq ($(GOROOT),)
|
ifeq ($(GOROOT),)
|
||||||
GOBUILD = go build
|
GOBUILD = go build -ldflags "-s -w"
|
||||||
else
|
else
|
||||||
GOBUILD = $(GOROOT)/bin/go build
|
GOBUILD = $(GOROOT)/bin/go build -ldflags "-s -w"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(shell uname),Darwin)
|
ifeq ($(shell uname),Darwin)
|
||||||
|
|||||||
41
Readme.md
41
Readme.md
@@ -11,8 +11,8 @@ and [IETF DNS-over-HTTPS (RFC 8484)](https://www.rfc-editor.org/rfc/rfc8484.txt)
|
|||||||
|
|
||||||
## Installing
|
## Installing
|
||||||
### From Source
|
### From Source
|
||||||
- Install [Go](https://golang.org), at least version 1.13. The newer the better.
|
- Install [Go](https://golang.org), at least version 1.20. The newer, the better.
|
||||||
> Note for Debian/Ubuntu users: You need to set `$GOROOT` if you could not get your new version of Go selected by the Makefile.)
|
> Note for Debian/Ubuntu users: You need to set `$GOROOT` if you could not get your new version of Go selected by the Makefile.
|
||||||
|
|
||||||
- First create an empty directory, used for `$GOPATH`:
|
- First create an empty directory, used for `$GOPATH`:
|
||||||
```bash
|
```bash
|
||||||
@@ -67,6 +67,15 @@ docker run -d --name doh-server \
|
|||||||
satishweb/doh-server
|
satishweb/doh-server
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Feeling adventurous? Try the latest build:
|
||||||
|
|
||||||
|
- `m13253/dns-over-https-server:latest`
|
||||||
|
- `m13253/dns-over-https-client:latest`
|
||||||
|
|
||||||
|
## Logging
|
||||||
|
|
||||||
|
All log lines (by either doh-client or doh-server) are written into `stderr`; you can view them using your OS tool of choice (`journalctl` when using systemd).
|
||||||
|
|
||||||
## Server Configuration
|
## Server Configuration
|
||||||
|
|
||||||
The following is a typical DNS-over-HTTPS architecture:
|
The following is a typical DNS-over-HTTPS architecture:
|
||||||
@@ -84,7 +93,7 @@ The following is a typical DNS-over-HTTPS architecture:
|
|||||||
| doh-client +--+ Content Delivery Network +--+ (Apache, Nginx, Caddy) |
|
| doh-client +--+ Content Delivery Network +--+ (Apache, Nginx, Caddy) |
|
||||||
+--------------+ +--------------------------+ +------------------------+
|
+--------------+ +--------------------------+ +------------------------+
|
||||||
|
|
||||||
Although DNS-over-HTTPS can work alone, a HTTP service muxer would be useful as
|
Although DNS-over-HTTPS can work alone, an HTTP service muxer would be useful as
|
||||||
you can host DNS-over-HTTPS along with other HTTPS services.
|
you can host DNS-over-HTTPS along with other HTTPS services.
|
||||||
|
|
||||||
HTTP/2 with at least TLS v1.3 is recommended. OCSP stapling must be enabled,
|
HTTP/2 with at least TLS v1.3 is recommended. OCSP stapling must be enabled,
|
||||||
@@ -127,7 +136,7 @@ server {
|
|||||||
|
|
||||||
server_tokens off;
|
server_tokens off;
|
||||||
|
|
||||||
ssl_protocols TLSv1.2 TLSv1.3; # TLS 1.3 requires nginx >= 1.13.0
|
ssl_protocols TLSv1.2 TLSv1.3; # TLS 1.3 requires nginx >= 1.20.0
|
||||||
ssl_prefer_server_ciphers on;
|
ssl_prefer_server_ciphers on;
|
||||||
ssl_dhparam /etc/nginx/dhparam.pem; # openssl dhparam -dsaparam -out /etc/nginx/dhparam.pem 4096
|
ssl_dhparam /etc/nginx/dhparam.pem; # openssl dhparam -dsaparam -out /etc/nginx/dhparam.pem 4096
|
||||||
ssl_ciphers EECDH+AESGCM:EDH+AESGCM;
|
ssl_ciphers EECDH+AESGCM:EDH+AESGCM;
|
||||||
@@ -269,10 +278,28 @@ services:
|
|||||||
|
|
||||||
> IPV6 Support for Docker Compose based configuration TBA
|
> IPV6 Support for Docker Compose based configuration TBA
|
||||||
|
|
||||||
|
### Example configuration: DNS-over-TLS
|
||||||
|
|
||||||
|
There is no native [DNS-over-TLS](https://en.wikipedia.org/wiki/DNS_over_TLS) support, but you can easily add it via nginx:
|
||||||
|
```
|
||||||
|
stream {
|
||||||
|
server {
|
||||||
|
listen *:853 ssl;
|
||||||
|
proxy_pass ipofyourdnsresolver:port #127.0.0.1:53
|
||||||
|
}
|
||||||
|
|
||||||
|
ssl_certificate /etc/letsencrypt/live/site.yourdomain/fullchain.pem;
|
||||||
|
ssl_certificate_key /etc/letsencrypt/live/site.yourdomain/privkey.pem;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The DoT service can also be provided by running a [STunnel](https://www.stunnel.org/) instance to wrap dnsmasq (or any other resolver of your choice, listening on a TCP port);
|
||||||
|
this approach does not need a stand-alone daemon to provide the DoT service.
|
||||||
|
|
||||||
## DNSSEC
|
## DNSSEC
|
||||||
|
|
||||||
DNS-over-HTTPS is compatible with DNSSEC, and requests DNSSEC signatures by
|
DNS-over-HTTPS is compatible with DNSSEC, and requests DNSSEC signatures by
|
||||||
default. However signature validation is not built-in. It is highly recommended
|
default. However, signature validation is not built-in. It is highly recommended
|
||||||
that you install `unbound` or `bind` and pass results for them to validate DNS
|
that you install `unbound` or `bind` and pass results for them to validate DNS
|
||||||
records. An instance of [Pi Hole](https://pi-hole.net) could also be used to validate DNS signatures as well as provide other capabilities.
|
records. An instance of [Pi Hole](https://pi-hole.net) could also be used to validate DNS signatures as well as provide other capabilities.
|
||||||
|
|
||||||
@@ -315,6 +342,10 @@ Currently supported features are:
|
|||||||
- [X] EDNS0 large UDP packet (4 KiB by default)
|
- [X] EDNS0 large UDP packet (4 KiB by default)
|
||||||
- [X] EDNS0-Client-Subnet (/24 for IPv4, /56 for IPv6 by default)
|
- [X] EDNS0-Client-Subnet (/24 for IPv4, /56 for IPv6 by default)
|
||||||
|
|
||||||
|
## Known issues
|
||||||
|
|
||||||
|
* it does not work well with [dnscrypt-proxy](https://github.com/DNSCrypt/dnscrypt-proxy), you might want to use either (or fix the compatibility bugs by submitting PRs)
|
||||||
|
|
||||||
## The name of the project
|
## The name of the project
|
||||||
|
|
||||||
This project is named "DNS-over-HTTPS" because it was written before the IETF DoH project. Although this project is compatible with IETF DoH, the project is not affiliated with IETF.
|
This project is named "DNS-over-HTTPS" because it was written before the IETF DoH project. Although this project is compatible with IETF DoH, the project is not affiliated with IETF.
|
||||||
|
|||||||
@@ -38,39 +38,40 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/m13253/dns-over-https/v2/doh-client/config"
|
|
||||||
"github.com/m13253/dns-over-https/v2/doh-client/selector"
|
|
||||||
jsondns "github.com/m13253/dns-over-https/v2/json-dns"
|
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
"golang.org/x/net/http2"
|
"golang.org/x/net/http2"
|
||||||
"golang.org/x/net/idna"
|
"golang.org/x/net/idna"
|
||||||
|
|
||||||
|
"github.com/m13253/dns-over-https/v2/doh-client/config"
|
||||||
|
"github.com/m13253/dns-over-https/v2/doh-client/selector"
|
||||||
|
jsondns "github.com/m13253/dns-over-https/v2/json-dns"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
conf *config.Config
|
httpClientLastCreate time.Time
|
||||||
bootstrap []string
|
|
||||||
passthrough []string
|
|
||||||
udpClient *dns.Client
|
|
||||||
tcpClient *dns.Client
|
|
||||||
udpServers []*dns.Server
|
|
||||||
tcpServers []*dns.Server
|
|
||||||
bootstrapResolver *net.Resolver
|
|
||||||
cookieJar http.CookieJar
|
cookieJar http.CookieJar
|
||||||
|
selector selector.Selector
|
||||||
httpClientMux *sync.RWMutex
|
httpClientMux *sync.RWMutex
|
||||||
|
tcpClient *dns.Client
|
||||||
|
bootstrapResolver *net.Resolver
|
||||||
|
udpClient *dns.Client
|
||||||
|
conf *config.Config
|
||||||
httpTransport *http.Transport
|
httpTransport *http.Transport
|
||||||
httpClient *http.Client
|
httpClient *http.Client
|
||||||
httpClientLastCreate time.Time
|
udpServers []*dns.Server
|
||||||
selector selector.Selector
|
tcpServers []*dns.Server
|
||||||
|
passthrough []string
|
||||||
|
bootstrap []string
|
||||||
}
|
}
|
||||||
|
|
||||||
type DNSRequest struct {
|
type DNSRequest struct {
|
||||||
|
err error
|
||||||
response *http.Response
|
response *http.Response
|
||||||
reply *dns.Msg
|
reply *dns.Msg
|
||||||
udpSize uint16
|
|
||||||
ednsClientAddress net.IP
|
|
||||||
ednsClientNetmask uint8
|
|
||||||
currentUpstream string
|
currentUpstream string
|
||||||
err error
|
ednsClientAddress net.IP
|
||||||
|
udpSize uint16
|
||||||
|
ednsClientNetmask uint8
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClient(conf *config.Config) (c *Client, err error) {
|
func NewClient(conf *config.Config) (c *Client, err error) {
|
||||||
@@ -427,7 +428,7 @@ func (c *Client) handlerFunc(w dns.ResponseWriter, r *dns.Msg, isTCP bool) {
|
|||||||
|
|
||||||
// https://developers.cloudflare.com/1.1.1.1/dns-over-https/request-structure/ says
|
// https://developers.cloudflare.com/1.1.1.1/dns-over-https/request-structure/ says
|
||||||
// returns code will be 200 / 400 / 413 / 415 / 504, some server will return 503, so
|
// returns code will be 200 / 400 / 413 / 415 / 504, some server will return 503, so
|
||||||
// I think if status code is 5xx, upstream must has some problems
|
// I think if status code is 5xx, upstream must have some problems
|
||||||
/*if req.response.StatusCode/100 == 5 {
|
/*if req.response.StatusCode/100 == 5 {
|
||||||
c.selector.ReportUpstreamStatus(upstream, selector.Medium)
|
c.selector.ReportUpstreamStatus(upstream, selector.Medium)
|
||||||
}*/
|
}*/
|
||||||
|
|||||||
@@ -27,16 +27,17 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/miekg/dns"
|
||||||
|
|
||||||
"github.com/m13253/dns-over-https/v2/doh-client/selector"
|
"github.com/m13253/dns-over-https/v2/doh-client/selector"
|
||||||
jsondns "github.com/m13253/dns-over-https/v2/json-dns"
|
jsondns "github.com/m13253/dns-over-https/v2/json-dns"
|
||||||
"github.com/miekg/dns"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Client) generateRequestGoogle(ctx context.Context, w dns.ResponseWriter, r *dns.Msg, isTCP bool, upstream *selector.Upstream) *DNSRequest {
|
func (c *Client) generateRequestGoogle(ctx context.Context, w dns.ResponseWriter, r *dns.Msg, isTCP bool, upstream *selector.Upstream) *DNSRequest {
|
||||||
@@ -77,7 +78,7 @@ func (c *Client) generateRequestGoogle(ctx context.Context, w dns.ResponseWriter
|
|||||||
requestURL += fmt.Sprintf("&edns_client_subnet=%s/%d", ednsClientAddress.String(), ednsClientNetmask)
|
requestURL += fmt.Sprintf("&edns_client_subnet=%s/%d", ednsClientAddress.String(), ednsClientNetmask)
|
||||||
}
|
}
|
||||||
|
|
||||||
req, err := http.NewRequest(http.MethodGet, requestURL, nil)
|
req, err := http.NewRequest(http.MethodGet, requestURL, http.NoBody)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
reply := jsondns.PrepareReply(r)
|
reply := jsondns.PrepareReply(r)
|
||||||
@@ -140,7 +141,7 @@ func (c *Client) parseResponseGoogle(ctx context.Context, w dns.ResponseWriter,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(req.response.Body)
|
body, err := io.ReadAll(req.response.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
req.reply.Rcode = dns.RcodeServerFailure
|
req.reply.Rcode = dns.RcodeServerFailure
|
||||||
@@ -163,6 +164,11 @@ func (c *Client) parseResponseGoogle(ctx context.Context, w dns.ResponseWriter,
|
|||||||
fixEmptyNames(&respJSON)
|
fixEmptyNames(&respJSON)
|
||||||
|
|
||||||
fullReply := jsondns.Unmarshal(req.reply, &respJSON, req.udpSize, req.ednsClientNetmask)
|
fullReply := jsondns.Unmarshal(req.reply, &respJSON, req.udpSize, req.ednsClientNetmask)
|
||||||
|
if isTCP {
|
||||||
|
fullReply.Truncate(dns.MaxMsgSize)
|
||||||
|
} else {
|
||||||
|
fullReply.Truncate(int(req.udpSize))
|
||||||
|
}
|
||||||
buf, err := fullReply.Pack()
|
buf, err := fullReply.Pack()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
@@ -170,15 +176,6 @@ func (c *Client) parseResponseGoogle(ctx context.Context, w dns.ResponseWriter,
|
|||||||
w.WriteMsg(req.reply)
|
w.WriteMsg(req.reply)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !isTCP && len(buf) > int(req.udpSize) {
|
|
||||||
fullReply.Truncated = true
|
|
||||||
buf, err = fullReply.Pack()
|
|
||||||
if err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
buf = buf[:req.udpSize]
|
|
||||||
}
|
|
||||||
w.Write(buf)
|
w.Write(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,16 +28,17 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/miekg/dns"
|
||||||
|
|
||||||
"github.com/m13253/dns-over-https/v2/doh-client/selector"
|
"github.com/m13253/dns-over-https/v2/doh-client/selector"
|
||||||
jsondns "github.com/m13253/dns-over-https/v2/json-dns"
|
jsondns "github.com/m13253/dns-over-https/v2/json-dns"
|
||||||
"github.com/miekg/dns"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Client) generateRequestIETF(ctx context.Context, w dns.ResponseWriter, r *dns.Msg, isTCP bool, upstream *selector.Upstream) *DNSRequest {
|
func (c *Client) generateRequestIETF(ctx context.Context, w dns.ResponseWriter, r *dns.Msg, isTCP bool, upstream *selector.Upstream) *DNSRequest {
|
||||||
@@ -104,7 +105,7 @@ func (c *Client) generateRequestIETF(ctx context.Context, w dns.ResponseWriter,
|
|||||||
|
|
||||||
var req *http.Request
|
var req *http.Request
|
||||||
if len(requestURL) < 2048 {
|
if len(requestURL) < 2048 {
|
||||||
req, err = http.NewRequest(http.MethodGet, requestURL, nil)
|
req, err = http.NewRequest(http.MethodGet, requestURL, http.NoBody)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
reply := jsondns.PrepareReply(r)
|
reply := jsondns.PrepareReply(r)
|
||||||
@@ -178,7 +179,7 @@ func (c *Client) parseResponseIETF(ctx context.Context, w dns.ResponseWriter, r
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(req.response.Body)
|
body, err := io.ReadAll(req.response.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("read error from upstream %s: %v\n", req.currentUpstream, err)
|
log.Printf("read error from upstream %s: %v\n", req.currentUpstream, err)
|
||||||
req.reply.Rcode = dns.RcodeServerFailure
|
req.reply.Rcode = dns.RcodeServerFailure
|
||||||
@@ -231,6 +232,11 @@ func (c *Client) parseResponseIETF(ctx context.Context, w dns.ResponseWriter, r
|
|||||||
_ = fixRecordTTL(rr, timeDelta)
|
_ = fixRecordTTL(rr, timeDelta)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if isTCP {
|
||||||
|
fullReply.Truncate(dns.MaxMsgSize)
|
||||||
|
} else {
|
||||||
|
fullReply.Truncate(int(req.udpSize))
|
||||||
|
}
|
||||||
buf, err := fullReply.Pack()
|
buf, err := fullReply.Pack()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("packing error with upstream %s: %v\n", req.currentUpstream, err)
|
log.Printf("packing error with upstream %s: %v\n", req.currentUpstream, err)
|
||||||
@@ -238,15 +244,6 @@ func (c *Client) parseResponseIETF(ctx context.Context, w dns.ResponseWriter, r
|
|||||||
w.WriteMsg(req.reply)
|
w.WriteMsg(req.reply)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !isTCP && len(buf) > int(req.udpSize) {
|
|
||||||
fullReply.Truncated = true
|
|
||||||
buf, err = fullReply.Pack()
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("re-packing error with upstream %s: %v\n", req.currentUpstream, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
buf = buf[:req.udpSize]
|
|
||||||
}
|
|
||||||
_, err = w.Write(buf)
|
_, err = w.Write(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("failed to write to client: %v\n", err)
|
log.Printf("failed to write to client: %v\n", err)
|
||||||
|
|||||||
@@ -26,8 +26,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
@@ -38,9 +36,9 @@ import (
|
|||||||
|
|
||||||
func checkPIDFile(pidFile string) (bool, error) {
|
func checkPIDFile(pidFile string) (bool, error) {
|
||||||
retry:
|
retry:
|
||||||
f, err := os.OpenFile(pidFile, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0666)
|
f, err := os.OpenFile(pidFile, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0o666)
|
||||||
if os.IsExist(err) {
|
if os.IsExist(err) {
|
||||||
pidStr, err := ioutil.ReadFile(pidFile)
|
pidStr, err := os.ReadFile(pidFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -64,7 +62,7 @@ retry:
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
_, err = io.WriteString(f, strconv.FormatInt(int64(os.Getpid()), 10))
|
_, err = f.WriteString(strconv.FormatInt(int64(os.Getpid()), 10))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ func (ls *LVSWRRSelector) StartEvaluate() {
|
|||||||
acceptType = "application/dns-message"
|
acceptType = "application/dns-message"
|
||||||
}
|
}
|
||||||
|
|
||||||
req, err := http.NewRequest(http.MethodGet, upstreamURL, nil)
|
req, err := http.NewRequest(http.MethodGet, upstreamURL, http.NoBody)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
/*log.Println("upstream:", upstreamURL, "type:", typeMap[upstream.Type], "check failed:", err)
|
/*log.Println("upstream:", upstreamURL, "type:", typeMap[upstream.Type], "check failed:", err)
|
||||||
continue*/
|
continue*/
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ func (ws *NginxWRRSelector) StartEvaluate() {
|
|||||||
acceptType = "application/dns-message"
|
acceptType = "application/dns-message"
|
||||||
}
|
}
|
||||||
|
|
||||||
req, err := http.NewRequest(http.MethodGet, upstreamURL, nil)
|
req, err := http.NewRequest(http.MethodGet, upstreamURL, http.NoBody)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
/*log.Println("upstream:", upstreamURL, "type:", typeMap[upstream.Type], "check failed:", err)
|
/*log.Println("upstream:", upstreamURL, "type:", typeMap[upstream.Type], "check failed:", err)
|
||||||
continue*/
|
continue*/
|
||||||
@@ -110,7 +110,7 @@ func (ws *NginxWRRSelector) StartEvaluate() {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
// nginx wrr like
|
// nginx wrr like.
|
||||||
func (ws *NginxWRRSelector) Get() *Upstream {
|
func (ws *NginxWRRSelector) Get() *Upstream {
|
||||||
var (
|
var (
|
||||||
total int32
|
total int32
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.NewSource(time.Now().UnixNano())
|
||||||
}
|
}
|
||||||
|
|
||||||
type RandomSelector struct {
|
type RandomSelector struct {
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ package selector
|
|||||||
type upstreamStatus int
|
type upstreamStatus int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// when query upstream timeout, usually upstream is unavailable for a long time
|
// when query upstream timeout, usually upstream is unavailable for a long time.
|
||||||
Timeout upstreamStatus = iota
|
Timeout upstreamStatus = iota
|
||||||
|
|
||||||
// when query upstream return 5xx response, upstream still alive, maybe just a lof of query for him
|
// when query upstream return 5xx response, upstream still alive, maybe just a lof of query for him.
|
||||||
Error
|
Error
|
||||||
|
|
||||||
// when query upstream ok, means upstream is available
|
// when query upstream ok, means upstream is available.
|
||||||
OK
|
OK
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -24,6 +24,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
const (
|
const (
|
||||||
VERSION = "2.3.0"
|
VERSION = "2.3.4"
|
||||||
USER_AGENT = "DNS-over-HTTPS/" + VERSION + " (+https://github.com/m13253/dns-over-https)"
|
USER_AGENT = "DNS-over-HTTPS/" + VERSION + " (+https://github.com/m13253/dns-over-https)"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -31,21 +31,21 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type config struct {
|
type config struct {
|
||||||
Listen []string `toml:"listen"`
|
TLSClientAuthCA string `toml:"tls_client_auth_ca"`
|
||||||
LocalAddr string `toml:"local_addr"`
|
LocalAddr string `toml:"local_addr"`
|
||||||
Cert string `toml:"cert"`
|
Cert string `toml:"cert"`
|
||||||
Key string `toml:"key"`
|
Key string `toml:"key"`
|
||||||
Path string `toml:"path"`
|
Path string `toml:"path"`
|
||||||
|
DebugHTTPHeaders []string `toml:"debug_http_headers"`
|
||||||
|
Listen []string `toml:"listen"`
|
||||||
Upstream []string `toml:"upstream"`
|
Upstream []string `toml:"upstream"`
|
||||||
Timeout uint `toml:"timeout"`
|
Timeout uint `toml:"timeout"`
|
||||||
Tries uint `toml:"tries"`
|
Tries uint `toml:"tries"`
|
||||||
Verbose bool `toml:"verbose"`
|
Verbose bool `toml:"verbose"`
|
||||||
DebugHTTPHeaders []string `toml:"debug_http_headers"`
|
|
||||||
LogGuessedIP bool `toml:"log_guessed_client_ip"`
|
LogGuessedIP bool `toml:"log_guessed_client_ip"`
|
||||||
ECSAllowNonGlobalIP bool `toml:"ecs_allow_non_global_ip"`
|
ECSAllowNonGlobalIP bool `toml:"ecs_allow_non_global_ip"`
|
||||||
ECSUsePreciseIP bool `toml:"ecs_use_precise_ip"`
|
ECSUsePreciseIP bool `toml:"ecs_use_precise_ip"`
|
||||||
TLSClientAuth bool `toml:"tls_client_auth"`
|
TLSClientAuth bool `toml:"tls_client_auth"`
|
||||||
TLSClientAuthCA string `toml:"tls_client_auth_ca"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadConfig(path string) (*config, error) {
|
func loadConfig(path string) (*config, error) {
|
||||||
|
|||||||
@@ -34,9 +34,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
jsondns "github.com/m13253/dns-over-https/v2/json-dns"
|
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
"golang.org/x/net/idna"
|
"golang.org/x/net/idna"
|
||||||
|
|
||||||
|
jsondns "github.com/m13253/dns-over-https/v2/json-dns"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *Server) parseRequestGoogle(ctx context.Context, w http.ResponseWriter, r *http.Request) *DNSRequest {
|
func (s *Server) parseRequestGoogle(ctx context.Context, w http.ResponseWriter, r *http.Request) *DNSRequest {
|
||||||
@@ -90,45 +91,14 @@ func (s *Server) parseRequestGoogle(ctx context.Context, w http.ResponseWriter,
|
|||||||
if ednsClientSubnet == "0/0" {
|
if ednsClientSubnet == "0/0" {
|
||||||
ednsClientSubnet = "0.0.0.0/0"
|
ednsClientSubnet = "0.0.0.0/0"
|
||||||
}
|
}
|
||||||
slash := strings.IndexByte(ednsClientSubnet, '/')
|
|
||||||
if slash < 0 {
|
var err error
|
||||||
ednsClientAddress = net.ParseIP(ednsClientSubnet)
|
ednsClientFamily, ednsClientAddress, ednsClientNetmask, err = parseSubnet(ednsClientSubnet)
|
||||||
if ednsClientAddress == nil {
|
if err != nil {
|
||||||
return &DNSRequest{
|
return &DNSRequest{
|
||||||
errcode: 400,
|
errcode: 400,
|
||||||
errtext: fmt.Sprintf("Invalid argument value: \"edns_client_subnet\" = %q", ednsClientSubnet),
|
errtext: err.Error(),
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ipv4 := ednsClientAddress.To4(); ipv4 != nil {
|
|
||||||
ednsClientFamily = 1
|
|
||||||
ednsClientAddress = ipv4
|
|
||||||
ednsClientNetmask = 24
|
|
||||||
} else {
|
|
||||||
ednsClientFamily = 2
|
|
||||||
ednsClientNetmask = 56
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ednsClientAddress = net.ParseIP(ednsClientSubnet[:slash])
|
|
||||||
if ednsClientAddress == nil {
|
|
||||||
return &DNSRequest{
|
|
||||||
errcode: 400,
|
|
||||||
errtext: fmt.Sprintf("Invalid argument value: \"edns_client_subnet\" = %q", ednsClientSubnet),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ipv4 := ednsClientAddress.To4(); ipv4 != nil {
|
|
||||||
ednsClientFamily = 1
|
|
||||||
ednsClientAddress = ipv4
|
|
||||||
} else {
|
|
||||||
ednsClientFamily = 2
|
|
||||||
}
|
|
||||||
netmask, err := strconv.ParseUint(ednsClientSubnet[slash+1:], 10, 8)
|
|
||||||
if err != nil {
|
|
||||||
return &DNSRequest{
|
|
||||||
errcode: 400,
|
|
||||||
errtext: fmt.Sprintf("Invalid argument value: \"edns_client_subnet\" = %q", ednsClientSubnet),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ednsClientNetmask = uint8(netmask)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ednsClientAddress = s.findClientIP(r)
|
ednsClientAddress = s.findClientIP(r)
|
||||||
@@ -169,6 +139,45 @@ func (s *Server) parseRequestGoogle(ctx context.Context, w http.ResponseWriter,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func parseSubnet(ednsClientSubnet string) (ednsClientFamily uint16, ednsClientAddress net.IP, ednsClientNetmask uint8, err error) {
|
||||||
|
slash := strings.IndexByte(ednsClientSubnet, '/')
|
||||||
|
if slash < 0 {
|
||||||
|
ednsClientAddress = net.ParseIP(ednsClientSubnet)
|
||||||
|
if ednsClientAddress == nil {
|
||||||
|
err = fmt.Errorf("Invalid argument value: \"edns_client_subnet\" = %q", ednsClientSubnet)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ipv4 := ednsClientAddress.To4(); ipv4 != nil {
|
||||||
|
ednsClientFamily = 1
|
||||||
|
ednsClientAddress = ipv4
|
||||||
|
ednsClientNetmask = 24
|
||||||
|
} else {
|
||||||
|
ednsClientFamily = 2
|
||||||
|
ednsClientNetmask = 56
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ednsClientAddress = net.ParseIP(ednsClientSubnet[:slash])
|
||||||
|
if ednsClientAddress == nil {
|
||||||
|
err = fmt.Errorf("Invalid argument value: \"edns_client_subnet\" = %q", ednsClientSubnet)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ipv4 := ednsClientAddress.To4(); ipv4 != nil {
|
||||||
|
ednsClientFamily = 1
|
||||||
|
ednsClientAddress = ipv4
|
||||||
|
} else {
|
||||||
|
ednsClientFamily = 2
|
||||||
|
}
|
||||||
|
netmask, err1 := strconv.ParseUint(ednsClientSubnet[slash+1:], 10, 8)
|
||||||
|
if err1 != nil {
|
||||||
|
err = fmt.Errorf("Invalid argument value: \"edns_client_subnet\" = %q", ednsClientSubnet)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ednsClientNetmask = uint8(netmask)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Server) generateResponseGoogle(ctx context.Context, w http.ResponseWriter, r *http.Request, req *DNSRequest) {
|
func (s *Server) generateResponseGoogle(ctx context.Context, w http.ResponseWriter, r *http.Request, req *DNSRequest) {
|
||||||
respJSON := jsondns.Marshal(req.response)
|
respJSON := jsondns.Marshal(req.response)
|
||||||
respStr, err := json.Marshal(respJSON)
|
respStr, err := json.Marshal(respJSON)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -36,8 +36,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
jsondns "github.com/m13253/dns-over-https/v2/json-dns"
|
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
|
|
||||||
|
jsondns "github.com/m13253/dns-over-https/v2/json-dns"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *Server) parseRequestIETF(ctx context.Context, w http.ResponseWriter, r *http.Request) *DNSRequest {
|
func (s *Server) parseRequestIETF(ctx context.Context, w http.ResponseWriter, r *http.Request) *DNSRequest {
|
||||||
@@ -50,7 +51,7 @@ func (s *Server) parseRequestIETF(ctx context.Context, w http.ResponseWriter, r
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(requestBinary) == 0 && (r.Header.Get("Content-Type") == "application/dns-message" || r.Header.Get("Content-Type") == "application/dns-udpwireformat") {
|
if len(requestBinary) == 0 && (r.Header.Get("Content-Type") == "application/dns-message" || r.Header.Get("Content-Type") == "application/dns-udpwireformat") {
|
||||||
requestBinary, err = ioutil.ReadAll(r.Body)
|
requestBinary, err = io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &DNSRequest{
|
return &DNSRequest{
|
||||||
errcode: 400,
|
errcode: 400,
|
||||||
@@ -182,8 +183,6 @@ func (s *Server) generateResponseIETF(ctx context.Context, w http.ResponseWriter
|
|||||||
w.Header().Set("Last-Modified", now)
|
w.Header().Set("Last-Modified", now)
|
||||||
w.Header().Set("Vary", "Accept")
|
w.Header().Set("Vary", "Accept")
|
||||||
|
|
||||||
_ = s.patchFirefoxContentType(w, r, req)
|
|
||||||
|
|
||||||
if respJSON.HaveTTL {
|
if respJSON.HaveTTL {
|
||||||
if req.isTailored {
|
if req.isTailored {
|
||||||
w.Header().Set("Cache-Control", "private, max-age="+strconv.FormatUint(uint64(respJSON.LeastTTL), 10))
|
w.Header().Set("Cache-Control", "private, max-age="+strconv.FormatUint(uint64(respJSON.LeastTTL), 10))
|
||||||
@@ -203,7 +202,7 @@ func (s *Server) generateResponseIETF(ctx context.Context, w http.ResponseWriter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Workaround a bug causing DNSCrypt-Proxy to expect a response with TransactionID = 0xcafe
|
// Workaround a bug causing DNSCrypt-Proxy to expect a response with TransactionID = 0xcafe.
|
||||||
func (s *Server) patchDNSCryptProxyReqID(w http.ResponseWriter, r *http.Request, requestBinary []byte) bool {
|
func (s *Server) patchDNSCryptProxyReqID(w http.ResponseWriter, r *http.Request, requestBinary []byte) bool {
|
||||||
if strings.Contains(r.UserAgent(), "dnscrypt-proxy") && bytes.Equal(requestBinary, []byte("\xca\xfe\x01\x00\x00\x01\x00\x00\x00\x00\x00\x01\x00\x00\x02\x00\x01\x00\x00\x29\x10\x00\x00\x00\x80\x00\x00\x00")) {
|
if strings.Contains(r.UserAgent(), "dnscrypt-proxy") && bytes.Equal(requestBinary, []byte("\xca\xfe\x01\x00\x00\x01\x00\x00\x00\x00\x00\x01\x00\x00\x02\x00\x01\x00\x00\x29\x10\x00\x00\x00\x80\x00\x00\x00")) {
|
||||||
if s.conf.Verbose {
|
if s.conf.Verbose {
|
||||||
@@ -218,17 +217,3 @@ func (s *Server) patchDNSCryptProxyReqID(w http.ResponseWriter, r *http.Request,
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Workaround a bug causing Firefox 61-62 to reject responses with Content-Type = application/dns-message
|
|
||||||
func (s *Server) patchFirefoxContentType(w http.ResponseWriter, r *http.Request, req *DNSRequest) bool {
|
|
||||||
if strings.Contains(r.UserAgent(), "Firefox") && strings.Contains(r.Header.Get("Accept"), "application/dns-udpwireformat") && !strings.Contains(r.Header.Get("Accept"), "application/dns-message") {
|
|
||||||
if s.conf.Verbose {
|
|
||||||
log.Println("Firefox 61-62 detected. Patching response.")
|
|
||||||
}
|
|
||||||
w.Header().Set("Content-Type", "application/dns-udpwireformat")
|
|
||||||
w.Header().Set("Vary", "Accept, User-Agent")
|
|
||||||
req.isTailored = true
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -26,8 +26,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
@@ -36,9 +34,9 @@ import (
|
|||||||
|
|
||||||
func checkPIDFile(pidFile string) (bool, error) {
|
func checkPIDFile(pidFile string) (bool, error) {
|
||||||
retry:
|
retry:
|
||||||
f, err := os.OpenFile(pidFile, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0666)
|
f, err := os.OpenFile(pidFile, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0o666)
|
||||||
if os.IsExist(err) {
|
if os.IsExist(err) {
|
||||||
pidStr, err := ioutil.ReadFile(pidFile)
|
pidStr, err := os.ReadFile(pidFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -62,7 +60,7 @@ retry:
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
_, err = io.WriteString(f, strconv.FormatInt(int64(os.Getpid()), 10))
|
_, err = f.WriteString(strconv.FormatInt(int64(os.Getpid()), 10))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
119
doh-server/parse_test.go
Normal file
119
doh-server/parse_test.go
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
/*
|
||||||
|
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 main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/miekg/dns"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestParseCIDR(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
for _, ednsClientSubnet := range []string{
|
||||||
|
"2001:db8::/0",
|
||||||
|
"2001:db8::/56",
|
||||||
|
"2001:db8::/129",
|
||||||
|
"2001:db8::",
|
||||||
|
|
||||||
|
"127.0.0.1/0",
|
||||||
|
"127.0.0.1/24",
|
||||||
|
"127.0.0.1/33",
|
||||||
|
"127.0.0.1",
|
||||||
|
|
||||||
|
"::ffff:7f00:1/0",
|
||||||
|
"::ffff:7f00:1/120",
|
||||||
|
"::ffff:7f00:1",
|
||||||
|
"127.0.0.1/0",
|
||||||
|
"127.0.0.1/24",
|
||||||
|
"127.0.0.1",
|
||||||
|
} {
|
||||||
|
_, ip, ipNet, err := parseSubnet(ednsClientSubnet)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("ecs:%s ip:[%v] ipNet:[%v] err:[%v]", ednsClientSubnet, ip, ipNet, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestParseInvalidCIDR(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
for _, ip := range []string{
|
||||||
|
"test",
|
||||||
|
"test/0",
|
||||||
|
"test/24",
|
||||||
|
"test/34",
|
||||||
|
"test/56",
|
||||||
|
"test/129",
|
||||||
|
} {
|
||||||
|
_, _, _, err := parseSubnet(ip)
|
||||||
|
if err == nil {
|
||||||
|
t.Errorf("expected error for %q", ip)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestEdns0SubnetParseCIDR(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
// init dns Msg
|
||||||
|
msg := new(dns.Msg)
|
||||||
|
msg.Id = dns.Id()
|
||||||
|
msg.SetQuestion(dns.Fqdn("example.com"), 1)
|
||||||
|
|
||||||
|
// init edns0Subnet
|
||||||
|
edns0Subnet := new(dns.EDNS0_SUBNET)
|
||||||
|
edns0Subnet.Code = dns.EDNS0SUBNET
|
||||||
|
edns0Subnet.SourceScope = 0
|
||||||
|
|
||||||
|
// init opt
|
||||||
|
opt := new(dns.OPT)
|
||||||
|
opt.Hdr.Name = "."
|
||||||
|
opt.Hdr.Rrtype = dns.TypeOPT
|
||||||
|
opt.SetUDPSize(dns.DefaultMsgSize)
|
||||||
|
|
||||||
|
opt.Option = append(opt.Option, edns0Subnet)
|
||||||
|
msg.Extra = append(msg.Extra, opt)
|
||||||
|
|
||||||
|
for _, subnet := range []string{"::ffff:7f00:1/120", "127.0.0.1/24"} {
|
||||||
|
var err error
|
||||||
|
edns0Subnet.Family, edns0Subnet.Address, edns0Subnet.SourceNetmask, err = parseSubnet(subnet)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
t.Log(msg.Pack())
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------127.0.0.1/24-----
|
||||||
|
// [143 29 1 0 0 1 0 0 0 0 0 1 7 101 120 97 109 112 108 101 3 99 111 109 0 0 1 0 1 0
|
||||||
|
// opt start 0 41 16 0 0 0 0 0 0 11
|
||||||
|
// subnet start 0 8 0 7 0 1 24 0
|
||||||
|
// client subnet start 127 0 0]
|
||||||
|
|
||||||
|
// -----::ffff:7f00:1/120----
|
||||||
|
// [111 113 1 0 0 1 0 0 0 0 0 1 7 101 120 97 109 112 108 101 3 99 111 109 0 0 1 0 1 0
|
||||||
|
// opt start 0 41 16 0 0 0 0 0 0 23
|
||||||
|
// subnet start 0 8 0 19 0 2 120 0
|
||||||
|
// client subnet start 0 0 0 0 0 0 0 0 0 0 255 255 127 0 0]
|
||||||
|
}
|
||||||
@@ -28,7 +28,6 @@ import (
|
|||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
@@ -38,8 +37,9 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gorilla/handlers"
|
"github.com/gorilla/handlers"
|
||||||
jsondns "github.com/m13253/dns-over-https/v2/json-dns"
|
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
|
|
||||||
|
jsondns "github.com/m13253/dns-over-https/v2/json-dns"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
@@ -53,11 +53,11 @@ type Server struct {
|
|||||||
type DNSRequest struct {
|
type DNSRequest struct {
|
||||||
request *dns.Msg
|
request *dns.Msg
|
||||||
response *dns.Msg
|
response *dns.Msg
|
||||||
transactionID uint16
|
|
||||||
currentUpstream string
|
currentUpstream string
|
||||||
isTailored bool
|
|
||||||
errcode int
|
|
||||||
errtext string
|
errtext string
|
||||||
|
errcode int
|
||||||
|
transactionID uint16
|
||||||
|
isTailored bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServer(conf *config) (*Server, error) {
|
func NewServer(conf *config) (*Server, error) {
|
||||||
@@ -114,7 +114,7 @@ func (s *Server) Start() error {
|
|||||||
var clientCAPool *x509.CertPool
|
var clientCAPool *x509.CertPool
|
||||||
if s.conf.TLSClientAuth {
|
if s.conf.TLSClientAuth {
|
||||||
if s.conf.TLSClientAuthCA != "" {
|
if s.conf.TLSClientAuthCA != "" {
|
||||||
clientCA, err := ioutil.ReadFile(s.conf.TLSClientAuthCA)
|
clientCA, err := os.ReadFile(s.conf.TLSClientAuthCA)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Reading certificate for client authentication has failed: %v", err)
|
log.Fatalf("Reading certificate for client authentication has failed: %v", err)
|
||||||
}
|
}
|
||||||
@@ -285,7 +285,7 @@ func (s *Server) handlerFunc(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
func (s *Server) findClientIP(r *http.Request) net.IP {
|
func (s *Server) findClientIP(r *http.Request) net.IP {
|
||||||
noEcs := r.URL.Query().Get("no_ecs")
|
noEcs := r.URL.Query().Get("no_ecs")
|
||||||
if strings.ToLower(noEcs) == "true" {
|
if strings.EqualFold(noEcs, "true") {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,7 +319,7 @@ func (s *Server) findClientIP(r *http.Request) net.IP {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Workaround a bug causing Unbound to refuse returning anything about the root
|
// Workaround a bug causing Unbound to refuse returning anything about the root.
|
||||||
func (s *Server) patchRootRD(req *DNSRequest) *DNSRequest {
|
func (s *Server) patchRootRD(req *DNSRequest) *DNSRequest {
|
||||||
for _, question := range req.request.Question {
|
for _, question := range req.request.Question {
|
||||||
if question.Name == "." {
|
if question.Name == "." {
|
||||||
@@ -329,7 +329,7 @@ func (s *Server) patchRootRD(req *DNSRequest) *DNSRequest {
|
|||||||
return req
|
return req
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the position index for the question of qtype from a DNS msg, otherwise return -1
|
// Return the position index for the question of qtype from a DNS msg, otherwise return -1.
|
||||||
func (s *Server) indexQuestionType(msg *dns.Msg, qtype uint16) int {
|
func (s *Server) indexQuestionType(msg *dns.Msg, qtype uint16) int {
|
||||||
for i, question := range msg.Question {
|
for i, question := range msg.Question {
|
||||||
if question.Qtype == qtype {
|
if question.Qtype == qtype {
|
||||||
@@ -364,7 +364,7 @@ func (s *Server) doDNSQuery(ctx context.Context, req *DNSRequest) (err error) {
|
|||||||
req.response, _, err = s.tcpClient.ExchangeContext(ctx, req.request, upstream)
|
req.response, _, err = s.tcpClient.ExchangeContext(ctx, req.request, upstream)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retry with TCP if this was an IXFR request and we only received an SOA
|
// Retry with TCP if this was an IXFR request, and we only received an SOA
|
||||||
if (s.indexQuestionType(req.request, dns.TypeIXFR) > -1) &&
|
if (s.indexQuestionType(req.request, dns.TypeIXFR) > -1) &&
|
||||||
(len(req.response.Answer) == 1) &&
|
(len(req.response.Answer) == 1) &&
|
||||||
(req.response.Answer[0].Header().Rrtype == dns.TypeSOA) {
|
(req.response.Answer[0].Header().Rrtype == dns.TypeSOA) {
|
||||||
|
|||||||
@@ -24,6 +24,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
const (
|
const (
|
||||||
VERSION = "2.3.0"
|
VERSION = "2.3.4"
|
||||||
USER_AGENT = "DNS-over-HTTPS/" + VERSION + " (+https://github.com/m13253/dns-over-https)"
|
USER_AGENT = "DNS-over-HTTPS/" + VERSION + " (+https://github.com/m13253/dns-over-https)"
|
||||||
)
|
)
|
||||||
|
|||||||
20
go.mod
20
go.mod
@@ -1,11 +1,19 @@
|
|||||||
module github.com/m13253/dns-over-https/v2
|
module github.com/m13253/dns-over-https/v2
|
||||||
|
|
||||||
go 1.13
|
go 1.20
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/BurntSushi/toml v0.3.1
|
github.com/BurntSushi/toml v1.3.2
|
||||||
github.com/gorilla/handlers v1.4.0
|
github.com/gorilla/handlers v1.5.1
|
||||||
github.com/infobloxopen/go-trees v0.0.0-20200715205103-96a057b8dfb9
|
github.com/infobloxopen/go-trees v0.0.0-20221216143356-66ceba885ebc
|
||||||
github.com/miekg/dns v1.1.41
|
github.com/miekg/dns v1.1.56
|
||||||
golang.org/x/net v0.0.0-20210324205630-d1beb07c2056
|
golang.org/x/net v0.17.0
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/felixge/httpsnoop v1.0.3 // indirect
|
||||||
|
golang.org/x/mod v0.13.0 // indirect
|
||||||
|
golang.org/x/sys v0.13.0 // indirect
|
||||||
|
golang.org/x/text v0.13.0 // indirect
|
||||||
|
golang.org/x/tools v0.14.0 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
43
go.sum
43
go.sum
@@ -1,25 +1,26 @@
|
|||||||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||||
github.com/gorilla/handlers v1.4.0 h1:XulKRWSQK5uChr4pEgSE4Tc/OcmnU9GJuSwdog/tZsA=
|
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||||
github.com/gorilla/handlers v1.4.0/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
|
github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk=
|
||||||
github.com/infobloxopen/go-trees v0.0.0-20200715205103-96a057b8dfb9 h1:w66aaP3c6SIQ0pi3QH1Tb4AMO3aWoEPxd1CNvLphbkA=
|
github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||||
github.com/infobloxopen/go-trees v0.0.0-20200715205103-96a057b8dfb9/go.mod h1:BaIJzjD2ZnHmx2acPF6XfGLPzNCMiBbMRqJr+8/8uRI=
|
github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4=
|
||||||
github.com/miekg/dns v1.1.41 h1:WMszZWJG0XmzbK9FEmzH2TVcqYzFesusSIB41b8KHxY=
|
github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q=
|
||||||
github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI=
|
github.com/infobloxopen/go-trees v0.0.0-20221216143356-66ceba885ebc h1:RhT2pjLo3EVRmldbEcBdeRA7CGPWsNEJC+Y/N1aXQbg=
|
||||||
|
github.com/infobloxopen/go-trees v0.0.0-20221216143356-66ceba885ebc/go.mod h1:BaIJzjD2ZnHmx2acPF6XfGLPzNCMiBbMRqJr+8/8uRI=
|
||||||
|
github.com/miekg/dns v1.1.56 h1:5imZaSeoRNvpM9SzWNhEcP9QliKiz20/dA2QabIGVnE=
|
||||||
|
github.com/miekg/dns v1.1.56/go.mod h1:cRm6Oo2C8TY9ZS/TqsSrseAcncm74lfK5G+ikN2SWWY=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY=
|
||||||
golang.org/x/net v0.0.0-20210324205630-d1beb07c2056 h1:sANdAef76Ioam9aQUUdcAqricwY/WUaMc4+7LY4eGg8=
|
golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||||
golang.org/x/net v0.0.0-20210324205630-d1beb07c2056/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k=
|
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
|
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
|
||||||
golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20210324051608-47abb6519492 h1:Paq34FxTluEPvVyayQqMPgHm+vTOrIifmcYxFBx9TLg=
|
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
||||||
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc=
|
||||||
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
|
golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
|||||||
@@ -119,7 +119,6 @@ func init() {
|
|||||||
IP: net.IP{0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
IP: net.IP{0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||||
Mask: net.IPMask{0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
Mask: net.IPMask{0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||||
}, struct{}{})
|
}, struct{}{})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsGlobalIP(ip net.IP) bool {
|
func IsGlobalIP(ip net.IP) bool {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ LimitNOFILE=1048576
|
|||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=3
|
RestartSec=3
|
||||||
Type=simple
|
Type=simple
|
||||||
User=nobody
|
DynamicUser=yes
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ LimitNOFILE=1048576
|
|||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=3
|
RestartSec=3
|
||||||
Type=simple
|
Type=simple
|
||||||
User=nobody
|
DynamicUser=yes
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|||||||
Reference in New Issue
Block a user