mirror of
https://github.com/SagerNet/sing-box.git
synced 2026-04-14 04:38:28 +10:00
Rename cloudflare-tunnel type to cloudflared
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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{},
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build with_cloudflare_tunnel
|
||||
//go:build with_cloudflared
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build with_cloudflare_tunnel
|
||||
//go:build with_cloudflared
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build with_cloudflare_tunnel
|
||||
//go:build with_cloudflared
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build with_cloudflare_tunnel
|
||||
//go:build with_cloudflared
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build with_cloudflare_tunnel
|
||||
//go:build with_cloudflared
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build with_cloudflare_tunnel
|
||||
//go:build with_cloudflared
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build with_cloudflare_tunnel
|
||||
//go:build with_cloudflared
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build with_cloudflare_tunnel
|
||||
//go:build with_cloudflared
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build with_cloudflare_tunnel
|
||||
//go:build with_cloudflared
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build with_cloudflare_tunnel
|
||||
//go:build with_cloudflared
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build with_cloudflare_tunnel
|
||||
//go:build with_cloudflared
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build with_cloudflare_tunnel
|
||||
//go:build with_cloudflared
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build with_cloudflare_tunnel
|
||||
//go:build with_cloudflared
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build with_cloudflare_tunnel
|
||||
//go:build with_cloudflared
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build with_cloudflare_tunnel
|
||||
//go:build with_cloudflared
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -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{},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build with_cloudflare_tunnel
|
||||
//go:build with_cloudflared
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -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{}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build with_cloudflare_tunnel
|
||||
//go:build with_cloudflared
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build with_cloudflare_tunnel
|
||||
//go:build with_cloudflared
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build with_cloudflare_tunnel
|
||||
//go:build with_cloudflared
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build with_cloudflare_tunnel
|
||||
//go:build with_cloudflared
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build with_cloudflare_tunnel
|
||||
//go:build with_cloudflared
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build with_cloudflare_tunnel
|
||||
//go:build with_cloudflared
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build with_cloudflare_tunnel
|
||||
//go:build with_cloudflared
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build with_cloudflare_tunnel
|
||||
//go:build with_cloudflared
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build with_cloudflare_tunnel
|
||||
//go:build with_cloudflared
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
Reference in New Issue
Block a user