mirror of
https://github.com/stakwork/sphinx-key.git
synced 2025-12-19 08:14:28 +01:00
cargo fmt
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
use crate::ChannelRequest;
|
||||
use bitcoin::Network;
|
||||
use sphinx_key_parser as parser;
|
||||
use sphinx_key_parser::MsgDriver;
|
||||
use tokio::sync::{mpsc, oneshot};
|
||||
use vls_protocol::model::Secret;
|
||||
use vls_protocol::{msgs, serde_bolt::WireString};
|
||||
use vls_proxy::util::{read_allowlist, read_integration_test_seed};
|
||||
use bitcoin::Network;
|
||||
|
||||
pub fn blocking_connect(tx: mpsc::Sender<ChannelRequest>, network: Network) {
|
||||
let init_msg_2 = crate::init::make_init_msg(network).expect("couldnt make init msg");
|
||||
@@ -40,8 +40,12 @@ pub fn make_init_msg(network: Network) -> anyhow::Result<Vec<u8>> {
|
||||
.into_iter()
|
||||
.map(|s| WireString(s.as_bytes().to_vec()))
|
||||
.collect::<Vec<_>>();
|
||||
let seed = if network==Network::Bitcoin {
|
||||
Some(Secret([0x8c, 0xe8, 0x62, 0xab, 0xd5, 0x6b, 0xb4, 0x6a, 0x61, 0x7f, 0xaf, 0x13, 0x50, 0xc1, 0xca, 0xf5, 0xb1, 0xee, 0x02, 0x97, 0xbf, 0xf3, 0xb8, 0xc9, 0x56, 0x63, 0x58, 0x9f, 0xec, 0x8c, 0x45, 0x79]))
|
||||
let seed = if network == Network::Bitcoin {
|
||||
Some(Secret([
|
||||
0x8c, 0xe8, 0x62, 0xab, 0xd5, 0x6b, 0xb4, 0x6a, 0x61, 0x7f, 0xaf, 0x13, 0x50, 0xc1,
|
||||
0xca, 0xf5, 0xb1, 0xee, 0x02, 0x97, 0xbf, 0xf3, 0xb8, 0xc9, 0x56, 0x63, 0x58, 0x9f,
|
||||
0xec, 0x8c, 0x45, 0x79,
|
||||
]))
|
||||
} else {
|
||||
read_integration_test_seed()
|
||||
.map(|s| Secret(s))
|
||||
|
||||
@@ -9,8 +9,8 @@ mod util;
|
||||
use crate::chain_tracker::MqttSignerPort;
|
||||
use crate::mqtt::start_broker;
|
||||
use crate::unix_fd::SignerLoop;
|
||||
use clap::{App, AppSettings, Arg};
|
||||
use bitcoin::Network;
|
||||
use clap::{App, AppSettings, Arg};
|
||||
use std::env;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::{mpsc, oneshot};
|
||||
|
||||
@@ -6,9 +6,9 @@ use librumqttd::{
|
||||
Config,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
use std::sync::{LazyLock, Mutex};
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
use std::sync::{LazyLock, Mutex};
|
||||
use tokio::sync::mpsc;
|
||||
use tokio::time::timeout;
|
||||
|
||||
|
||||
@@ -85,4 +85,4 @@ pub async fn iteration(
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use fsdb::{Bucket, DoubleBucket, Fsdb};
|
||||
use lightning_signer_server::lightning_signer;
|
||||
use lightning_signer::bitcoin::secp256k1::PublicKey;
|
||||
use lightning_signer::chain::tracker::ChainTracker;
|
||||
use lightning_signer::channel::{Channel, ChannelId, ChannelStub};
|
||||
@@ -7,6 +6,7 @@ use lightning_signer::monitor::ChainMonitor;
|
||||
use lightning_signer::node::{NodeConfig, NodeState as CoreNodeState};
|
||||
use lightning_signer::persist::Persist;
|
||||
use lightning_signer::policy::validator::EnforcementState;
|
||||
use lightning_signer_server::lightning_signer;
|
||||
use lightning_signer_server::persist::model::{
|
||||
AllowlistItemEntry, ChainTrackerEntry, ChannelEntry, NodeEntry, NodeStateEntry,
|
||||
};
|
||||
@@ -48,7 +48,13 @@ fn get_channel_key(channel_id: &[u8]) -> &[u8] {
|
||||
}
|
||||
|
||||
impl Persist for FsPersister {
|
||||
fn new_node(&self, node_id: &PublicKey, config: &NodeConfig, state: &CoreNodeState, seed: &[u8]) {
|
||||
fn new_node(
|
||||
&self,
|
||||
node_id: &PublicKey,
|
||||
config: &NodeConfig,
|
||||
state: &CoreNodeState,
|
||||
seed: &[u8],
|
||||
) {
|
||||
let pk = hex::encode(node_id.serialize());
|
||||
let state_entry = state.into();
|
||||
let _ = self.states.put(&pk, state_entry);
|
||||
@@ -198,7 +204,6 @@ impl Persist for FsPersister {
|
||||
excess_amount: 0,
|
||||
log_prefix: "".to_string(),
|
||||
velocity_control: state_entry.velocity_control.into(),
|
||||
|
||||
};
|
||||
let entry = CoreNodeEntry {
|
||||
seed: node.seed,
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
mod randomstartingtime;
|
||||
|
||||
pub use vls_protocol_signer::lightning_signer;
|
||||
pub use vls_protocol_signer::vls_protocol;
|
||||
use lightning_signer::persist::Persist;
|
||||
use lightning_signer::policy::simple_validator::{make_simple_policy, SimpleValidatorFactory};
|
||||
use lightning_signer::policy::filter::PolicyFilter;
|
||||
use lightning_signer::node::NodeServices;
|
||||
use lightning_signer::persist::Persist;
|
||||
use lightning_signer::policy::filter::PolicyFilter;
|
||||
use lightning_signer::policy::simple_validator::{make_simple_policy, SimpleValidatorFactory};
|
||||
use lightning_signer::util::clock::StandardClock;
|
||||
use lightning_signer::util::velocity::{VelocityControlIntervalType, VelocityControlSpec};
|
||||
use randomstartingtime::RandomStartingTimeFactory;
|
||||
pub use vls_protocol_signer::lightning_signer;
|
||||
pub use vls_protocol_signer::vls_protocol;
|
||||
// use lightning_signer::persist::DummyPersister;
|
||||
use std::sync::Arc;
|
||||
use vls_protocol::model::PubKey;
|
||||
@@ -62,13 +62,7 @@ pub fn init(bytes: Vec<u8>, network: Network) -> anyhow::Result<InitResponse> {
|
||||
};
|
||||
|
||||
log::info!("create root handler now");
|
||||
let root_handler = RootHandler::new(
|
||||
network,
|
||||
0,
|
||||
Some(seed),
|
||||
allowlist,
|
||||
services,
|
||||
);
|
||||
let root_handler = RootHandler::new(network, 0, Some(seed), allowlist, services);
|
||||
log::info!("root_handler created");
|
||||
let init_reply = root_handler
|
||||
.handle(Message::HsmdInit2(init))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use vls_protocol_signer::lightning_signer;
|
||||
use lightning_signer::signer::StartingTimeFactory;
|
||||
use rand::{rngs::OsRng, RngCore};
|
||||
use std::sync::Arc;
|
||||
use vls_protocol_signer::lightning_signer;
|
||||
|
||||
/// A starting time factory which uses entropy from the RNG
|
||||
pub(crate) struct RandomStartingTimeFactory {}
|
||||
|
||||
@@ -188,4 +188,4 @@ async function fetchWithTimeout(resource, options = {}) {
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
"#;
|
||||
"#;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::conn::html;
|
||||
use crate::core::config::{Config, ConfigDTO, ecdh_keypair, decrypt_seed};
|
||||
use crate::core::config::{decrypt_seed, ecdh_keypair, Config, ConfigDTO};
|
||||
|
||||
use serde::Deserialize;
|
||||
use std::sync::{Arc, Condvar, Mutex};
|
||||
@@ -19,14 +19,19 @@ pub struct Params {
|
||||
|
||||
#[allow(unused_variables)]
|
||||
pub fn config_server(mutex: Arc<(Mutex<Option<Config>>, Condvar)>) -> Result<idf::Server> {
|
||||
|
||||
let (sk1, pk1) = ecdh_keypair();
|
||||
|
||||
let server = idf::ServerRegistry::new()
|
||||
.at("/")
|
||||
.get(|_| Ok(html::HTML.into()))?
|
||||
.at("/ecdh")
|
||||
.get(move |_| Ok(format!("{{\"pubkey\":\"{}\"}}", hex::encode(pk1.serialize())).to_owned().into()))?
|
||||
.get(move |_| {
|
||||
Ok(
|
||||
format!("{{\"pubkey\":\"{}\"}}", hex::encode(pk1.serialize()))
|
||||
.to_owned()
|
||||
.into(),
|
||||
)
|
||||
})?
|
||||
.at("/config")
|
||||
.post(move |request| {
|
||||
let bod = &request
|
||||
@@ -38,7 +43,7 @@ pub fn config_server(mutex: Arc<(Mutex<Option<Config>>, Condvar)>) -> Result<idf
|
||||
let dto = serde_json::from_str::<ConfigDTO>(¶ms.config)?;
|
||||
|
||||
let conf = decrypt_seed(dto, sk1)?;
|
||||
|
||||
|
||||
let mut wait = mutex.0.lock().unwrap();
|
||||
*wait = Some(conf);
|
||||
mutex.1.notify_one();
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
pub mod wifi;
|
||||
mod html;
|
||||
pub mod http;
|
||||
pub mod mqtt;
|
||||
pub mod sntp;
|
||||
mod html;
|
||||
|
||||
|
||||
|
||||
pub mod wifi;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
use esp_idf_svc::sntp::EspSntp;
|
||||
use esp_idf_svc::sntp::SyncStatus::Completed;
|
||||
use std::time::Duration;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
pub fn sync_time() {
|
||||
let sntp = EspSntp::new_default().unwrap();
|
||||
println!("SNTP initialized");
|
||||
while sntp.get_sync_status() != Completed {
|
||||
println!("Waiting for sntp sync...");
|
||||
thread::sleep(Duration::from_secs(1));
|
||||
println!("Waiting for sntp sync...");
|
||||
thread::sleep(Duration::from_secs(1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@ use crate::conn;
|
||||
|
||||
use anyhow::Result;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::convert::TryInto;
|
||||
use std::sync::{Arc, Condvar, Mutex};
|
||||
use std::time::Duration;
|
||||
use std::convert::TryInto;
|
||||
|
||||
use embedded_svc::wifi::*;
|
||||
use esp_idf_svc::nvs::*;
|
||||
@@ -13,7 +13,7 @@ use esp_idf_svc::wifi::*;
|
||||
use sphinx_crypter::chacha::{decrypt, PAYLOAD_LEN};
|
||||
use sphinx_crypter::ecdh::{derive_shared_secret_from_slice, PUBLIC_KEY_LEN};
|
||||
use sphinx_crypter::secp256k1::rand::thread_rng;
|
||||
use sphinx_crypter::secp256k1::{Secp256k1, SecretKey, PublicKey};
|
||||
use sphinx_crypter::secp256k1::{PublicKey, Secp256k1, SecretKey};
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct Config {
|
||||
@@ -52,8 +52,7 @@ pub fn ecdh_keypair() -> (SecretKey, PublicKey) {
|
||||
pub fn decrypt_seed(dto: ConfigDTO, sk1: SecretKey) -> Result<Config> {
|
||||
let their_pk = hex::decode(dto.pubkey)?;
|
||||
let their_pk_bytes: [u8; PUBLIC_KEY_LEN] = their_pk[..PUBLIC_KEY_LEN].try_into()?;
|
||||
let shared_secret =
|
||||
derive_shared_secret_from_slice(their_pk_bytes, sk1.secret_bytes())?;
|
||||
let shared_secret = derive_shared_secret_from_slice(their_pk_bytes, sk1.secret_bytes())?;
|
||||
// decrypt seed
|
||||
let cipher_seed = hex::decode(dto.seed)?;
|
||||
let cipher: [u8; PAYLOAD_LEN] = cipher_seed[..PAYLOAD_LEN].try_into()?;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::conn::mqtt::{QOS, RETURN_TOPIC, TOPIC};
|
||||
use crate::core::init::make_init_msg;
|
||||
use crate::core::config::Config;
|
||||
use crate::core::init::make_init_msg;
|
||||
|
||||
use sphinx_key_signer::lightning_signer::bitcoin::Network;
|
||||
use sphinx_key_signer::vls_protocol::model::PubKey;
|
||||
@@ -43,7 +43,7 @@ pub fn make_event_loop(
|
||||
network: Network,
|
||||
do_log: bool,
|
||||
led_tx: mpsc::Sender<Status>,
|
||||
config: Config
|
||||
config: Config,
|
||||
) -> Result<()> {
|
||||
while let Ok(event) = rx.recv() {
|
||||
log::info!("BROKER IP AND PORT: {}", config.broker);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use sphinx_key_signer::MsgDriver;
|
||||
use sphinx_key_signer::lightning_signer::bitcoin::Network;
|
||||
use sphinx_key_signer::vls_protocol::model::Secret;
|
||||
use sphinx_key_signer::vls_protocol::{msgs, serde_bolt::WireString};
|
||||
use sphinx_key_signer::lightning_signer::bitcoin::Network;
|
||||
use sphinx_key_signer::MsgDriver;
|
||||
|
||||
pub fn make_init_msg(network: Network, seed: [u8; 32]) -> anyhow::Result<Vec<u8>> {
|
||||
let allowlist = Vec::new();
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
pub mod events;
|
||||
pub mod config;
|
||||
pub mod init;
|
||||
pub mod events;
|
||||
pub mod init;
|
||||
|
||||
@@ -106,7 +106,7 @@ fn main() -> Result<()> {
|
||||
.put_raw("config", &conf[..])
|
||||
.expect("could not store config");
|
||||
println!("CONFIG SAVED");
|
||||
loop {};
|
||||
loop {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
use crate::core::events::Status;
|
||||
use embedded_hal::delay::blocking::DelayUs;
|
||||
use esp_idf_hal::delay::Ets;
|
||||
use esp_idf_hal::{gpio, rmt};
|
||||
use esp_idf_hal::rmt::config::TransmitConfig;
|
||||
use esp_idf_hal::rmt::{FixedLengthSignal, PinState, Pulse, Transmit};
|
||||
use esp_idf_hal::{gpio, rmt};
|
||||
use std::collections::BTreeMap;
|
||||
use std::sync::{mpsc, Arc, Mutex};
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
type Color = u32;
|
||||
type Time = u32;
|
||||
@@ -18,23 +18,23 @@ pub struct Led {
|
||||
}
|
||||
|
||||
fn states() -> BTreeMap<Status, (Color, Time)> {
|
||||
let mut s = BTreeMap::new();
|
||||
s.insert(Status::Starting, (0x000001, 100));
|
||||
s.insert(Status::MountingSDCard, (0x000102, 100));
|
||||
s.insert(Status::SyncingTime, (0x000122, 100));
|
||||
s.insert(Status::WifiAccessPoint, (0x000100, 100));
|
||||
s.insert(Status::Configuring, (0x010000, 20));
|
||||
s.insert(Status::ConnectingToWifi, (0x010100, 350));
|
||||
s.insert(Status::ConnectingToMqtt, (0x010001, 100));
|
||||
s.insert(Status::Connected, (0x000101, 400));
|
||||
s.insert(Status::Signing, (0x111111, 100));
|
||||
s
|
||||
let mut s = BTreeMap::new();
|
||||
s.insert(Status::Starting, (0x000001, 100));
|
||||
s.insert(Status::MountingSDCard, (0x000102, 100));
|
||||
s.insert(Status::SyncingTime, (0x000122, 100));
|
||||
s.insert(Status::WifiAccessPoint, (0x000100, 100));
|
||||
s.insert(Status::Configuring, (0x010000, 20));
|
||||
s.insert(Status::ConnectingToWifi, (0x010100, 350));
|
||||
s.insert(Status::ConnectingToMqtt, (0x010001, 100));
|
||||
s.insert(Status::Connected, (0x000101, 400));
|
||||
s.insert(Status::Signing, (0x111111, 100));
|
||||
s
|
||||
}
|
||||
|
||||
pub fn led_control_loop(
|
||||
gpio8: gpio::Gpio8<gpio::Unknown>,
|
||||
channel0: rmt::CHANNEL0,
|
||||
rx: mpsc::Receiver<Status>
|
||||
gpio8: gpio::Gpio8<gpio::Unknown>,
|
||||
channel0: rmt::CHANNEL0,
|
||||
rx: mpsc::Receiver<Status>,
|
||||
) {
|
||||
let led = gpio8.into_output().unwrap();
|
||||
let config = TransmitConfig::new().clock_divider(1);
|
||||
@@ -68,7 +68,10 @@ impl Led {
|
||||
self.blink_length = blink_length;
|
||||
}
|
||||
|
||||
pub fn blink(&mut self, transmit: Arc<Mutex<Transmit<gpio::Gpio8<gpio::Output>, rmt::CHANNEL0>>>) {
|
||||
pub fn blink(
|
||||
&mut self,
|
||||
transmit: Arc<Mutex<Transmit<gpio::Gpio8<gpio::Output>, rmt::CHANNEL0>>>,
|
||||
) {
|
||||
// Prepare signal
|
||||
let mut tx = transmit.lock().unwrap();
|
||||
let ticks_hz = tx.counter_clock().unwrap();
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
pub mod led;
|
||||
pub mod sd;
|
||||
pub mod sd;
|
||||
|
||||
@@ -12,90 +12,90 @@ const URL: &str = "http://192.168.71.1";
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct EcdhBody {
|
||||
pub pubkey: String,
|
||||
pub pubkey: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct ConfigBody {
|
||||
pub seed: String,
|
||||
pub ssid: String,
|
||||
pub pass: String,
|
||||
pub broker: String,
|
||||
pub pubkey: String, // for ecdh
|
||||
pub network: String,
|
||||
pub seed: String,
|
||||
pub ssid: String,
|
||||
pub pass: String,
|
||||
pub broker: String,
|
||||
pub pubkey: String, // for ecdh
|
||||
pub network: String,
|
||||
}
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct ConfigResponse {
|
||||
pub success: bool,
|
||||
pub success: bool,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
dotenv().ok();
|
||||
dotenv().ok();
|
||||
|
||||
let url: String = env::var("URL").unwrap_or(URL.to_string());
|
||||
let url: String = env::var("URL").unwrap_or(URL.to_string());
|
||||
|
||||
let ssid: String = env::var("SSID").expect("no ssid");
|
||||
let pass: String = env::var("PASS").expect("no pass");
|
||||
let broker: String = env::var("BROKER").expect("no broker");
|
||||
let seed_string: String = env::var("SEED").expect("no seed");
|
||||
let seed: [u8; MSG_LEN] = hex::decode(seed_string)?[..MSG_LEN].try_into()?;
|
||||
let network: String = env::var("NETWORK").unwrap_or("regtest".to_string());
|
||||
if !(network == "bitcoin"
|
||||
|| network == "mainnet"
|
||||
|| network == "testnet"
|
||||
|| network == "signet"
|
||||
|| network == "regtest")
|
||||
{
|
||||
panic!("invalid network string");
|
||||
}
|
||||
println!("network {:?}", network);
|
||||
let ssid: String = env::var("SSID").expect("no ssid");
|
||||
let pass: String = env::var("PASS").expect("no pass");
|
||||
let broker: String = env::var("BROKER").expect("no broker");
|
||||
let seed_string: String = env::var("SEED").expect("no seed");
|
||||
let seed: [u8; MSG_LEN] = hex::decode(seed_string)?[..MSG_LEN].try_into()?;
|
||||
let network: String = env::var("NETWORK").unwrap_or("regtest".to_string());
|
||||
if !(network == "bitcoin"
|
||||
|| network == "mainnet"
|
||||
|| network == "testnet"
|
||||
|| network == "signet"
|
||||
|| network == "regtest")
|
||||
{
|
||||
panic!("invalid network string");
|
||||
}
|
||||
println!("network {:?}", network);
|
||||
|
||||
let s = Secp256k1::new();
|
||||
let (sk1, pk1) = s.generate_keypair(&mut thread_rng());
|
||||
let s = Secp256k1::new();
|
||||
let (sk1, pk1) = s.generate_keypair(&mut thread_rng());
|
||||
|
||||
let client = reqwest::Client::builder()
|
||||
.timeout(Duration::from_secs(10))
|
||||
.build()
|
||||
.expect("couldnt build reqwest client");
|
||||
let client = reqwest::Client::builder()
|
||||
.timeout(Duration::from_secs(10))
|
||||
.build()
|
||||
.expect("couldnt build reqwest client");
|
||||
|
||||
let res = client
|
||||
.get(format!("{}/{}", url, "ecdh"))
|
||||
.header("Content-Type", "application/json")
|
||||
.send()
|
||||
.await?;
|
||||
let their_ecdh: EcdhBody = res.json().await?;
|
||||
let their_pk = hex::decode(their_ecdh.pubkey)?;
|
||||
let res = client
|
||||
.get(format!("{}/{}", url, "ecdh"))
|
||||
.header("Content-Type", "application/json")
|
||||
.send()
|
||||
.await?;
|
||||
let their_ecdh: EcdhBody = res.json().await?;
|
||||
let their_pk = hex::decode(their_ecdh.pubkey)?;
|
||||
|
||||
let their_pk_bytes: [u8; PUBLIC_KEY_LEN] = their_pk[..PUBLIC_KEY_LEN].try_into()?;
|
||||
let shared_secret = derive_shared_secret_from_slice(their_pk_bytes, sk1.secret_bytes())?;
|
||||
let their_pk_bytes: [u8; PUBLIC_KEY_LEN] = their_pk[..PUBLIC_KEY_LEN].try_into()?;
|
||||
let shared_secret = derive_shared_secret_from_slice(their_pk_bytes, sk1.secret_bytes())?;
|
||||
|
||||
let mut nonce_end = [0; NONCE_LEN];
|
||||
OsRng.fill_bytes(&mut nonce_end);
|
||||
let cipher = encrypt(seed, shared_secret, nonce_end)?;
|
||||
let mut nonce_end = [0; NONCE_LEN];
|
||||
OsRng.fill_bytes(&mut nonce_end);
|
||||
let cipher = encrypt(seed, shared_secret, nonce_end)?;
|
||||
|
||||
let cipher_seed = hex::encode(cipher);
|
||||
let config = ConfigBody {
|
||||
seed: cipher_seed,
|
||||
ssid,
|
||||
pass,
|
||||
broker,
|
||||
network,
|
||||
pubkey: hex::encode(pk1.serialize()),
|
||||
};
|
||||
let cipher_seed = hex::encode(cipher);
|
||||
let config = ConfigBody {
|
||||
seed: cipher_seed,
|
||||
ssid,
|
||||
pass,
|
||||
broker,
|
||||
network,
|
||||
pubkey: hex::encode(pk1.serialize()),
|
||||
};
|
||||
|
||||
let conf_string = serde_json::to_string(&config)?;
|
||||
let conf_encoded = urlencoding::encode(&conf_string).to_owned();
|
||||
let conf_string = serde_json::to_string(&config)?;
|
||||
let conf_encoded = urlencoding::encode(&conf_string).to_owned();
|
||||
|
||||
let res2 = client
|
||||
.post(format!("{}/{}={}", url, "config?config", conf_encoded))
|
||||
.send()
|
||||
.await?;
|
||||
let conf_res: ConfigResponse = res2.json().await?;
|
||||
let res2 = client
|
||||
.post(format!("{}/{}={}", url, "config?config", conf_encoded))
|
||||
.send()
|
||||
.await?;
|
||||
let conf_res: ConfigResponse = res2.json().await?;
|
||||
|
||||
if conf_res.success {
|
||||
println!("SUCCESS!")
|
||||
}
|
||||
if conf_res.success {
|
||||
println!("SUCCESS!")
|
||||
}
|
||||
|
||||
Ok(())
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user