Skip to content

Commit 02e1351

Browse files
committed
Fix legacy migration
1 parent 6d2f40f commit 02e1351

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

nym-vpn-core/crates/nym-vpn-lib-types/src/gateway.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ impl NodeIdentity {
3838
&self.key
3939
}
4040

41+
pub fn from_bytes(bytes: &[u8]) -> Result<Self, Ed25519RecoveryError> {
42+
ed25519::PublicKey::from_bytes(bytes).map(Self::from)
43+
}
44+
4145
pub fn from_base58_string(s: impl AsRef<[u8]>) -> Result<Self, Ed25519RecoveryError> {
4246
ed25519::PublicKey::from_base58_string(s).map(Self::from)
4347
}

nym-vpn-core/crates/nym-vpnd/src/service/config.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -745,9 +745,9 @@ impl TryFrom<ExitPointExtV1> for ExitPoint {
745745
// Legacy TOML version of config file.
746746
//
747747

748-
#[derive(Clone, Debug, Serialize, Deserialize)]
748+
#[derive(Clone, Debug, Deserialize)]
749749
enum LegacyEntryPoint {
750-
Gateway { identity: NodeIdentity },
750+
Gateway { identity: Vec<u8> },
751751
Location { location: String },
752752
Random,
753753
}
@@ -757,7 +757,10 @@ impl TryFrom<LegacyEntryPoint> for EntryPoint {
757757

758758
fn try_from(value: LegacyEntryPoint) -> Result<Self, Self::Error> {
759759
match value {
760-
LegacyEntryPoint::Gateway { identity } => Ok(EntryPoint::Gateway { identity }),
760+
LegacyEntryPoint::Gateway { identity } => Ok(EntryPoint::Gateway {
761+
identity: NodeIdentity::from_bytes(&identity)
762+
.map_err(|e| ConfigSetupError::EntryPoint(e.to_string()))?,
763+
}),
761764
LegacyEntryPoint::Location { location } => Ok(EntryPoint::Country {
762765
two_letter_iso_country_code: location,
763766
}),
@@ -766,10 +769,10 @@ impl TryFrom<LegacyEntryPoint> for EntryPoint {
766769
}
767770
}
768771

769-
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
772+
#[derive(Clone, Debug, PartialEq, Eq, Deserialize)]
770773
enum LegacyExitPoint {
771774
Address { address: String },
772-
Gateway { identity: NodeIdentity },
775+
Gateway { identity: Vec<u8> },
773776
Location { location: String },
774777
Random,
775778
}
@@ -786,7 +789,10 @@ impl TryFrom<LegacyExitPoint> for ExitPoint {
786789
address: Box::new(recipient),
787790
})
788791
}
789-
LegacyExitPoint::Gateway { identity } => Ok(ExitPoint::Gateway { identity }),
792+
LegacyExitPoint::Gateway { identity } => Ok(ExitPoint::Gateway {
793+
identity: NodeIdentity::from_bytes(&identity)
794+
.map_err(|e| ConfigSetupError::ExitPoint(e.to_string()))?,
795+
}),
790796
LegacyExitPoint::Location { location } => Ok(ExitPoint::Country {
791797
two_letter_iso_country_code: location,
792798
}),

0 commit comments

Comments
 (0)