From 58d88cf2bc2d59a219155c0aac80f2e84b4e00bf Mon Sep 17 00:00:00 2001 From: Mathew Jacob Date: Thu, 18 Nov 2021 11:18:09 -0600 Subject: [PATCH] Fix subdomain gateway logic to allow multiple gateways on same domain --- core/corehttp/hostname.go | 2 +- core/corehttp/hostname_test.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/core/corehttp/hostname.go b/core/corehttp/hostname.go index e294a561b86..57c2c2191a6 100644 --- a/core/corehttp/hostname.go +++ b/core/corehttp/hostname.go @@ -338,7 +338,7 @@ func knownSubdomainDetails(hostname string, knownGateways gatewayHosts) (gw *con ns := labels[i-1] if !isSubdomainNamespace(ns) { - break + continue } // Merge remaining labels (could be a FQDN with DNSLink) diff --git a/core/corehttp/hostname_test.go b/core/corehttp/hostname_test.go index 6575ee1e840..f7ba89a8c9b 100644 --- a/core/corehttp/hostname_test.go +++ b/core/corehttp/hostname_test.go @@ -217,6 +217,7 @@ func TestKnownSubdomainDetails(t *testing.T) { knownGateways := prepareKnownGateways(map[string]*config.GatewaySpec{ "localhost": gwLocalhost, "dweb.link": gwDweb, + "devgateway.dweb.link": gwDweb, "dweb.ipfs.pvt.k12.ma.us": gwLong, // note the sneaky ".ipfs." ;-) "*.wildcard1.tld": gwWildcard1, "*.*.wildcard2.tld": gwWildcard2, @@ -248,6 +249,7 @@ func TestKnownSubdomainDetails(t *testing.T) { // cid in subdomain, known gateway {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.localhost:8080", gwLocalhost, "localhost:8080", "ipfs", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am", true}, {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.dweb.link", gwDweb, "dweb.link", "ipfs", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am", true}, + {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.devgateway.dweb.link", gwDweb, "devgateway.dweb.link", "ipfs", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am", true}, // capture everything before .ipfs. {"foo.bar.boo-buzz.ipfs.dweb.link", gwDweb, "dweb.link", "ipfs", "foo.bar.boo-buzz", true}, // ipns