diff --git a/client/src/nat.rs b/client/src/nat.rs index b7d22d5..ed1979e 100644 --- a/client/src/nat.rs +++ b/client/src/nat.rs @@ -21,7 +21,11 @@ pub struct NatTraverse<'a> { } impl<'a> NatTraverse<'a> { - pub fn new(interface: &'a InterfaceName, backend: Backend, diffs: &[PeerDiff]) -> Result { + pub fn new( + interface: &'a InterfaceName, + backend: Backend, + diffs: &[PeerDiff], + ) -> Result { let mut remaining: Vec<_> = diffs.iter().filter_map(|diff| diff.new).cloned().collect(); for peer in &mut remaining { diff --git a/server/src/db/peer.rs b/server/src/db/peer.rs index 5bf7973..897632f 100644 --- a/server/src/db/peer.rs +++ b/server/src/db/peer.rs @@ -3,7 +3,7 @@ use crate::ServerError; use lazy_static::lazy_static; use regex::Regex; use rusqlite::{params, types::Type, Connection}; -use shared::{Endpoint, Peer, PeerContents, PERSISTENT_KEEPALIVE_INTERVAL_SECS}; +use shared::{Peer, PeerContents, PERSISTENT_KEEPALIVE_INTERVAL_SECS}; use std::{ net::IpAddr, ops::{Deref, DerefMut}, @@ -240,10 +240,14 @@ impl DatabasePeer { let invite_expires = row .get::<_, Option>(9)? .map(|unixtime| SystemTime::UNIX_EPOCH + Duration::from_secs(unixtime)); - let candidates_str: String = row.get(10)?; - let candidates: Vec = serde_json::from_str(&candidates_str).map_err(|_| { - rusqlite::Error::InvalidColumnType(10, "candidates (json)".into(), Type::Text) - })?; + + let candidates = if let Some(candidates) = row.get::<_, Option>(10)? { + serde_json::from_str(&candidates).map_err(|_| { + rusqlite::Error::InvalidColumnType(10, "candidates (json)".into(), Type::Text) + })? + } else { + vec![] + }; let persistent_keepalive_interval = Some(PERSISTENT_KEEPALIVE_INTERVAL_SECS);