mirror of
https://github.com/2e3s/awatcher.git
synced 2025-06-04 02:20:15 +00:00
Make bundle server host configurable
This commit is contained in:
parent
ff16bd6221
commit
03e94e2f26
@ -19,10 +19,10 @@ pub async fn run(
|
||||
);
|
||||
|
||||
if !no_tray {
|
||||
let tray = Tray::new(host, port, config_file, shutdown_sender, manager);
|
||||
let tray = Tray::new(host.clone(), port, config_file, shutdown_sender, manager);
|
||||
let service = ksni::TrayService::new(tray);
|
||||
service.spawn();
|
||||
}
|
||||
|
||||
server::run(port).await;
|
||||
server::run(host.clone(), port).await;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
use std::collections::HashMap;
|
||||
use std::net::Ipv4Addr;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use std::str::FromStr;
|
||||
use tokio::sync::mpsc::UnboundedSender;
|
||||
|
||||
use super::modules::Manager;
|
||||
@ -22,6 +23,17 @@ impl Tray {
|
||||
shutdown_sender: UnboundedSender<()>,
|
||||
watchers_manager: Manager,
|
||||
) -> Self {
|
||||
let is_zero_first_octet = match Ipv4Addr::from_str(&server_host) {
|
||||
Ok(ip) => ip.octets()[0] == 0,
|
||||
Err(_) => false,
|
||||
};
|
||||
|
||||
let server_host = if is_zero_first_octet {
|
||||
"localhost".to_string()
|
||||
} else {
|
||||
server_host
|
||||
};
|
||||
|
||||
let checks = watchers_manager
|
||||
.path_watchers
|
||||
.iter()
|
||||
|
@ -1,8 +1,9 @@
|
||||
use anyhow::anyhow;
|
||||
use aw_server::endpoints::{build_rocket, AssetResolver, ServerState};
|
||||
use std::net::ToSocketAddrs;
|
||||
use std::sync::Mutex;
|
||||
|
||||
pub async fn run(port: u16) {
|
||||
pub async fn run(host: String, port: u16) {
|
||||
let db_path = aw_server::dirs::db_path(false)
|
||||
.map_err(|()| anyhow!("DB path is not found"))
|
||||
.unwrap()
|
||||
@ -11,8 +12,13 @@ pub async fn run(port: u16) {
|
||||
.to_string();
|
||||
let device_id = aw_server::device_id::get_device_id();
|
||||
let mut config = aw_server::config::create_config(false);
|
||||
config.address = "127.0.0.1".to_string();
|
||||
config.port = port;
|
||||
|
||||
let mut addrs_iter = (host + ":" + &port.to_string()).to_socket_addrs().unwrap();
|
||||
let address = addrs_iter.next().unwrap();
|
||||
|
||||
info!("Starting server on {}", address);
|
||||
config.address = address.ip().to_string();
|
||||
config.port = address.port();
|
||||
|
||||
let legacy_import = false;
|
||||
let server_state = ServerState {
|
||||
|
Loading…
x
Reference in New Issue
Block a user