feature/conn25: guard extension Init() and PeerAPI handler with opt-in env var

Fixes tailscale/corp#39003

Signed-off-by: Michael Ben-Ami <mzb@tailscale.com>
This commit is contained in:
Michael Ben-Ami
2026-03-24 09:31:30 -04:00
committed by mzbenami
parent 302e49dc4e
commit bdcf976477

View File

@@ -23,6 +23,7 @@
"go4.org/netipx"
"golang.org/x/net/dns/dnsmessage"
"tailscale.com/appc"
"tailscale.com/envknob"
"tailscale.com/feature"
"tailscale.com/ipn/ipnext"
"tailscale.com/ipn/ipnlocal"
@@ -35,6 +36,7 @@
"tailscale.com/util/dnsname"
"tailscale.com/util/mak"
"tailscale.com/util/set"
"tailscale.com/util/testenv"
)
// featureName is the name of the feature implemented by this package.
@@ -75,6 +77,11 @@ func init() {
}
func handleConnectorTransitIP(h ipnlocal.PeerAPIHandler, w http.ResponseWriter, r *http.Request) {
// TODO(tailscale/corp#39033): Remove for alpha release.
if !envknob.UseWIPCode() && !testenv.InTest() {
w.WriteHeader(http.StatusNotImplemented)
return
}
e, ok := ipnlocal.GetExt[*extension](h.LocalBackend())
if !ok {
http.Error(w, "miswired", http.StatusInternalServerError)
@@ -103,6 +110,11 @@ func (e *extension) Name() string {
// Init implements [ipnext.Extension].
func (e *extension) Init(host ipnext.Host) error {
// TODO(tailscale/corp#39033): Remove for alpha release.
if !envknob.UseWIPCode() && !testenv.InTest() {
return ipnext.SkipExtension
}
//Init only once
e.mu.Lock()
defer e.mu.Unlock()