mirror of
https://github.com/coredns/coredns.git
synced 2026-10-08 19:45:21 -04:00
core: upgrade Go requirement to 1.26.0 (#8466)
* core: upgrade Go requirement to 1.26.0 As golang 1.27 has been released, this PR - Bump Go version requirement to 1.26.0 - Update Go build version to 1.27.0 This is also for solving the issue encountered in 8092 of k8s update Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Bump golang ci Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Fix Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Fix Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Fix Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Migrate faillint to forbidigo, as failint has not bee updated for more than a year Signed-off-by: Yong Tang <yong.tang.github@outlook.com> --------- Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
@@ -507,7 +507,7 @@ func TestDNS64(t *testing.T) {
|
||||
}
|
||||
actual := rec.Msg
|
||||
if actual.Rcode != rc {
|
||||
t.Fatalf("ServeDNS should return real result code %q != %q", actual.Rcode, rc)
|
||||
t.Fatalf("ServeDNS should return real result code %d != %d", actual.Rcode, rc)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(actual, tc.resp) {
|
||||
|
||||
@@ -92,7 +92,7 @@ func TestShouldTransfer(t *testing.T) {
|
||||
t.Fatalf("Unable to run shouldTransfer: %v", err)
|
||||
}
|
||||
if !should {
|
||||
t.Fatalf("ShouldTransfer should return true for serial: %q", soa.serial-1)
|
||||
t.Fatalf("ShouldTransfer should return true for serial: %d", soa.serial-1)
|
||||
}
|
||||
// Serial equal
|
||||
z.SOA = test.SOA(fmt.Sprintf("%s IN SOA bla. bla. %d 0 0 0 0 ", testZone, soa.serial))
|
||||
|
||||
@@ -32,14 +32,14 @@ func TestSetup(t *testing.T) {
|
||||
max_streams 100
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxStreams: intPtr(100),
|
||||
expectedMaxStreams: new(100),
|
||||
},
|
||||
{
|
||||
input: `grpc_server {
|
||||
max_connections 200
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxConnections: intPtr(200),
|
||||
expectedMaxConnections: new(200),
|
||||
},
|
||||
{
|
||||
input: `grpc_server {
|
||||
@@ -47,8 +47,8 @@ func TestSetup(t *testing.T) {
|
||||
max_connections 100
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxStreams: intPtr(50),
|
||||
expectedMaxConnections: intPtr(100),
|
||||
expectedMaxStreams: new(50),
|
||||
expectedMaxConnections: new(100),
|
||||
},
|
||||
// Zero values (unbounded)
|
||||
{
|
||||
@@ -56,14 +56,14 @@ func TestSetup(t *testing.T) {
|
||||
max_streams 0
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxStreams: intPtr(0),
|
||||
expectedMaxStreams: new(0),
|
||||
},
|
||||
{
|
||||
input: `grpc_server {
|
||||
max_connections 0
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxConnections: intPtr(0),
|
||||
expectedMaxConnections: new(0),
|
||||
},
|
||||
// Error cases
|
||||
{
|
||||
@@ -139,9 +139,7 @@ func TestSetup(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func intPtr(v int) *int {
|
||||
return &v
|
||||
}
|
||||
//go:fix inline
|
||||
|
||||
func assertIntPtrValue(t *testing.T, testIndex int, testInput, fieldName string, actual, expected *int) {
|
||||
t.Helper()
|
||||
|
||||
@@ -48,14 +48,14 @@ func TestSetup(t *testing.T) {
|
||||
max_connections 200
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxConnections: intPtr(200),
|
||||
expectedMaxConnections: new(200),
|
||||
},
|
||||
{
|
||||
input: `https {
|
||||
max_streams 100
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxStreams: intPtr(100),
|
||||
expectedMaxStreams: new(100),
|
||||
},
|
||||
{
|
||||
input: `https {
|
||||
@@ -63,8 +63,8 @@ func TestSetup(t *testing.T) {
|
||||
max_streams 100
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxConnections: intPtr(200),
|
||||
expectedMaxStreams: intPtr(100),
|
||||
expectedMaxConnections: new(200),
|
||||
expectedMaxStreams: new(100),
|
||||
},
|
||||
// Zero values (unbounded)
|
||||
{
|
||||
@@ -72,7 +72,7 @@ func TestSetup(t *testing.T) {
|
||||
max_connections 0
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxConnections: intPtr(0),
|
||||
expectedMaxConnections: new(0),
|
||||
},
|
||||
// Error cases
|
||||
{
|
||||
@@ -123,7 +123,7 @@ func TestSetup(t *testing.T) {
|
||||
max_streams 0
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxStreams: intPtr(0),
|
||||
expectedMaxStreams: new(0),
|
||||
},
|
||||
{
|
||||
input: `https {
|
||||
@@ -199,9 +199,7 @@ func TestSetup(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func intPtr(v int) *int {
|
||||
return &v
|
||||
}
|
||||
//go:fix inline
|
||||
|
||||
func assertIntPtrValue(t *testing.T, testIndex int, testInput, fieldName string, actual, expected *int) {
|
||||
t.Helper()
|
||||
|
||||
@@ -31,7 +31,7 @@ func TestSetup(t *testing.T) {
|
||||
max_streams 100
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxStreams: intPtr(100),
|
||||
expectedMaxStreams: new(100),
|
||||
},
|
||||
// Zero values (unbounded)
|
||||
{
|
||||
@@ -39,7 +39,7 @@ func TestSetup(t *testing.T) {
|
||||
max_streams 0
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxStreams: intPtr(0),
|
||||
expectedMaxStreams: new(0),
|
||||
},
|
||||
// Error cases
|
||||
{
|
||||
@@ -114,9 +114,7 @@ func TestSetup(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func intPtr(v int) *int {
|
||||
return &v
|
||||
}
|
||||
//go:fix inline
|
||||
|
||||
func assertIntPtrValue(t *testing.T, testIndex int, testInput, fieldName string, actual, expected *int) {
|
||||
t.Helper()
|
||||
|
||||
@@ -132,7 +132,7 @@ type dnsControlOpts struct {
|
||||
}
|
||||
|
||||
// newdnsController creates a controller for CoreDNS.
|
||||
func newdnsController(ctx context.Context, kubeClient kubernetes.Interface, mcsClient mcsClientset.MulticlusterV1alpha1Interface, opts dnsControlOpts) *dnsControl {
|
||||
func newdnsController(_ context.Context, kubeClient kubernetes.Interface, mcsClient mcsClientset.MulticlusterV1alpha1Interface, opts dnsControlOpts) *dnsControl {
|
||||
dns := dnsControl{
|
||||
client: kubeClient,
|
||||
mcsClient: mcsClient,
|
||||
@@ -147,8 +147,8 @@ func newdnsController(ctx context.Context, kubeClient kubernetes.Interface, mcsC
|
||||
dns.svcLister, dns.svcController = object.NewIndexerInformer(
|
||||
cache.ToListWatcherWithWatchListSemantics(
|
||||
&cache.ListWatch{
|
||||
ListFunc: serviceListFunc(ctx, dns.client, api.NamespaceAll, dns.selector),
|
||||
WatchFunc: serviceWatchFunc(ctx, dns.client, api.NamespaceAll, dns.selector),
|
||||
ListWithContextFunc: serviceListFunc(dns.client, api.NamespaceAll, dns.selector),
|
||||
WatchFuncWithContext: serviceWatchFunc(dns.client, api.NamespaceAll, dns.selector),
|
||||
},
|
||||
kubeClient,
|
||||
),
|
||||
@@ -161,8 +161,8 @@ func newdnsController(ctx context.Context, kubeClient kubernetes.Interface, mcsC
|
||||
podLister, podController := object.NewIndexerInformer(
|
||||
cache.ToListWatcherWithWatchListSemantics(
|
||||
&cache.ListWatch{
|
||||
ListFunc: podListFunc(ctx, dns.client, api.NamespaceAll, dns.selector),
|
||||
WatchFunc: podWatchFunc(ctx, dns.client, api.NamespaceAll, dns.selector),
|
||||
ListWithContextFunc: podListFunc(dns.client, api.NamespaceAll, dns.selector),
|
||||
WatchFuncWithContext: podWatchFunc(dns.client, api.NamespaceAll, dns.selector),
|
||||
},
|
||||
kubeClient,
|
||||
),
|
||||
@@ -183,8 +183,8 @@ func newdnsController(ctx context.Context, kubeClient kubernetes.Interface, mcsC
|
||||
epLister, epController := object.NewIndexerInformer(
|
||||
cache.ToListWatcherWithWatchListSemantics(
|
||||
&cache.ListWatch{
|
||||
ListFunc: endpointSliceListFunc(ctx, dns.client, api.NamespaceAll, dns.selector),
|
||||
WatchFunc: endpointSliceWatchFunc(ctx, dns.client, api.NamespaceAll, dns.selector),
|
||||
ListWithContextFunc: endpointSliceListFunc(dns.client, api.NamespaceAll, dns.selector),
|
||||
WatchFuncWithContext: endpointSliceWatchFunc(dns.client, api.NamespaceAll, dns.selector),
|
||||
},
|
||||
kubeClient,
|
||||
),
|
||||
@@ -201,8 +201,8 @@ func newdnsController(ctx context.Context, kubeClient kubernetes.Interface, mcsC
|
||||
dns.nsLister, dns.nsController = object.NewIndexerInformer(
|
||||
cache.ToListWatcherWithWatchListSemantics(
|
||||
&cache.ListWatch{
|
||||
ListFunc: namespaceListFunc(ctx, dns.client, dns.namespaceSelector),
|
||||
WatchFunc: namespaceWatchFunc(ctx, dns.client, dns.namespaceSelector),
|
||||
ListWithContextFunc: namespaceListFunc(dns.client, dns.namespaceSelector),
|
||||
WatchFuncWithContext: namespaceWatchFunc(dns.client, dns.namespaceSelector),
|
||||
},
|
||||
kubeClient,
|
||||
),
|
||||
@@ -222,8 +222,8 @@ func newdnsController(ctx context.Context, kubeClient kubernetes.Interface, mcsC
|
||||
dns.mcEpLister, dns.mcEpController = object.NewIndexerInformer(
|
||||
cache.ToListWatcherWithWatchListSemantics(
|
||||
&cache.ListWatch{
|
||||
ListFunc: endpointSliceListFunc(ctx, dns.client, api.NamespaceAll, mcsEpSelector),
|
||||
WatchFunc: endpointSliceWatchFunc(ctx, dns.client, api.NamespaceAll, mcsEpSelector),
|
||||
ListWithContextFunc: endpointSliceListFunc(dns.client, api.NamespaceAll, mcsEpSelector),
|
||||
WatchFuncWithContext: endpointSliceWatchFunc(dns.client, api.NamespaceAll, mcsEpSelector),
|
||||
},
|
||||
kubeClient,
|
||||
),
|
||||
@@ -235,8 +235,8 @@ func newdnsController(ctx context.Context, kubeClient kubernetes.Interface, mcsC
|
||||
dns.svcImportLister, dns.svcImportController = object.NewIndexerInformer(
|
||||
cache.ToListWatcherWithWatchListSemantics(
|
||||
&cache.ListWatch{
|
||||
ListFunc: serviceImportListFunc(ctx, dns.mcsClient, api.NamespaceAll, dns.namespaceSelector),
|
||||
WatchFunc: serviceImportWatchFunc(ctx, dns.mcsClient, api.NamespaceAll, dns.namespaceSelector),
|
||||
ListWithContextFunc: serviceImportListFunc(dns.mcsClient, api.NamespaceAll, dns.namespaceSelector),
|
||||
WatchFuncWithContext: serviceImportWatchFunc(dns.mcsClient, api.NamespaceAll, dns.namespaceSelector),
|
||||
},
|
||||
kubeClient,
|
||||
),
|
||||
@@ -334,8 +334,8 @@ func mcEpNameNamespaceIndexFunc(obj any) ([]string, error) {
|
||||
return []string{mcEp.Index}, nil
|
||||
}
|
||||
|
||||
func serviceListFunc(ctx context.Context, c kubernetes.Interface, ns string, s labels.Selector) func(meta.ListOptions) (runtime.Object, error) {
|
||||
return func(opts meta.ListOptions) (runtime.Object, error) {
|
||||
func serviceListFunc(c kubernetes.Interface, ns string, s labels.Selector) func(context.Context, meta.ListOptions) (runtime.Object, error) {
|
||||
return func(ctx context.Context, opts meta.ListOptions) (runtime.Object, error) {
|
||||
if s != nil {
|
||||
opts.LabelSelector = s.String()
|
||||
}
|
||||
@@ -343,8 +343,8 @@ func serviceListFunc(ctx context.Context, c kubernetes.Interface, ns string, s l
|
||||
}
|
||||
}
|
||||
|
||||
func podListFunc(ctx context.Context, c kubernetes.Interface, ns string, s labels.Selector) func(meta.ListOptions) (runtime.Object, error) {
|
||||
return func(opts meta.ListOptions) (runtime.Object, error) {
|
||||
func podListFunc(c kubernetes.Interface, ns string, s labels.Selector) func(context.Context, meta.ListOptions) (runtime.Object, error) {
|
||||
return func(ctx context.Context, opts meta.ListOptions) (runtime.Object, error) {
|
||||
if s != nil {
|
||||
opts.LabelSelector = s.String()
|
||||
}
|
||||
@@ -356,8 +356,8 @@ func podListFunc(ctx context.Context, c kubernetes.Interface, ns string, s label
|
||||
}
|
||||
}
|
||||
|
||||
func endpointSliceListFunc(ctx context.Context, c kubernetes.Interface, ns string, s labels.Selector) func(meta.ListOptions) (runtime.Object, error) {
|
||||
return func(opts meta.ListOptions) (runtime.Object, error) {
|
||||
func endpointSliceListFunc(c kubernetes.Interface, ns string, s labels.Selector) func(context.Context, meta.ListOptions) (runtime.Object, error) {
|
||||
return func(ctx context.Context, opts meta.ListOptions) (runtime.Object, error) {
|
||||
if s != nil {
|
||||
opts.LabelSelector = s.String()
|
||||
}
|
||||
@@ -365,8 +365,8 @@ func endpointSliceListFunc(ctx context.Context, c kubernetes.Interface, ns strin
|
||||
}
|
||||
}
|
||||
|
||||
func namespaceListFunc(ctx context.Context, c kubernetes.Interface, s labels.Selector) func(meta.ListOptions) (runtime.Object, error) {
|
||||
return func(opts meta.ListOptions) (runtime.Object, error) {
|
||||
func namespaceListFunc(c kubernetes.Interface, s labels.Selector) func(context.Context, meta.ListOptions) (runtime.Object, error) {
|
||||
return func(ctx context.Context, opts meta.ListOptions) (runtime.Object, error) {
|
||||
if s != nil {
|
||||
opts.LabelSelector = s.String()
|
||||
}
|
||||
@@ -374,8 +374,8 @@ func namespaceListFunc(ctx context.Context, c kubernetes.Interface, s labels.Sel
|
||||
}
|
||||
}
|
||||
|
||||
func serviceImportListFunc(ctx context.Context, c mcsClientset.MulticlusterV1alpha1Interface, ns string, s labels.Selector) func(meta.ListOptions) (runtime.Object, error) {
|
||||
return func(opts meta.ListOptions) (runtime.Object, error) {
|
||||
func serviceImportListFunc(c mcsClientset.MulticlusterV1alpha1Interface, ns string, s labels.Selector) func(context.Context, meta.ListOptions) (runtime.Object, error) {
|
||||
return func(ctx context.Context, opts meta.ListOptions) (runtime.Object, error) {
|
||||
if s != nil {
|
||||
opts.LabelSelector = s.String()
|
||||
}
|
||||
@@ -383,8 +383,8 @@ func serviceImportListFunc(ctx context.Context, c mcsClientset.MulticlusterV1alp
|
||||
}
|
||||
}
|
||||
|
||||
func serviceWatchFunc(ctx context.Context, c kubernetes.Interface, ns string, s labels.Selector) func(options meta.ListOptions) (watch.Interface, error) {
|
||||
return func(options meta.ListOptions) (watch.Interface, error) {
|
||||
func serviceWatchFunc(c kubernetes.Interface, ns string, s labels.Selector) func(context.Context, meta.ListOptions) (watch.Interface, error) {
|
||||
return func(ctx context.Context, options meta.ListOptions) (watch.Interface, error) {
|
||||
if s != nil {
|
||||
options.LabelSelector = s.String()
|
||||
}
|
||||
@@ -392,8 +392,8 @@ func serviceWatchFunc(ctx context.Context, c kubernetes.Interface, ns string, s
|
||||
}
|
||||
}
|
||||
|
||||
func podWatchFunc(ctx context.Context, c kubernetes.Interface, ns string, s labels.Selector) func(options meta.ListOptions) (watch.Interface, error) {
|
||||
return func(options meta.ListOptions) (watch.Interface, error) {
|
||||
func podWatchFunc(c kubernetes.Interface, ns string, s labels.Selector) func(context.Context, meta.ListOptions) (watch.Interface, error) {
|
||||
return func(ctx context.Context, options meta.ListOptions) (watch.Interface, error) {
|
||||
if s != nil {
|
||||
options.LabelSelector = s.String()
|
||||
}
|
||||
@@ -405,8 +405,8 @@ func podWatchFunc(ctx context.Context, c kubernetes.Interface, ns string, s labe
|
||||
}
|
||||
}
|
||||
|
||||
func endpointSliceWatchFunc(ctx context.Context, c kubernetes.Interface, ns string, s labels.Selector) func(options meta.ListOptions) (watch.Interface, error) {
|
||||
return func(options meta.ListOptions) (watch.Interface, error) {
|
||||
func endpointSliceWatchFunc(c kubernetes.Interface, ns string, s labels.Selector) func(context.Context, meta.ListOptions) (watch.Interface, error) {
|
||||
return func(ctx context.Context, options meta.ListOptions) (watch.Interface, error) {
|
||||
if s != nil {
|
||||
options.LabelSelector = s.String()
|
||||
}
|
||||
@@ -414,8 +414,8 @@ func endpointSliceWatchFunc(ctx context.Context, c kubernetes.Interface, ns stri
|
||||
}
|
||||
}
|
||||
|
||||
func namespaceWatchFunc(ctx context.Context, c kubernetes.Interface, s labels.Selector) func(options meta.ListOptions) (watch.Interface, error) {
|
||||
return func(options meta.ListOptions) (watch.Interface, error) {
|
||||
func namespaceWatchFunc(c kubernetes.Interface, s labels.Selector) func(context.Context, meta.ListOptions) (watch.Interface, error) {
|
||||
return func(ctx context.Context, options meta.ListOptions) (watch.Interface, error) {
|
||||
if s != nil {
|
||||
options.LabelSelector = s.String()
|
||||
}
|
||||
@@ -423,8 +423,8 @@ func namespaceWatchFunc(ctx context.Context, c kubernetes.Interface, s labels.Se
|
||||
}
|
||||
}
|
||||
|
||||
func serviceImportWatchFunc(ctx context.Context, c mcsClientset.MulticlusterV1alpha1Interface, ns string, s labels.Selector) func(options meta.ListOptions) (watch.Interface, error) {
|
||||
return func(options meta.ListOptions) (watch.Interface, error) {
|
||||
func serviceImportWatchFunc(c mcsClientset.MulticlusterV1alpha1Interface, ns string, s labels.Selector) func(context.Context, meta.ListOptions) (watch.Interface, error) {
|
||||
return func(ctx context.Context, options meta.ListOptions) (watch.Interface, error) {
|
||||
if s != nil {
|
||||
options.LabelSelector = s.String()
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
mcs "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1"
|
||||
)
|
||||
|
||||
func ptrTo[T any](v T) *T { return &v }
|
||||
//go:fix inline
|
||||
|
||||
// dump renders an object for a failure message. %+v prints an aliased pointer field as
|
||||
// an address, which hides the value that actually differs, so render as JSON instead.
|
||||
@@ -76,7 +76,7 @@ func deepCopyCases() []struct {
|
||||
Ports: []api.ServicePort{{
|
||||
Name: "http", Protocol: api.ProtocolTCP, Port: 80,
|
||||
// A pointer field, so a slice copy alone leaves it shared.
|
||||
AppProtocol: ptrTo("kubernetes.io/h2c"),
|
||||
AppProtocol: new("kubernetes.io/h2c"),
|
||||
}},
|
||||
ExternalIPs: []string{"1.2.3.4"},
|
||||
}},
|
||||
@@ -89,7 +89,7 @@ func deepCopyCases() []struct {
|
||||
Type: mcs.ClusterSetIP,
|
||||
Ports: []mcs.ServicePort{{
|
||||
Name: "http", Protocol: api.ProtocolTCP, Port: 80,
|
||||
AppProtocol: ptrTo("kubernetes.io/h2c"),
|
||||
AppProtocol: new("kubernetes.io/h2c"),
|
||||
}},
|
||||
}},
|
||||
{"Namespace", &Namespace{Version: "1", Name: "testns"}},
|
||||
|
||||
@@ -176,12 +176,12 @@ func makeDoQTestTLSConfigs(t *testing.T) (*tls.Config, *tls.Config) {
|
||||
}
|
||||
roots.AddCert(parsed)
|
||||
return &tls.Config{
|
||||
Certificates: []tls.Certificate{cert},
|
||||
NextProtos: []string{doqALPN},
|
||||
}, &tls.Config{
|
||||
RootCAs: roots,
|
||||
ServerName: "doq.test",
|
||||
}
|
||||
Certificates: []tls.Certificate{cert},
|
||||
NextProtos: []string{doqALPN},
|
||||
}, &tls.Config{
|
||||
RootCAs: roots,
|
||||
ServerName: "doq.test",
|
||||
}
|
||||
}
|
||||
|
||||
func writeDoQTestResponse(stream *quic.Stream, response *dns.Msg) error {
|
||||
@@ -291,8 +291,7 @@ func TestProxyDoQVerifiesServerName(t *testing.T) {
|
||||
if err == nil {
|
||||
t.Fatal("Connect() succeeded with the wrong TLS server name")
|
||||
}
|
||||
var hostnameError x509.HostnameError
|
||||
if !errors.As(err, &hostnameError) {
|
||||
if _, ok := errors.AsType[x509.HostnameError](err); !ok {
|
||||
t.Fatalf("Connect() error = %T %v, want x509.HostnameError", err, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,10 +141,10 @@ func loadRoots(caPath string) (*x509.CertPool, error) {
|
||||
func NewHTTPSTransport(cc *tls.Config) *http.Transport {
|
||||
tr := &http.Transport{
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
Dial: (&net.Dialer{
|
||||
DialContext: (&net.Dialer{
|
||||
Timeout: 30 * time.Second,
|
||||
KeepAlive: 30 * time.Second,
|
||||
}).Dial,
|
||||
}).DialContext,
|
||||
TLSHandshakeTimeout: 10 * time.Second,
|
||||
TLSClientConfig: cc,
|
||||
MaxIdleConnsPerHost: 25,
|
||||
|
||||
@@ -36,7 +36,7 @@ func TestQuicSetup(t *testing.T) {
|
||||
max_streams 100
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxStreams: pint(100),
|
||||
expectedMaxStreams: new(100),
|
||||
expectedWorkerPoolSize: nil,
|
||||
},
|
||||
{
|
||||
@@ -45,7 +45,7 @@ func TestQuicSetup(t *testing.T) {
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxStreams: nil,
|
||||
expectedWorkerPoolSize: pint(1000),
|
||||
expectedWorkerPoolSize: new(1000),
|
||||
},
|
||||
{
|
||||
input: `quic {
|
||||
@@ -53,8 +53,8 @@ func TestQuicSetup(t *testing.T) {
|
||||
worker_pool_size 1000
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxStreams: pint(100),
|
||||
expectedWorkerPoolSize: pint(1000),
|
||||
expectedMaxStreams: new(100),
|
||||
expectedWorkerPoolSize: new(1000),
|
||||
},
|
||||
{
|
||||
input: `quic {
|
||||
@@ -133,7 +133,7 @@ func TestQuicSetup(t *testing.T) {
|
||||
}`,
|
||||
shouldErr: true,
|
||||
expectedErrContent: "already defined",
|
||||
expectedMaxStreams: pint(100),
|
||||
expectedMaxStreams: new(100),
|
||||
},
|
||||
{
|
||||
input: `quic {
|
||||
@@ -142,7 +142,7 @@ func TestQuicSetup(t *testing.T) {
|
||||
}`,
|
||||
shouldErr: true,
|
||||
expectedErrContent: "already defined",
|
||||
expectedWorkerPoolSize: pint(1000),
|
||||
expectedWorkerPoolSize: new(1000),
|
||||
},
|
||||
{
|
||||
input: `quic {
|
||||
@@ -239,6 +239,4 @@ func formatNilableInt(v *int) string {
|
||||
return fmt.Sprintf("%d", *v)
|
||||
}
|
||||
|
||||
func pint(i int) *int {
|
||||
return &i
|
||||
}
|
||||
//go:fix inline
|
||||
|
||||
@@ -2,6 +2,7 @@ package rewrite
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
@@ -161,8 +162,8 @@ func copyRRs(rrs []dns.RR) []dns.RR {
|
||||
|
||||
func (r *ResponseReverter) rewriteResourceRecord(res *dns.Msg, rr dns.RR) {
|
||||
// The reverting rules need to be done in reversed order.
|
||||
for i := len(r.ResponseRules) - 1; i >= 0; i-- {
|
||||
r.ResponseRules[i].RewriteResponse(res, rr)
|
||||
for _, v := range slices.Backward(r.ResponseRules) {
|
||||
v.RewriteResponse(res, rr)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,18 +172,18 @@ func (r *ResponseReverter) rewriteResourceRecord(res *dns.Msg, rr dns.RR) {
|
||||
// loops in WriteMsg would otherwise never apply them.
|
||||
func (r *ResponseReverter) rewriteMsg(res *dns.Msg) {
|
||||
// The reverting rules need to be done in reversed order.
|
||||
for i := len(r.ResponseRules) - 1; i >= 0; i-- {
|
||||
if _, ok := r.ResponseRules[i].(msgResponseRule); !ok {
|
||||
for _, v := range slices.Backward(r.ResponseRules) {
|
||||
if _, ok := v.(msgResponseRule); !ok {
|
||||
continue
|
||||
}
|
||||
r.ResponseRules[i].RewriteResponse(res, nil)
|
||||
v.RewriteResponse(res, nil)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *ResponseReverter) rewriteRequestExtra(req *dns.Msg, rr dns.RR) {
|
||||
// The reverting rules need to be done in reversed order.
|
||||
for i := len(r.ResponseRules) - 1; i >= 0; i-- {
|
||||
rule, ok := r.ResponseRules[i].(requestExtraRevertRule)
|
||||
for _, v := range slices.Backward(r.ResponseRules) {
|
||||
rule, ok := v.(requestExtraRevertRule)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -541,7 +541,7 @@ func TestSIIT(t *testing.T) {
|
||||
}
|
||||
actual := rec.Msg
|
||||
if actual.Rcode != rc {
|
||||
t.Fatalf("ServeDNS should return real result code %q != %q", actual.Rcode, rc)
|
||||
t.Fatalf("ServeDNS should return real result code %d != %d", actual.Rcode, rc)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(actual, tc.resp) {
|
||||
|
||||
@@ -247,7 +247,7 @@ func Section(tc Case, sec sect, rr []dns.RR) error {
|
||||
return fmt.Errorf("MX Mx should be %q, but is %q", tt.Mx, x.Mx)
|
||||
}
|
||||
if x.Preference != tt.Preference {
|
||||
return fmt.Errorf("MX Preference should be %q, but is %q", tt.Preference, x.Preference)
|
||||
return fmt.Errorf("MX Preference should be %d, but is %d", tt.Preference, x.Preference)
|
||||
}
|
||||
case *dns.NS:
|
||||
tt := section[i].(*dns.NS)
|
||||
|
||||
Reference in New Issue
Block a user