Fix cloudflared registration parameter inconsistencies
- Set QUIC InitialPacketSize per IP family (IPv4: 1252, IPv6: 1232) - Set MaxIncomingStreams/MaxIncomingUniStreams to 1<<60 - Populate OriginLocalIP from local socket address in both QUIC and HTTP/2 - Pass NumPreviousAttempts from retry counter to registration - Include version number in client version string - Use OS_GOARCH format for Arch field
This commit is contained in:
@@ -5,9 +5,11 @@ package cloudflare
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
C "github.com/sagernet/sing-box/constant"
|
||||
"github.com/sagernet/sing-box/protocol/cloudflare/tunnelrpc"
|
||||
E "github.com/sagernet/sing/common/exceptions"
|
||||
|
||||
@@ -18,9 +20,10 @@ import (
|
||||
|
||||
const (
|
||||
registrationTimeout = 10 * time.Second
|
||||
clientVersion = "sing-box"
|
||||
)
|
||||
|
||||
var clientVersion = "sing-box " + C.Version
|
||||
|
||||
// RegistrationClient handles the Cap'n Proto RPC for tunnel registration.
|
||||
type RegistrationClient struct {
|
||||
client tunnelrpc.TunnelServer
|
||||
@@ -148,14 +151,15 @@ func (c *RegistrationClient) Close() error {
|
||||
}
|
||||
|
||||
// BuildConnectionOptions creates the ConnectionOptions to send during registration.
|
||||
func BuildConnectionOptions(connectorID uuid.UUID, features []string, numPreviousAttempts uint8) *RegistrationConnectionOptions {
|
||||
func BuildConnectionOptions(connectorID uuid.UUID, features []string, numPreviousAttempts uint8, originLocalIP net.IP) *RegistrationConnectionOptions {
|
||||
return &RegistrationConnectionOptions{
|
||||
Client: RegistrationClientInfo{
|
||||
ClientID: connectorID[:],
|
||||
Features: features,
|
||||
Version: clientVersion,
|
||||
Arch: runtime.GOARCH,
|
||||
Arch: runtime.GOOS + "_" + runtime.GOARCH,
|
||||
},
|
||||
OriginLocalIP: originLocalIP,
|
||||
NumPreviousAttempts: numPreviousAttempts,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user