forked from Place1/wg-access-server
-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #239 from DasSkelett/fix/dns-proxy-big-packets
- Loading branch information
Showing
6 changed files
with
163 additions
and
13 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Unit tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
|
||
jobs: | ||
test-go: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
go: [ '1.18', '1.19' ] | ||
name: Go ${{ matrix.go }} tests | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ matrix.go }} | ||
cache: true | ||
- name: Run go test | ||
run: go test -v ./... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package dnsproxy | ||
|
||
import ( | ||
"context" | ||
"net" | ||
"testing" | ||
"time" | ||
) | ||
|
||
var ffmucUpstreams, _ = net.LookupHost("dns.ffmuc.net") | ||
|
||
func TestDNSProxy_ServeDNS(t *testing.T) { | ||
const listen = "[::1]:8053" | ||
|
||
resolver := net.Resolver{ | ||
PreferGo: true, | ||
Dial: func(ctx context.Context, network, address string) (net.Conn, error) { | ||
d := net.Dialer{Timeout: time.Second} | ||
return d.DialContext(ctx, network, listen) | ||
}, | ||
} | ||
|
||
server, err := New(DNSServerOpts{ | ||
Domain: "", | ||
ListenAddr: []string{listen}, | ||
Upstream: ffmucUpstreams, | ||
}) | ||
server.ListenAndServe() | ||
defer func() { _ = server.Close() }() | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
t.Run("Reply over 1300 bytes", func(t *testing.T) { | ||
_, err := resolver.LookupTXT(context.Background(), "cloudflare.com.") | ||
if err != nil { | ||
t.Error(err) | ||
return | ||
} | ||
}) | ||
t.Run("Reply over 1500 bytes", func(t *testing.T) { | ||
records, err := resolver.LookupTXT(context.Background(), "txtfill1500.go.dnscheck.tools.") | ||
if err != nil { | ||
t.Error(err) | ||
return | ||
} | ||
var containsBigRecord bool | ||
for _, r := range records { | ||
if len(r) >= 1500 { | ||
containsBigRecord = true | ||
} | ||
} | ||
if !containsBigRecord { | ||
t.Error("missing big TXT record, packet probably truncated") | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters