aboutsummaryrefslogtreecommitdiff
path: root/test/file_upstream_test.go
blob: 36f2bbc562097ddd5aa423382d000617d78809bd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package test

import (
	"testing"

	"github.com/miekg/dns"
)

func TestFileUpstream(t *testing.T) {
	name, rm, err := TempFile(".", `$ORIGIN example.org.
@	3600 IN	SOA sns.dns.icann.org. noc.dns.icann.org. (
		2017042745 ; serial
		7200       ; refresh (2 hours)
		3600       ; retry (1 hour)
		1209600    ; expire (2 weeks)
		3600       ; minimum (1 hour)
	)

        3600 IN NS a.iana-servers.net.
	3600 IN NS b.iana-servers.net.

www 3600 IN CNAME   www.example.net.
`)
	if err != nil {
		t.Fatalf("Failed to create zone: %s", err)
	}
	defer rm()

	corefile := `.:0 {
	file ` + name + ` example.org {
	       upstream
	}
	hosts {
               10.0.0.1 www.example.net.
               fallthrough
       }
}
`
	i, udp, _, err := CoreDNSServerAndPorts(corefile)
	if err != nil {
		t.Fatalf("Could not get CoreDNS serving instance: %s", err)
	}
	defer i.Stop()

	m := new(dns.Msg)
	m.SetQuestion("www.example.org.", dns.TypeA)
	m.SetEdns0(4096, true)

	r, err := dns.Exchange(m, udp)
	if err != nil {
		t.Fatalf("Could not exchange msg: %s", err)
	}
	if r.Rcode == dns.RcodeServerFailure {
		t.Fatalf("Rcode should not be dns.RcodeServerFailure")
	}
	if x := r.Answer[1].(*dns.A).A.String(); x != "10.0.0.1" {
		t.Errorf("Failed to get address for CNAME, expected 10.0.0.1 got %s", x)
	}
}

// TestFileUpstreamAdditional runs two CoreDNS servers that serve example.org and foo.example.org.
// example.org contains a cname to foo.example.org; this should be resolved via upstream.Self.
func TestFileUpstreamAdditional(t *testing.T) {
	name, rm, err := TempFile(".", `$ORIGIN example.org.
@	3600 IN	SOA sns.dns.icann.org. noc.dns.icann.org. 2017042745 7200 3600 1209600 3600

	3600 IN NS b.iana-servers.net.

www 3600 IN CNAME   www.foo
`)
	if err != nil {
		t.Fatalf("Failed to create zone: %s", err)
	}
	defer rm()

	name2, rm2, err2 := TempFile(".", `$ORIGIN foo.example.org.
@	3600 IN	SOA sns.dns.icann.org. noc.dns.icann.org. 2017042745 7200 3600 1209600 3600

	3600 IN NS b.iana-servers.net.

www 3600 IN A   127.0.0.53
`)
	if err2 != nil {
		t.Fatalf("Failed to create zone: %s", err2)
	}
	defer rm2()

	corefile := `.:0 {
	file ` + name + ` example.org {
	       upstream
	}
	file ` + name2 + ` foo.example.org {
	       upstream
	}
}
`
	i, udp, _, err := CoreDNSServerAndPorts(corefile)
	if err != nil {
		t.Fatalf("Could not get CoreDNS serving instance: %s", err)
	}
	defer i.Stop()

	m := new(dns.Msg)
	m.SetQuestion("www.example.org.", dns.TypeA)

	r, err := dns.Exchange(m, udp)
	if err != nil {
		t.Fatalf("Could not exchange msg: %s", err)
	}
	if r.Rcode == dns.RcodeServerFailure {
		t.Fatalf("Rcode should not be dns.RcodeServerFailure")
	}
	if x := len(r.Answer); x != 2 {
		t.Errorf("Expected 2 RR in reply, got %d", x)
	}
	if x := r.Answer[1].(*dns.A).A.String(); x != "127.0.0.53" {
		t.Errorf("Failed to get address for CNAME, expected 127.0.0.53, got %s", x)
	}
}
/commit/src/bun.js/api/server.zig?h=derrick/fix/bindings-mark-jscinitialize&id=1227a7b995d02980634ded567a4a233c1ddd26a2&follow=1'>avoids segfault after aborted onReject in Bun.serve streams (#2256)Gravatar Ciro Spaciari 1-7/+8 * avoids segfault after aborted on reject * silence err on handleRejectStream after aborted 2023-03-01Run tests in CI for bun-linux-aarch64Gravatar Ashcon Partovi 2-1/+30 2023-03-01Revert spawnSync changeGravatar Jarred Sumner 1-1/+2 cc @FireTheFox 2023-03-01Update bindings.zigGravatar Jarred Sumner 1-1/+3 2023-03-01fix deinit behavior when connection is aborted using ResponseStream and ↵Gravatar Ciro Spaciari 3-34/+174 abort event behavior (#2252) * fix deinit behavior when connection is aborted using ResponseStream * fix abort handling on stream, and get better tests * avoid segfault by trying to deinit 2x when aborted * make tests more reliable * more reliable onResolveStream after aborted * add test case for not firing the abort signal 2023-03-01fix Bun.file.arrayBuffer() segmentation fault on empty file #2248 (#2249)Gravatar Ciro Spaciari 3-7/+23 * fix Bun.file.arrayBuffer() segmentation fault on empty file #2248 * cleanner this.iotask check 2023-03-01Fix async in sqliteGravatar Colin McDonnell 1-2/+2 2023-02-28Forces a specific libdir for c-ares (#2241)Gravatar Justin Whear 1-1/+5 The c-ares build expects lib/libcares.a to exist after cmake, but on my system it was being generated in lib64. This simply sets the cmake variable so that the target ends up where we expect. 2023-02-28Make Bun.gc(true) more aggressiveGravatar Jarred Sumner 1-0/+3 2023-02-28Expose JSC::Options via `BUN_JSC_` prefixGravatar Jarred Sumner 6-8/+47 Example usage: BUN_JSC_logGC=1 bun file.js 2023-02-28fixupGravatar Jarred Sumner 1-1/+1 2023-02-28Fix typecheckGravatar Colin McDonnell 2-1/+4 2023-02-28Fix incorrect Bun version in docs (#2236)Gravatar Derrick Farris 1-1/+1 2023-02-28just some comments fix (#2237)Gravatar Ciro Spaciari 1-4/+2 2023-02-28Add `-D`, `--dev` flags for bun install (#2240)Gravatar Justin Whear 1-9/+9 * remove vendored clap * Update to latest zig-clap Major changes: * Instead of vendoring zig-clap and adding changes, this uses Hejsil/zig-clap directly as a submodule * `cli.zig` and related files have been updated to use new API (no more `flag()` or `option()`) * A workaround for the Run and Auto commands has been implemented that allows us to use the official upstream Minor change: * `-i` now has the long option `--install-fallback`; I didn't spend much time thinking about this name, so suggestions weclome. * add --development and --optional to bun install * Add support for `-D`, `--dev` in bun install, fix `--save` 2023-02-28Document punningGravatar Colin McDonnell 1-1/+18