TUN-9883: Add new datagram v3 feature flag
After the previous rollout was reverted, the original `support_datagram_v3_1` is deprecated and replaced with `support_datagram_v3_2`. Closes TUN-9883
This commit is contained in:
parent
d78e64c8cc
commit
1ac6c45dad
|
|
@ -45,6 +45,6 @@ func (m *mockFeatureSelector) Snapshot() features.FeatureSnapshot {
|
||||||
return features.FeatureSnapshot{
|
return features.FeatureSnapshot{
|
||||||
PostQuantum: features.PostQuantumPrefer,
|
PostQuantum: features.PostQuantumPrefer,
|
||||||
DatagramVersion: features.DatagramV3,
|
DatagramVersion: features.DatagramV3,
|
||||||
FeaturesList: []string{features.FeaturePostQuantum, features.FeatureDatagramV3_1},
|
FeaturesList: []string{features.FeaturePostQuantum, features.FeatureDatagramV3_2},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,10 @@ const (
|
||||||
FeaturePostQuantum = "postquantum"
|
FeaturePostQuantum = "postquantum"
|
||||||
FeatureQUICSupportEOF = "support_quic_eof"
|
FeatureQUICSupportEOF = "support_quic_eof"
|
||||||
FeatureManagementLogs = "management_logs"
|
FeatureManagementLogs = "management_logs"
|
||||||
FeatureDatagramV3_1 = "support_datagram_v3_1"
|
FeatureDatagramV3_2 = "support_datagram_v3_2"
|
||||||
|
|
||||||
DeprecatedFeatureDatagramV3 = "support_datagram_v3" // Deprecated: TUN-9291
|
DeprecatedFeatureDatagramV3 = "support_datagram_v3" // Deprecated: TUN-9291
|
||||||
|
DeprecatedFeatureDatagramV3_1 = "support_datagram_v3_1" // Deprecated: TUN-9883
|
||||||
)
|
)
|
||||||
|
|
||||||
var defaultFeatures = []string{
|
var defaultFeatures = []string{
|
||||||
|
|
@ -26,6 +27,7 @@ var defaultFeatures = []string{
|
||||||
// List of features that are no longer in-use.
|
// List of features that are no longer in-use.
|
||||||
var deprecatedFeatures = []string{
|
var deprecatedFeatures = []string{
|
||||||
DeprecatedFeatureDatagramV3,
|
DeprecatedFeatureDatagramV3,
|
||||||
|
DeprecatedFeatureDatagramV3_1,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Features set by user provided flags
|
// Features set by user provided flags
|
||||||
|
|
@ -58,7 +60,7 @@ const (
|
||||||
// DatagramV2 is the currently supported datagram protocol for UDP and ICMP packets
|
// DatagramV2 is the currently supported datagram protocol for UDP and ICMP packets
|
||||||
DatagramV2 DatagramVersion = FeatureDatagramV2
|
DatagramV2 DatagramVersion = FeatureDatagramV2
|
||||||
// DatagramV3 is a new datagram protocol for UDP and ICMP packets. It is not backwards compatible with datagram v2.
|
// DatagramV3 is a new datagram protocol for UDP and ICMP packets. It is not backwards compatible with datagram v2.
|
||||||
DatagramV3 DatagramVersion = FeatureDatagramV3_1
|
DatagramV3 DatagramVersion = FeatureDatagramV3_2
|
||||||
)
|
)
|
||||||
|
|
||||||
// Remove any duplicate features from the list and remove deprecated features
|
// Remove any duplicate features from the list and remove deprecated features
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,10 @@ const (
|
||||||
// If the TXT record is missing a key, the field will unmarshal to the default Go value
|
// If the TXT record is missing a key, the field will unmarshal to the default Go value
|
||||||
|
|
||||||
type featuresRecord struct {
|
type featuresRecord struct {
|
||||||
DatagramV3Percentage uint32 `json:"dv3_1"`
|
DatagramV3Percentage uint32 `json:"dv3_2"`
|
||||||
|
|
||||||
// DatagramV3Percentage int32 `json:"dv3"` // Removed in TUN-9291
|
// DatagramV3Percentage int32 `json:"dv3"` // Removed in TUN-9291
|
||||||
|
// DatagramV3Percentage uint32 `json:"dv3_1"` // Removed in TUN-9883
|
||||||
// PostQuantumPercentage int32 `json:"pq"` // Removed in TUN-7970
|
// PostQuantumPercentage int32 `json:"pq"` // Removed in TUN-7970
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -105,7 +106,7 @@ func (fs *featureSelector) postQuantumMode() PostQuantumMode {
|
||||||
|
|
||||||
func (fs *featureSelector) datagramVersion() DatagramVersion {
|
func (fs *featureSelector) datagramVersion() DatagramVersion {
|
||||||
// If user provides the feature via the cli, we take it as priority over remote feature evaluation
|
// If user provides the feature via the cli, we take it as priority over remote feature evaluation
|
||||||
if slices.Contains(fs.cliFeatures, FeatureDatagramV3_1) {
|
if slices.Contains(fs.cliFeatures, FeatureDatagramV3_2) {
|
||||||
return DatagramV3
|
return DatagramV3
|
||||||
}
|
}
|
||||||
// If the user specifies DatagramV2, we also take that over remote
|
// If the user specifies DatagramV2, we also take that over remote
|
||||||
|
|
|
||||||
|
|
@ -22,15 +22,15 @@ func TestUnmarshalFeaturesRecord(t *testing.T) {
|
||||||
expectedPercentage uint32
|
expectedPercentage uint32
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
record: []byte(`{"dv3_1":0}`),
|
record: []byte(`{"dv3_2":0}`),
|
||||||
expectedPercentage: 0,
|
expectedPercentage: 0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
record: []byte(`{"dv3_1":39}`),
|
record: []byte(`{"dv3_2":39}`),
|
||||||
expectedPercentage: 39,
|
expectedPercentage: 39,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
record: []byte(`{"dv3_1":100}`),
|
record: []byte(`{"dv3_2":100}`),
|
||||||
expectedPercentage: 100,
|
expectedPercentage: 100,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -40,7 +40,7 @@ func TestUnmarshalFeaturesRecord(t *testing.T) {
|
||||||
record: []byte(`{"kyber":768}`), // Unmarshal to default struct if key is not present
|
record: []byte(`{"kyber":768}`), // Unmarshal to default struct if key is not present
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
record: []byte(`{"pq": 101,"dv3":100}`), // Expired keys don't unmarshal to anything
|
record: []byte(`{"pq": 101,"dv3":100,"dv3_1":100}`), // Expired keys don't unmarshal to anything
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -111,10 +111,10 @@ func TestFeaturePrecedenceEvaluationDatagramVersion(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "user_specified_v3",
|
name: "user_specified_v3",
|
||||||
cli: []string{FeatureDatagramV3_1},
|
cli: []string{FeatureDatagramV3_2},
|
||||||
remote: featuresRecord{},
|
remote: featuresRecord{},
|
||||||
expectedFeatures: dedupAndRemoveFeatures(append(defaultFeatures, FeatureDatagramV3_1)),
|
expectedFeatures: dedupAndRemoveFeatures(append(defaultFeatures, FeatureDatagramV3_2)),
|
||||||
expectedVersion: FeatureDatagramV3_1,
|
expectedVersion: FeatureDatagramV3_2,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -150,6 +150,12 @@ func TestDeprecatedFeaturesRemoved(t *testing.T) {
|
||||||
remote: featuresRecord{},
|
remote: featuresRecord{},
|
||||||
expectedFeatures: defaultFeatures,
|
expectedFeatures: defaultFeatures,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "support_datagram_v3_1",
|
||||||
|
cli: []string{DeprecatedFeatureDatagramV3_1},
|
||||||
|
remote: featuresRecord{},
|
||||||
|
expectedFeatures: defaultFeatures,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue