fix tor address field on update

This commit is contained in:
Aiden McClelland
2021-09-08 18:08:39 -06:00
committed by Aiden McClelland
parent 2f8e71d459
commit 296c2a98c3
2 changed files with 24 additions and 13 deletions

View File

@@ -178,6 +178,24 @@
]
}
},
"c895b08869cc611708d37643ec92b5c827c1766c63e263d5687aa639357b27e6": {
"query": "INSERT OR IGNORE INTO tor (package, interface, key) VALUES (?, ?, ?) RETURNING key AS \"key!:Vec<u8>\"",
"describe": {
"columns": [
{
"name": "key!:Vec<u8>",
"ordinal": 0,
"type_info": "Null"
}
],
"parameters": {
"Right": 3
},
"nullable": [
null
]
}
},
"d5117054072476377f3c4f040ea429d4c9b2cf534e76f35c80a2bf60e8599cca": {
"query": "SELECT openssh_pubkey FROM ssh_keys",
"describe": {
@@ -196,16 +214,6 @@
]
}
},
"d79d608ceb862c15b741a6040044c6dd54a837a3a0c5594d15a6041c7bc68ea8": {
"query": "INSERT OR IGNORE INTO tor (package, interface, key) VALUES (?, ?, ?)",
"describe": {
"columns": [],
"parameters": {
"Right": 3
},
"nullable": []
}
},
"de2a5e90798d606047ab8180c044baac05469c0cdf151316bd58ee8c7196fdef": {
"query": "SELECT * FROM ssh_keys WHERE fingerprint = ?",
"describe": {

View File

@@ -36,14 +36,17 @@ impl Interfaces {
if iface.tor_config.is_some() || iface.lan_config.is_some() {
let key = TorSecretKeyV3::generate();
let key_vec = key.as_bytes().to_vec();
sqlx::query!(
"INSERT OR IGNORE INTO tor (package, interface, key) VALUES (?, ?, ?)",
let key_row = sqlx::query!(
"INSERT OR IGNORE INTO tor (package, interface, key) VALUES (?, ?, ?) RETURNING key AS \"key!:Vec<u8>\"",
**package_id,
**id,
key_vec,
)
.execute(&mut *secrets)
.fetch_one(&mut *secrets)
.await?;
let mut key = [0_u8; 64];
key.clone_from_slice(&key_row.key);
let key = TorSecretKeyV3::from(key);
let onion = key.public().get_onion_address();
if iface.tor_config.is_some() {
addrs.tor_address = Some(onion.to_string());