@@ -84,64 +84,11 @@ pub fn migrate(
84
84
}
85
85
}
86
86
87
- migrate_tunnel_type ( settings) ?;
88
-
89
- // TODO: Uncomment this when closing the migration:
90
- // json_blob["settings_version"] = serde_json::json!(SettingsVersion::V10);
87
+ json_blob[ "settings_version" ] = serde_json:: json!( SettingsVersion :: V10 ) ;
91
88
92
89
Ok ( ( ) )
93
90
}
94
91
95
- fn migrate_tunnel_type ( settings : & mut serde_json:: Value ) -> Result < ( ) > {
96
- let Some ( ref mut normal) = relay_settings ( settings) else {
97
- return Ok ( ( ) ) ;
98
- } ;
99
- match normal. get_mut ( "tunnel_protocol" ) {
100
- // Already migrated
101
- Some ( serde_json:: Value :: String ( s) ) if s == "any" => {
102
- // If openvpn is selected, migrate to openvpn tunnel type
103
- // Otherwise, select wireguard
104
- let hostname = normal
105
- . get_mut ( "location" )
106
- . and_then ( |location| location. get_mut ( "only" ) )
107
- . and_then ( |only| only. get_mut ( "location" ) )
108
- . and_then ( |only| only. get_mut ( "hostname" ) . cloned ( ) ) ;
109
-
110
- let protocol = if let Some ( serde_json:: Value :: String ( s) ) = hostname {
111
- if s. split ( '-' ) . any ( |token| token == "ovpn" ) {
112
- TunnelType :: OpenVpn
113
- } else {
114
- TunnelType :: Wireguard
115
- }
116
- } else {
117
- TunnelType :: Wireguard
118
- } ;
119
-
120
- normal[ "tunnel_protocol" ] = serde_json:: json!( protocol) ;
121
- }
122
- // Migrate
123
- Some ( serde_json:: Value :: Object ( ref mut constraint) ) => {
124
- if let Some ( tunnel_type) = constraint. get ( "only" ) {
125
- let tunnel_type: TunnelType = serde_json:: from_value ( tunnel_type. clone ( ) )
126
- . map_err ( |_| Error :: InvalidSettingsContent ) ?;
127
- normal[ "tunnel_protocol" ] = serde_json:: json!( tunnel_type) ;
128
- } else {
129
- return Err ( Error :: InvalidSettingsContent ) ;
130
- }
131
- }
132
- Some ( _) => {
133
- return Err ( Error :: InvalidSettingsContent ) ;
134
- }
135
- // Unexpected result. Do nothing.
136
- None => ( ) ,
137
- }
138
- Ok ( ( ) )
139
- }
140
-
141
- fn relay_settings ( settings : & mut serde_json:: Value ) -> Option < & mut serde_json:: Value > {
142
- settings. get_mut ( "relay_settings" ) ?. get_mut ( "normal" )
143
- }
144
-
145
92
fn version_matches ( settings : & serde_json:: Value ) -> bool {
146
93
settings
147
94
. get ( "settings_version" )
@@ -644,7 +591,7 @@ mod test {
644
591
},
645
592
"providers": "any",
646
593
"ownership": "any",
647
- "tunnel_protocol": "openvpn ",
594
+ "tunnel_protocol": "any ",
648
595
"wireguard_constraints": {
649
596
"port": "any",
650
597
"ip_version": "any",
@@ -732,7 +679,7 @@ mod test {
732
679
},
733
680
"relay_overrides": [],
734
681
"show_beta_releases": true,
735
- "settings_version": 9
682
+ "settings_version": 10
736
683
}
737
684
"# ;
738
685
}
0 commit comments