Skip to content

Commit 58a16ed

Browse files
committed
Merge branch 'master' of github.com:DNSCrypt/dnscrypt-proxy
2 parents 0da41e8 + bcbf2db commit 58a16ed

File tree

694 files changed

+3891
-18412
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

694 files changed

+3891
-18412
lines changed

.ci/ci-package.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#! /bin/sh
2+
3+
PACKAGE_VERSION="$1"
4+
5+
cd dnscrypt-proxy || exit 1
6+
7+
# setup the environment
8+
9+
sudo apt-get update -y
10+
sudo apt-get install -y wget wine dotnet-sdk-6.0
11+
sudo dpkg --add-architecture i386 && sudo apt-get update && sudo apt-get install -y wine32
12+
13+
sudo apt-get install -y unzip
14+
15+
export WINEPREFIX="$HOME"/.wine32
16+
export WINEARCH=win32
17+
export WINEDEBUG=-all
18+
19+
wget https://dl.winehq.org/wine/wine-mono/8.1.0/wine-mono-8.1.0-x86.msi
20+
WINEPREFIX="$HOME/.wine32" WINEARCH=win32 wineboot --init
21+
WINEPREFIX="$HOME/.wine32" WINEARCH=win32 wine msiexec /i wine-mono-8.1.0-x86.msi
22+
23+
mkdir "$HOME"/.wine32/drive_c/temp
24+
mkdir -p "$HOME"/.wine/drive_c/temp
25+
wget https://github.com/wixtoolset/wix3/releases/download/wix3112rtm/wix311-binaries.zip -nv -O wix.zip
26+
27+
unzip wix.zip -d "$HOME"/wix
28+
rm -f wix.zip
29+
30+
builddir=$(pwd)
31+
srcdir=$(
32+
cd ..
33+
pwd
34+
)
35+
version=$PACKAGE_VERSION
36+
37+
cd "$HOME"/wix || exit
38+
39+
ln -s "$builddir" "$HOME"/wix/build
40+
ln -s "$srcdir"/contrib/msi "$HOME"/wix/wixproj
41+
echo "builddir: $builddir"
42+
43+
# build the msi's
44+
#################
45+
for arch in x64 x86; do
46+
binpath="win32"
47+
if [ "$arch" = "x64" ]; then
48+
binpath="win64"
49+
fi
50+
51+
echo $arch
52+
53+
wine candle.exe -dVersion="$version" -dPlatform=$arch -dPath=build\\$binpath -arch $arch wixproj\\dnscrypt.wxs -out build\\dnscrypt-$arch.wixobj
54+
wine light.exe -out build\\dnscrypt-proxy-$arch-"$version".msi build\\dnscrypt-$arch.wixobj -sval
55+
56+
done
57+
58+
cd "$builddir" || exit

.ci/ci-test.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ t || dig -p${DNS_PORT} +dnssec darpa.mil @127.0.0.1 2>&1 | grep -Fvq 'RRSIG' ||
6666
t || dig -p${DNS_PORT} +dnssec www.darpa.mil @127.0.0.1 2>&1 | grep -Fvq 'RRSIG' || fail
6767

6868
section
69-
t || dig -p${DNS_PORT} +short cloaked.com @127.0.0.1 | grep -Eq '1.1.1.1|1.0.0.1' || fail
70-
t || dig -p${DNS_PORT} +short MX cloaked.com @127.0.0.1 | grep -Fq 'locally blocked' || fail
69+
t || dig -p${DNS_PORT} +short cloakedunregistered.com @127.0.0.1 | grep -Eq '1.1.1.1|1.0.0.1' || fail
70+
t || dig -p${DNS_PORT} +short MX cloakedunregistered.com @127.0.0.1 | grep -Fq 'locally blocked' || fail
7171
t || dig -p${DNS_PORT} +short MX example.com @127.0.0.1 | grep -Fvq 'locally blocked' || fail
72-
t || dig -p${DNS_PORT} NS cloaked.com @127.0.0.1 | grep -Fiq 'gtld-servers.net' || fail
73-
t || dig -p${DNS_PORT} +short www.cloaked2.com @127.0.0.1 | grep -Eq '1.1.1.1|1.0.0.1' || fail
72+
t || dig -p${DNS_PORT} NS cloakedunregistered.com @127.0.0.1 | grep -Fiq 'gtld-servers.net' || fail
73+
t || dig -p${DNS_PORT} +short www.cloakedunregistered2.com @127.0.0.1 | grep -Eq '1.1.1.1|1.0.0.1' || fail
7474
t || dig -p${DNS_PORT} +short www.dnscrypt-test @127.0.0.1 | grep -Fq '192.168.100.100' || fail
7575
t || dig -p${DNS_PORT} a.www.dnscrypt-test @127.0.0.1 | grep -Fq 'NXDOMAIN' || fail
7676
t || dig -p${DNS_PORT} +short ptr 101.100.168.192.in-addr.arpa. @127.0.0.1 | grep -Eq 'www.dnscrypt-test.com' || fail
@@ -122,8 +122,8 @@ t || grep -Eq 'invalid.*SYNTH' query.log || fail
122122
t || grep -Eq '168.192.in-addr.arpa.*SYNTH' query.log || fail
123123
t || grep -Eq 'darpa.mil.*FORWARD' query.log || fail
124124
t || grep -Eq 'www.darpa.mil.*FORWARD' query.log || fail
125-
t || grep -Eq 'cloaked.com.*CLOAK' query.log || fail
126-
t || grep -Eq 'www.cloaked2.com.*CLOAK' query.log || fail
125+
t || grep -Eq 'cloakedunregistered.com.*CLOAK' query.log || fail
126+
t || grep -Eq 'www.cloakedunregistered2.com.*CLOAK' query.log || fail
127127
t || grep -Eq 'www.dnscrypt-test.*CLOAK' query.log || fail
128128
t || grep -Eq 'a.www.dnscrypt-test.*NXDOMAIN' query.log || fail
129129
t || grep -Eq 'telemetry.example.*REJECT' query.log || fail

.ci/cloaking-rules.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
cloaked.* one.one.one.one
2-
*.cloaked2.* one.one.one.one # inline comment
3-
=www.dnscrypt-test 192.168.100.100
4-
=www.dnscrypt-test.com 192.168.100.101
5-
=ipv6.dnscrypt-test.com fd02::1
1+
cloakedunregistered.* one.one.one.one
2+
*.cloakedunregistered2.* one.one.one.one # inline comment
3+
=www.dnscrypt-test 192.168.100.100
4+
=www.dnscrypt-test.com 192.168.100.101
5+
=ipv6.dnscrypt-test.com fd02::1

.ci/test3-dnscrypt-proxy.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ cache = true
1313
[query_log]
1414
file = 'query.log'
1515

16-
17-
1816
[static]
1917

2018
[static.'myserver']
21-
stamp = 'sdns://AQcAAAAAAAAADjIxMi40Ny4yMjguMTM2IOgBuE6mBr-wusDOQ0RbsV66ZLAvo8SqMa4QY2oHkDJNHzIuZG5zY3J5cHQtY2VydC5mci5kbnNjcnlwdC5vcmc'
19+
stamp = 'sdns://AQcAAAAAAAAADjIxMi40Ny4yMjguMTM2IOgBuE6mBr-wusDOQ0RbsV66ZLAvo8SqMa4QY2oHkDJNHzIuZG5zY3J5cHQtY2VydC5mci5kbnNjcnlwdC5vcmc'

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ jobs:
1818
fetch-depth: 2
1919

2020
- name: Initialize CodeQL
21-
uses: github/codeql-action/init@v2
21+
uses: github/codeql-action/init@v3
2222

2323
- name: Autobuild
24-
uses: github/codeql-action/autobuild@v2
24+
uses: github/codeql-action/autobuild@v3
2525

2626
- name: Perform CodeQL Analysis
27-
uses: github/codeql-action/analyze@v2
27+
uses: github/codeql-action/analyze@v3

.github/workflows/releases.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ jobs:
4949
run: |
5050
.ci/ci-build.sh "${{ steps.get_version.outputs.VERSION }}"
5151
52+
- name: Package
53+
if: startsWith(github.ref, 'refs/tags/')
54+
run: |
55+
.ci/ci-package.sh "${{ steps.get_version.outputs.VERSION }}"
56+
5257
- name: Install minisign and sign
5358
if: startsWith(github.ref, 'refs/tags/')
5459
run: |
@@ -87,3 +92,4 @@ jobs:
8792
dnscrypt-proxy/*.zip
8893
dnscrypt-proxy/*.tar.gz
8994
dnscrypt-proxy/*.minisig
95+
dnscrypt-proxy/*.msi

.github/workflows/shiftleft-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ jobs:
1818
output: reports
1919

2020
- name: Upload report
21-
uses: github/codeql-action/upload-sarif@v2
21+
uses: github/codeql-action/upload-sarif@v3
2222
with:
2323
sarif_file: reports

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ dnscrypt-proxy/dnscrypt-proxy
1414
.ci/*.md
1515
.ci/*.md.minisig
1616
.ci/test-dnscrypt-proxy.toml
17+
contrib/msi/*.msi
18+
contrib/msi/*.wixpdb
19+
contrib/msi/*.wixobj

contrib/msi/Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM ubuntu:latest
2+
MAINTAINER dnscrypt-authors
3+
4+
RUN apt-get update && \
5+
apt-get install -y wget wine dotnet-sdk-6.0 && \
6+
dpkg --add-architecture i386 && apt-get update && apt-get install -y wine32
7+
8+
9+
ENV WINEPREFIX=/root/.wine32 WINEARCH=win32 WINEDEBUG=-all
10+
11+
RUN wget https://dl.winehq.org/wine/wine-mono/8.1.0/wine-mono-8.1.0-x86.msi && \
12+
WINEPREFIX="$HOME/.wine32" WINEARCH=win32 wineboot --init && \
13+
WINEPREFIX="$HOME/.wine32" WINEARCH=win32 wine msiexec /i wine-mono-8.1.0-x86.msi && \
14+
mkdir $WINEPREFIX/drive_c/temp && \
15+
apt-get install -y unzip && \
16+
wget https://github.com/wixtoolset/wix3/releases/download/wix3112rtm/wix311-binaries.zip -nv -O wix.zip && \
17+
unzip wix.zip -d /wix && \
18+
rm -f wix.zip
19+
20+
WORKDIR /wix
21+

contrib/msi/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Scripts and utilities related to building an .msi (Microsoft Standard Installer) file.
2+
3+
## Docker test image for building an MSI locally
4+
5+
```sh
6+
docker build . -f Dockerfile -t ubuntu:dnscrypt-msi
7+
```
8+
9+
## Test building msi files for intel win32 & win64
10+
11+
```sh
12+
./build.sh
13+
```

contrib/msi/build.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#! /bin/sh
2+
3+
version=0.0.0
4+
gitver=$(git describe --tags --always --match="[0-9]*.[0-9]*.[0-9]*" --exclude='*[^0-9.]*')
5+
if [ "$gitver" != "" ]; then
6+
version=$gitver
7+
fi
8+
9+
# build the image by running: docker build . -f Dockerfile -t ubuntu:dnscrypt-msi
10+
if [ "$(docker image list -q ubuntu:dnscrypt-msi)" = "" ]; then
11+
docker build . -f Dockerfile -t ubuntu:dnscrypt-msi
12+
fi
13+
14+
image=ubuntu:dnscrypt-msi
15+
16+
for arch in x64 x86; do
17+
binpath="win32"
18+
if [ "$arch" = "x64" ]; then
19+
binpath="win64"
20+
fi
21+
src=$(
22+
cd ../../dnscrypt-proxy/$binpath || exit
23+
pwd
24+
)
25+
echo "$src"
26+
27+
docker run --rm -v "$(pwd)":/wixproj -v "$src":/src $image wine candle.exe -dVersion="$version" -dPlatform=$arch -dPath=\\src -arch $arch \\wixproj\\dnscrypt.wxs -out \\wixproj\\dnscrypt-$arch.wixobj
28+
docker run --rm -v "$(pwd)":/wixproj -v "$src":/src $image wine light.exe -out \\wixproj\\dnscrypt-proxy-$arch-"$version".msi \\wixproj\\dnscrypt-$arch.wixobj -sval
29+
30+
done

contrib/msi/dnscrypt.wxs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0"?>
2+
3+
<?if $(var.Platform)="x64" ?>
4+
<?define Program_Files="ProgramFiles64Folder"?>
5+
<?else ?>
6+
<?define Program_Files="ProgramFilesFolder"?>
7+
<?endif ?>
8+
<?ifndef var.Version?>
9+
<?error Undefined Version variable?>
10+
<?endif ?>
11+
<?ifndef var.Path?>
12+
<?error Undefined Path variable?>
13+
<?endif ?>
14+
15+
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
16+
<Product Id="*"
17+
UpgradeCode="fbf99dd8-c21e-4f9b-a632-de53bb64c45e"
18+
Name="dnscrypt-proxy"
19+
Version="$(var.Version)"
20+
Manufacturer="DNSCrypt"
21+
Language="1033">
22+
23+
<Package InstallerVersion="200" Compressed="yes" Comments="Windows Installer Package" InstallScope="perMachine" />
24+
<Media Id="1" Cabinet="product.cab" EmbedCab="yes" />
25+
<MajorUpgrade DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." />
26+
27+
<Upgrade Id="fbf99dd8-c21e-4f9b-a632-de53bb64c45e">
28+
<UpgradeVersion Minimum="$(var.Version)" OnlyDetect="yes" Property="NEWERVERSIONDETECTED" />
29+
<UpgradeVersion Minimum="2.1.0" Maximum="$(var.Version)" IncludeMinimum="yes" IncludeMaximum="no" Property="OLDERVERSIONBEINGUPGRADED" />
30+
</Upgrade>
31+
<Condition Message="A newer version of this software is already installed.">NOT NEWERVERSIONDETECTED</Condition>
32+
33+
<Directory Id="TARGETDIR" Name="SourceDir">
34+
<Directory Id="$(var.Program_Files)">
35+
<Directory Id="INSTALLDIR" Name="DNSCrypt">
36+
<Component Id="ApplicationFiles" Guid="7d693c0b-71d8-436a-9c84-60a11dc74092">
37+
<File Id="dnscryptproxy.exe" KeyPath="yes" Source="$(var.Path)\dnscrypt-proxy.exe" DiskId="1"/>
38+
<File Source="$(var.Path)\LICENSE"></File>
39+
<File Source="$(var.Path)\service-install.bat"></File>
40+
<File Source="$(var.Path)\service-restart.bat"></File>
41+
<File Source="$(var.Path)\service-uninstall.bat"></File>
42+
<File Source="$(var.Path)\example-dnscrypt-proxy.toml"></File>
43+
</Component>
44+
<Component Id="ConfigInstall" Guid="db7b691e-f7c7-4c9a-92e1-c6f21ce6430f" KeyPath="yes">
45+
<Condition><![CDATA[CONFIGFILE]]></Condition>
46+
<CopyFile Id="dnscryptproxytoml" DestinationDirectory="INSTALLDIR" DestinationName="dnscrypt-proxy.toml" SourceProperty="CONFIGFILE">
47+
</CopyFile>
48+
<RemoveFile Id="RemoveConfig" Directory="INSTALLDIR" Name="dnscrypt-proxy.toml" On="uninstall" />
49+
</Component>
50+
</Directory>
51+
</Directory>
52+
</Directory>
53+
54+
<Feature Id="Complete" Level="1">
55+
<ComponentRef Id="ApplicationFiles" />
56+
<ComponentRef Id="ConfigInstall" />
57+
</Feature>
58+
59+
</Product>
60+
</Wix>

dnscrypt-proxy/coldstart.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"net"
66
"strings"
7+
"sync"
78
"time"
89

910
"github.com/jedisct1/dlog"
@@ -15,17 +16,13 @@ type CaptivePortalEntryIPs []net.IP
1516
type CaptivePortalMap map[string]CaptivePortalEntryIPs
1617

1718
type CaptivePortalHandler struct {
19+
wg sync.WaitGroup
1820
cancelChannel chan struct{}
19-
countChannel chan struct{}
20-
channelCount int
2121
}
2222

2323
func (captivePortalHandler *CaptivePortalHandler) Stop() {
2424
close(captivePortalHandler.cancelChannel)
25-
for len(captivePortalHandler.countChannel) < captivePortalHandler.channelCount {
26-
time.Sleep(10 * time.Millisecond)
27-
}
28-
close(captivePortalHandler.countChannel)
25+
captivePortalHandler.wg.Wait()
2926
}
3027

3128
func (ipsMap *CaptivePortalMap) GetEntry(msg *dns.Msg) (*dns.Question, *CaptivePortalEntryIPs) {
@@ -133,11 +130,12 @@ func addColdStartListener(
133130
if err != nil {
134131
return err
135132
}
133+
captivePortalHandler.wg.Add(1)
136134
go func() {
137135
for !handleColdStartClient(clientPc, captivePortalHandler.cancelChannel, ipsMap) {
138136
}
139137
clientPc.Close()
140-
captivePortalHandler.countChannel <- struct{}{}
138+
captivePortalHandler.wg.Done()
141139
}()
142140
return nil
143141
}
@@ -185,14 +183,17 @@ func ColdStart(proxy *Proxy) (*CaptivePortalHandler, error) {
185183
listenAddrStrs := proxy.listenAddresses
186184
captivePortalHandler := CaptivePortalHandler{
187185
cancelChannel: make(chan struct{}),
188-
countChannel: make(chan struct{}, len(listenAddrStrs)),
189-
channelCount: 0,
190186
}
187+
ok := false
191188
for _, listenAddrStr := range listenAddrStrs {
192-
if err := addColdStartListener(proxy, &ipsMap, listenAddrStr, &captivePortalHandler); err == nil {
193-
captivePortalHandler.channelCount++
189+
err = addColdStartListener(proxy, &ipsMap, listenAddrStr, &captivePortalHandler)
190+
if err == nil {
191+
ok = true
194192
}
195193
}
194+
if ok {
195+
err = nil
196+
}
196197
proxy.captivePortalMap = &ipsMap
197-
return &captivePortalHandler, nil
198+
return &captivePortalHandler, err
198199
}

dnscrypt-proxy/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ type Config struct {
4242
Timeout int `toml:"timeout"`
4343
KeepAlive int `toml:"keepalive"`
4444
Proxy string `toml:"proxy"`
45+
CertRefreshConcurrency int `toml:"cert_refresh_concurrency"`
4546
CertRefreshDelay int `toml:"cert_refresh_delay"`
4647
CertIgnoreTimestamp bool `toml:"cert_ignore_timestamp"`
4748
EphemeralKeys bool `toml:"dnscrypt_ephemeral_keys"`
@@ -116,6 +117,7 @@ func newConfig() Config {
116117
LocalDoH: LocalDoHConfig{Path: "/dns-query"},
117118
Timeout: 5000,
118119
KeepAlive: 5,
120+
CertRefreshConcurrency: 10,
119121
CertRefreshDelay: 240,
120122
HTTP3: false,
121123
CertIgnoreTimestamp: false,
@@ -443,6 +445,7 @@ func ConfigLoad(proxy *Proxy, flags *ConfigFlags) error {
443445
if config.ForceTCP {
444446
proxy.mainProto = "tcp"
445447
}
448+
proxy.certRefreshConcurrency = Max(1, config.CertRefreshConcurrency)
446449
proxy.certRefreshDelay = time.Duration(Max(60, config.CertRefreshDelay)) * time.Minute
447450
proxy.certRefreshDelayAfterFailure = time.Duration(10 * time.Second)
448451
proxy.certIgnoreTimestamp = config.CertIgnoreTimestamp

dnscrypt-proxy/example-dnscrypt-proxy.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ keepalive = 30
183183
# use_syslog = true
184184

185185

186+
## The maximum concurrency to reload certificates from the resolvers.
187+
## Default is 10.
188+
189+
# cert_refresh_concurrency = 10
190+
191+
186192
## Delay, in minutes, after which certificates are reloaded
187193

188194
cert_refresh_delay = 240

0 commit comments

Comments
 (0)