features.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 (
  13. DefaultFeatures = []string{
  14. FeatureAllowRemoteConfig,
  15. FeatureSerializedHeaders,
  16. FeatureDatagramV2,
  17. FeatureQUICSupportEOF,
  18. FeatureManagementLogs,
  19. }
  20. )
  21. func Contains(feature string) bool {
  22. for _, f := range DefaultFeatures {
  23. if f == feature {
  24. return true
  25. }
  26. }
  27. return false
  28. }
  29. // Remove any duplicates from the slice
  30. func Dedup(slice []string) []string {
  31. // Convert the slice into a set
  32. set := make(map[string]bool, 0)
  33. for _, str := range slice {
  34. set[str] = true
  35. }
  36. // Convert the set back into a slice
  37. keys := make([]string, len(set))
  38. i := 0
  39. for str := range set {
  40. keys[i] = str
  41. i++
  42. }
  43. return keys
  44. }