Skip to content

Commit

Permalink
Add exit mixnet and replace whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
neacsu committed Sep 12, 2024
1 parent 30611fc commit 8d5192d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

CREATE TABLE clients (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
client_type TEXT NOT NULL CHECK(client_type IN ('entry mixnet', 'entry wireguard', 'exit wireguard'))
client_type TEXT NOT NULL CHECK(client_type IN ('entry_mixnet', 'exit_mixnet', 'entry_wireguard', 'exit_wireguard'))
);

INSERT INTO clients (id, client_type)
SELECT id, 'entry mixnet'
SELECT id, 'entry_mixnet'
FROM shared_keys;

CREATE TABLE shared_keys_tmp (
Expand Down
15 changes: 9 additions & 6 deletions common/gateway-storage/src/clients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::models::Client;
#[sqlx(type_name = "TEXT")] // SQLite TEXT type
pub enum ClientType {
EntryMixnet,
ExitMixnet,
EntryWireguard,
ExitWireguard,
}
Expand All @@ -18,9 +19,10 @@ impl FromStr for ClientType {

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"entry mixnet" => Ok(ClientType::EntryMixnet),
"entry wireguard" => Ok(ClientType::EntryWireguard),
"exit wireguard" => Ok(ClientType::ExitWireguard),
"entry_mixnet" => Ok(ClientType::EntryMixnet),
"exit_mixnet" => Ok(ClientType::ExitMixnet),
"entry_wireguard" => Ok(ClientType::EntryWireguard),
"exit_wireguard" => Ok(ClientType::ExitWireguard),
_ => Err("Invalid client type"),
}
}
Expand All @@ -29,9 +31,10 @@ impl FromStr for ClientType {
impl std::fmt::Display for ClientType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let s = match self {
ClientType::EntryMixnet => "entry mixnet",
ClientType::EntryWireguard => "entry wireguard",
ClientType::ExitWireguard => "exit wireguard",
ClientType::EntryMixnet => "entry_mixnet",
ClientType::ExitMixnet => "exit_mixnet",
ClientType::EntryWireguard => "entry_wireguard",
ClientType::ExitWireguard => "exit_wireguard",
};
write!(f, "{}", s)
}
Expand Down

0 comments on commit 8d5192d

Please sign in to comment.