mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-06-17 22:16:38 +00:00

During a refresh of the supported features via the DNS TXT record, cloudflared would update the internal feature list, but would not propagate this information to the edge during a new connection. This meant that a situation could occur in which cloudflared would think that the client's connection could support datagram V3, and would setup that muxer locally, but would not propagate that information to the edge during a register connection in the `ClientInfo` of the `ConnectionOptions`. This meant that the edge still thought that the client was setup to support datagram V2 and since the protocols are not backwards compatible, the local muxer for datagram V3 would reject the incoming RPC calls. To address this, the feature list will be fetched only once during client bootstrapping and will persist as-is until the client is restarted. This helps reduce the complexity involved with different connections having possibly different sets of features when connecting to the edge. The features will now be tied to the client and never diverge across connections. Also, retires the use of `support_datagram_v3` in-favor of `support_datagram_v3_1` to reduce the risk of reusing the feature key. The `dv3` TXT feature key is also deprecated. Closes TUN-9291
76 lines
2.0 KiB
Go
76 lines
2.0 KiB
Go
package features
|
|
|
|
import "slices"
|
|
|
|
const (
|
|
FeatureSerializedHeaders = "serialized_headers"
|
|
FeatureQuickReconnects = "quick_reconnects"
|
|
FeatureAllowRemoteConfig = "allow_remote_config"
|
|
FeatureDatagramV2 = "support_datagram_v2"
|
|
FeaturePostQuantum = "postquantum"
|
|
FeatureQUICSupportEOF = "support_quic_eof"
|
|
FeatureManagementLogs = "management_logs"
|
|
FeatureDatagramV3_1 = "support_datagram_v3_1"
|
|
|
|
DeprecatedFeatureDatagramV3 = "support_datagram_v3" // Deprecated: TUN-9291
|
|
)
|
|
|
|
var defaultFeatures = []string{
|
|
FeatureAllowRemoteConfig,
|
|
FeatureSerializedHeaders,
|
|
FeatureDatagramV2,
|
|
FeatureQUICSupportEOF,
|
|
FeatureManagementLogs,
|
|
}
|
|
|
|
// List of features that are no longer in-use.
|
|
var deprecatedFeatures = []string{
|
|
DeprecatedFeatureDatagramV3,
|
|
}
|
|
|
|
// Features set by user provided flags
|
|
type staticFeatures struct {
|
|
PostQuantumMode *PostQuantumMode
|
|
}
|
|
|
|
type PostQuantumMode uint8
|
|
|
|
const (
|
|
// Prefer post quantum, but fallback if connection cannot be established
|
|
PostQuantumPrefer PostQuantumMode = iota
|
|
// If the user passes the --post-quantum flag, we override
|
|
// CurvePreferences to only support hybrid post-quantum key agreements.
|
|
PostQuantumStrict
|
|
)
|
|
|
|
type DatagramVersion string
|
|
|
|
const (
|
|
// DatagramV2 is the currently supported datagram protocol for UDP and ICMP packets
|
|
DatagramV2 DatagramVersion = FeatureDatagramV2
|
|
// DatagramV3 is a new datagram protocol for UDP and ICMP packets. It is not backwards compatible with datagram v2.
|
|
DatagramV3 DatagramVersion = FeatureDatagramV3_1
|
|
)
|
|
|
|
// Remove any duplicate features from the list and remove deprecated features
|
|
func dedupAndRemoveFeatures(features []string) []string {
|
|
// Convert the slice into a set
|
|
set := map[string]bool{}
|
|
for _, feature := range features {
|
|
// Remove deprecated features from the provided list
|
|
if slices.Contains(deprecatedFeatures, feature) {
|
|
continue
|
|
}
|
|
set[feature] = true
|
|
}
|
|
|
|
// Convert the set back into a slice
|
|
keys := make([]string, len(set))
|
|
i := 0
|
|
for str := range set {
|
|
keys[i] = str
|
|
i++
|
|
}
|
|
return keys
|
|
}
|