features.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package features
  2. const (
  3. FeatureSerializedHeaders = "serialized_headers"
  4. FeatureQuickReconnects = "quick_reconnects"
  5. FeatureAllowRemoteConfig = "allow_remote_config"
  6. FeatureDatagramV2 = "support_datagram_v2"
  7. FeaturePostQuantum = "postquantum"
  8. FeatureQUICSupportEOF = "support_quic_eof"
  9. FeatureManagementLogs = "management_logs"
  10. FeatureDatagramV3 = "support_datagram_v3"
  11. )
  12. var defaultFeatures = []string{
  13. FeatureAllowRemoteConfig,
  14. FeatureSerializedHeaders,
  15. FeatureDatagramV2,
  16. FeatureQUICSupportEOF,
  17. FeatureManagementLogs,
  18. }
  19. // Features set by user provided flags
  20. type staticFeatures struct {
  21. PostQuantumMode *PostQuantumMode
  22. }
  23. type PostQuantumMode uint8
  24. const (
  25. // Prefer post quantum, but fallback if connection cannot be established
  26. PostQuantumPrefer PostQuantumMode = iota
  27. // If the user passes the --post-quantum flag, we override
  28. // CurvePreferences to only support hybrid post-quantum key agreements.
  29. PostQuantumStrict
  30. )
  31. type DatagramVersion string
  32. const (
  33. // DatagramV2 is the currently supported datagram protocol for UDP and ICMP packets
  34. DatagramV2 DatagramVersion = FeatureDatagramV2
  35. // DatagramV3 is a new datagram protocol for UDP and ICMP packets. It is not backwards compatible with datagram v2.
  36. DatagramV3 DatagramVersion = FeatureDatagramV3
  37. )
  38. // Remove any duplicates from the slice
  39. func Dedup(slice []string) []string {
  40. // Convert the slice into a set
  41. set := make(map[string]bool, 0)
  42. for _, str := range slice {
  43. set[str] = true
  44. }
  45. // Convert the set back into a slice
  46. keys := make([]string, len(set))
  47. i := 0
  48. for str := range set {
  49. keys[i] = str
  50. i++
  51. }
  52. return keys
  53. }