Rename cloudflare-tunnel type to cloudflared

This commit is contained in:
世界
2026-03-24 16:40:21 +08:00
parent af2afc529b
commit 2cf2ff3f33
43 changed files with 83 additions and 82 deletions

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare
@@ -10,10 +10,11 @@ import (
"strings"
"sync"
"github.com/coreos/go-oidc/v3/oidc"
E "github.com/sagernet/sing/common/exceptions"
M "github.com/sagernet/sing/common/metadata"
N "github.com/sagernet/sing/common/network"
"github.com/coreos/go-oidc/v3/oidc"
)
const accessJWTAssertionHeader = "Cf-Access-Jwt-Assertion"

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare
@@ -32,7 +32,7 @@ func newAccessTestInbound(t *testing.T) *Inbound {
t.Fatal(err)
}
return &Inbound{
Adapter: inbound.NewAdapter(C.TypeCloudflareTunnel, "test"),
Adapter: inbound.NewAdapter(C.TypeCloudflared, "test"),
logger: logFactory.NewLogger("test"),
accessCache: &accessValidatorCache{values: make(map[string]accessValidator), dialer: N.SystemDialer},
router: &testRouter{},

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare
@@ -11,7 +11,7 @@ import (
)
func TestNewInboundRequiresToken(t *testing.T) {
_, err := NewInbound(context.Background(), nil, log.NewNOPFactory().NewLogger("test"), "test", option.CloudflareTunnelInboundOptions{})
_, err := NewInbound(context.Background(), nil, log.NewNOPFactory().NewLogger("test"), "test", option.CloudflaredInboundOptions{})
if err == nil {
t.Fatal("expected missing token error")
}

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare
@@ -14,7 +14,7 @@ import (
func TestDatagramV3RegistrationDestinationUnreachable(t *testing.T) {
sender := &captureDatagramSender{}
inboundInstance := &Inbound{
Adapter: inbound.NewAdapter(C.TypeCloudflareTunnel, "test"),
Adapter: inbound.NewAdapter(C.TypeCloudflared, "test"),
flowLimiter: &FlowLimiter{},
}
muxer := NewDatagramV3Muxer(inboundInstance, sender, nil)
@@ -40,7 +40,7 @@ func TestDatagramV3RegistrationDestinationUnreachable(t *testing.T) {
func TestDatagramV3RegistrationErrorWithMessage(t *testing.T) {
sender := &captureDatagramSender{}
inboundInstance := &Inbound{
Adapter: inbound.NewAdapter(C.TypeCloudflareTunnel, "test"),
Adapter: inbound.NewAdapter(C.TypeCloudflared, "test"),
flowLimiter: &FlowLimiter{},
}
muxer := NewDatagramV3Muxer(inboundInstance, sender, nil)

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare
@@ -31,7 +31,7 @@ func newLimitedInbound(t *testing.T, limit uint64) *Inbound {
config.WarpRouting.MaxActiveFlows = limit
configManager.activeConfig = config
return &Inbound{
Adapter: inbound.NewAdapter(C.TypeCloudflareTunnel, "test"),
Adapter: inbound.NewAdapter(C.TypeCloudflared, "test"),
router: &testRouter{},
logger: logFactory.NewLogger("test"),
configManager: configManager,

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare
@@ -177,7 +177,7 @@ func newTestInbound(t *testing.T, token string, protocol string, haConnections i
ctx, cancel := context.WithCancel(context.Background())
inboundInstance := &Inbound{
Adapter: inbound.NewAdapter(C.TypeCloudflareTunnel, "test"),
Adapter: inbound.NewAdapter(C.TypeCloudflared, "test"),
ctx: ctx,
cancel: cancel,
router: &testRouter{},

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare
@@ -71,7 +71,7 @@ func TestICMPBridgeHandleV2RoutesEchoRequest(t *testing.T) {
},
}
inboundInstance := &Inbound{
Adapter: inbound.NewAdapter(C.TypeCloudflareTunnel, "test"),
Adapter: inbound.NewAdapter(C.TypeCloudflared, "test"),
router: router,
}
sender := &captureDatagramSender{}
@@ -117,7 +117,7 @@ func TestICMPBridgeHandleV2TracedReply(t *testing.T) {
},
}
inboundInstance := &Inbound{
Adapter: inbound.NewAdapter(C.TypeCloudflareTunnel, "test"),
Adapter: inbound.NewAdapter(C.TypeCloudflared, "test"),
router: router,
}
bridge := NewICMPBridge(inboundInstance, sender, icmpWireV2)
@@ -151,7 +151,7 @@ func TestICMPBridgeHandleV3Reply(t *testing.T) {
},
}
inboundInstance := &Inbound{
Adapter: inbound.NewAdapter(C.TypeCloudflareTunnel, "test"),
Adapter: inbound.NewAdapter(C.TypeCloudflared, "test"),
router: router,
}
bridge := NewICMPBridge(inboundInstance, sender, icmpWireV3)
@@ -178,7 +178,7 @@ func TestICMPBridgeDropsNonEcho(t *testing.T) {
},
}
inboundInstance := &Inbound{
Adapter: inbound.NewAdapter(C.TypeCloudflareTunnel, "test"),
Adapter: inbound.NewAdapter(C.TypeCloudflared, "test"),
router: router,
}
sender := &captureDatagramSender{}

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare
@@ -30,10 +30,10 @@ import (
)
func RegisterInbound(registry *inbound.Registry) {
inbound.Register[option.CloudflareTunnelInboundOptions](registry, C.TypeCloudflareTunnel, NewInbound)
inbound.Register[option.CloudflaredInboundOptions](registry, C.TypeCloudflared, NewInbound)
}
var ErrNonRemoteManagedTunnelUnsupported = errors.New("cloudflare tunnel only supports remote-managed tunnels")
var ErrNonRemoteManagedTunnelUnsupported = errors.New("cloudflared only supports remote-managed tunnels")
type Inbound struct {
inbound.Adapter
@@ -71,7 +71,7 @@ type Inbound struct {
connectedNotify chan uint8
}
func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.CloudflareTunnelInboundOptions) (adapter.Inbound, error) {
func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.CloudflaredInboundOptions) (adapter.Inbound, error) {
if options.Token == "" {
return nil, E.New("missing token")
}
@@ -107,7 +107,7 @@ func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLo
configManager, err := NewConfigManager()
if err != nil {
return nil, E.Cause(err, "build cloudflare tunnel runtime config")
return nil, E.Cause(err, "build cloudflared runtime config")
}
controlDialer, err := boxDialer.NewWithOptions(boxDialer.Options{
Context: ctx,
@@ -115,7 +115,7 @@ func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLo
RemoteIsDomain: true,
})
if err != nil {
return nil, E.Cause(err, "build cloudflare tunnel control dialer")
return nil, E.Cause(err, "build cloudflared control dialer")
}
region := options.Region
@@ -129,7 +129,7 @@ func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLo
inboundCtx, cancel := context.WithCancel(ctx)
return &Inbound{
Adapter: inbound.NewAdapter(C.TypeCloudflareTunnel, tag),
Adapter: inbound.NewAdapter(C.TypeCloudflared, tag),
ctx: inboundCtx,
cancel: cancel,
router: router,

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare
@@ -64,7 +64,7 @@ func newSpecialServiceInboundWithRouter(t *testing.T, router adapter.Router) *In
t.Fatal(err)
}
return &Inbound{
Adapter: inbound.NewAdapter(C.TypeCloudflareTunnel, "test"),
Adapter: inbound.NewAdapter(C.TypeCloudflared, "test"),
router: router,
logger: logFactory.NewLogger("test"),
configManager: configManager,

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare

View File

@@ -1,4 +1,4 @@
//go:build with_cloudflare_tunnel
//go:build with_cloudflared
package cloudflare