2023-03-29 20:12:32 +00:00
|
|
|
package features
|
|
|
|
|
|
|
|
const (
|
|
|
|
FeatureSerializedHeaders = "serialized_headers"
|
|
|
|
FeatureQuickReconnects = "quick_reconnects"
|
|
|
|
FeatureAllowRemoteConfig = "allow_remote_config"
|
|
|
|
FeatureDatagramV2 = "support_datagram_v2"
|
|
|
|
FeaturePostQuantum = "postquantum"
|
|
|
|
FeatureQUICSupportEOF = "support_quic_eof"
|
|
|
|
FeatureManagementLogs = "management_logs"
|
2024-10-01 22:21:01 +00:00
|
|
|
FeatureDatagramV3 = "support_datagram_v3"
|
2023-03-29 20:12:32 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2025-01-06 17:15:18 +00:00
|
|
|
defaultFeatures = []string{
|
2023-03-29 20:12:32 +00:00
|
|
|
FeatureAllowRemoteConfig,
|
|
|
|
FeatureSerializedHeaders,
|
|
|
|
FeatureDatagramV2,
|
|
|
|
FeatureQUICSupportEOF,
|
2023-04-12 21:41:11 +00:00
|
|
|
FeatureManagementLogs,
|
2023-03-29 20:12:32 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2025-01-06 17:15:18 +00:00
|
|
|
// Features set by user provided flags
|
|
|
|
type staticFeatures struct {
|
|
|
|
PostQuantumMode *PostQuantumMode
|
2023-03-29 20:12:32 +00:00
|
|
|
}
|
2023-08-25 13:39:25 +00:00
|
|
|
|
2025-01-06 17:15:18 +00:00
|
|
|
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
|
|
|
|
)
|
|
|
|
|
2023-08-25 13:39:25 +00:00
|
|
|
// Remove any duplicates from the slice
|
|
|
|
func Dedup(slice []string) []string {
|
|
|
|
|
|
|
|
// Convert the slice into a set
|
|
|
|
set := make(map[string]bool, 0)
|
|
|
|
for _, str := range slice {
|
|
|
|
set[str] = 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
|
|
|
|
}
|