Skip to content

Commit

Permalink
convert session keys from binary to hex strings (#408)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffgrunewald authored Mar 14, 2023
1 parent 46ce965 commit 79964fe
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion iot_config/migrations/6_session_key_filters.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
create table session_key_filters (
oui bigint not null references organizations(oui) on delete cascade,
devaddr int not null,
session_key bytea not null,
session_key text not null,

inserted_at timestamptz not null default now(),
updated_at timestamptz not null default now(),
Expand Down
4 changes: 2 additions & 2 deletions iot_config/src/session_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ use tokio::sync::broadcast::Sender;
pub struct SessionKeyFilter {
pub oui: u64,
pub devaddr: DevAddrField,
pub session_key: Vec<u8>,
pub session_key: String,
}

impl FromRow<'_, PgRow> for SessionKeyFilter {
fn from_row(row: &PgRow) -> sqlx::Result<Self> {
Ok(Self {
oui: row.get::<i64, &str>("oui") as u64,
devaddr: row.get::<i32, &str>("devaddr").into(),
session_key: row.get::<Vec<u8>, &str>("session_key"),
session_key: row.get::<String, &str>("session_key"),
})
}
}
Expand Down
6 changes: 2 additions & 4 deletions iot_config/src/session_key_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ impl iot_config::SessionKeyFilter for SessionKeyFilterService {
let message = match filter {
Ok(filter) => Ok(filter.into()),
Err(bad_filter) => Err(Status::internal(format!(
"invalid session key filter {:?}",
bad_filter
"invalid session key filter {bad_filter:?}"
))),
};
if tx.send(message).await.is_err() {
Expand Down Expand Up @@ -156,8 +155,7 @@ impl iot_config::SessionKeyFilter for SessionKeyFilterService {
let message = match filter {
Ok(filter) => Ok(filter.into()),
Err(bad_filter) => Err(Status::internal(format!(
"invalid session key filter {:?}",
bad_filter
"invalid session key filter {bad_filter:?}"
))),
};
if tx.send(message).await.is_err() {
Expand Down

0 comments on commit 79964fe

Please sign in to comment.