@@ -4,6 +4,7 @@ use crate::proto::types::{
4
4
use crate :: {
5
5
constraints:: Constraint , custom_list:: Id , relay_constraints:: GeographicLocationConstraint ,
6
6
} ;
7
+ use crate :: { IntoProto , TryFromProto } ;
7
8
use std:: str:: FromStr ;
8
9
use talpid_types:: net:: proxy:: CustomProxy ;
9
10
@@ -26,7 +27,7 @@ impl TryFrom<&types::WireguardConstraints> for crate::relay_constraints::Wiregua
26
27
} ;
27
28
28
29
Ok ( mullvad_constraints:: WireguardConstraints {
29
- port : Constraint :: from ( constraints. port . map ( |port| port as u16 ) ) ,
30
+ port : TryFromProto :: try_from_proto ( constraints. port ) ? ,
30
31
ip_version : Constraint :: from ( ip_version) ,
31
32
use_multihop : constraints. use_multihop ,
32
33
entry_location : constraints
@@ -143,8 +144,8 @@ impl From<crate::relay_constraints::BridgeState> for types::BridgeState {
143
144
}
144
145
}
145
146
146
- impl From < & crate :: relay_constraints:: ObfuscationSettings > for types:: ObfuscationSettings {
147
- fn from ( settings : & crate :: relay_constraints:: ObfuscationSettings ) -> Self {
147
+ impl From < crate :: relay_constraints:: ObfuscationSettings > for types:: ObfuscationSettings {
148
+ fn from ( settings : crate :: relay_constraints:: ObfuscationSettings ) -> Self {
148
149
use crate :: relay_constraints:: SelectedObfuscation ;
149
150
let selected_obfuscation = i32:: from ( match settings. selected_obfuscation {
150
151
SelectedObfuscation :: Auto => types:: obfuscation_settings:: SelectedObfuscation :: Auto ,
@@ -155,23 +156,7 @@ impl From<&crate::relay_constraints::ObfuscationSettings> for types::Obfuscation
155
156
} ) ;
156
157
Self {
157
158
selected_obfuscation,
158
- udp2tcp : Some ( types:: Udp2TcpObfuscationSettings :: from ( & settings. udp2tcp ) ) ,
159
- }
160
- }
161
- }
162
-
163
- impl From < crate :: relay_constraints:: ObfuscationSettings > for types:: ObfuscationSettings {
164
- fn from ( settings : crate :: relay_constraints:: ObfuscationSettings ) -> Self {
165
- types:: ObfuscationSettings :: from ( & settings)
166
- }
167
- }
168
-
169
- impl From < & crate :: relay_constraints:: Udp2TcpObfuscationSettings >
170
- for types:: Udp2TcpObfuscationSettings
171
- {
172
- fn from ( settings : & crate :: relay_constraints:: Udp2TcpObfuscationSettings ) -> Self {
173
- Self {
174
- port : settings. port . map ( u32:: from) . option ( ) ,
159
+ udp2tcp : Some ( settings. udp2tcp . into_proto ( ) ) ,
175
160
}
176
161
}
177
162
}
@@ -441,7 +426,7 @@ impl TryFrom<types::ObfuscationSettings> for crate::relay_constraints::Obfuscati
441
426
442
427
let udp2tcp = match settings. udp2tcp {
443
428
Some ( settings) => {
444
- crate :: relay_constraints:: Udp2TcpObfuscationSettings :: try_from ( & settings) ?
429
+ crate :: relay_constraints:: Udp2TcpObfuscationSettings :: try_from ( settings) ?
445
430
}
446
431
None => {
447
432
return Err ( FromProtobufTypeError :: InvalidArgument (
@@ -457,18 +442,6 @@ impl TryFrom<types::ObfuscationSettings> for crate::relay_constraints::Obfuscati
457
442
}
458
443
}
459
444
460
- impl TryFrom < & types:: Udp2TcpObfuscationSettings >
461
- for crate :: relay_constraints:: Udp2TcpObfuscationSettings
462
- {
463
- type Error = FromProtobufTypeError ;
464
-
465
- fn try_from ( settings : & types:: Udp2TcpObfuscationSettings ) -> Result < Self , Self :: Error > {
466
- Ok ( Self {
467
- port : Constraint :: from ( settings. port . map ( |port| port as u16 ) ) ,
468
- } )
469
- }
470
- }
471
-
472
445
impl TryFrom < types:: BridgeState > for crate :: relay_constraints:: BridgeState {
473
446
type Error = FromProtobufTypeError ;
474
447
@@ -490,7 +463,7 @@ impl TryFrom<types::TransportPort> for crate::relay_constraints::TransportPort {
490
463
fn try_from ( port : types:: TransportPort ) -> Result < Self , Self :: Error > {
491
464
Ok ( crate :: relay_constraints:: TransportPort {
492
465
protocol : super :: net:: try_transport_protocol_from_i32 ( port. protocol ) ?,
493
- port : Constraint :: from ( port. port . map ( |port| port as u16 ) ) ,
466
+ port : TryFromProto :: try_from_proto ( port. port ) ? ,
494
467
} )
495
468
}
496
469
}
0 commit comments