mirror of
https://github.com/yuzu-emu/liftinstall.git
synced 2024-11-25 17:05:39 +01:00
Bind to both IPv4 and 6
This commit is contained in:
parent
7f86ac634a
commit
55239ec4aa
33
src/main.rs
33
src/main.rs
@ -47,6 +47,11 @@ use nfd::Response;
|
||||
|
||||
use rest::WebServer;
|
||||
|
||||
use std::net::ToSocketAddrs;
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::sync::RwLock;
|
||||
|
||||
// TODO: Fetch this over a HTTP request?
|
||||
static RAW_CONFIG: &'static str = include_str!("../config.toml");
|
||||
|
||||
@ -73,11 +78,33 @@ fn main() {
|
||||
InstallerFramework::new(config)
|
||||
};
|
||||
|
||||
let server = WebServer::new(framework).unwrap();
|
||||
let addresses = "localhost:0"
|
||||
.to_socket_addrs()
|
||||
.expect("No localhost address found");
|
||||
|
||||
let mut servers = Vec::new();
|
||||
let mut http_address = None;
|
||||
|
||||
let framework = Arc::new(RwLock::new(framework));
|
||||
|
||||
// Startup HTTP server for handling the web view
|
||||
let http_address = format!("http://{}", server.get_addr());
|
||||
println!("Server: {:?}", http_address);
|
||||
for address in addresses {
|
||||
let server = WebServer::with_addr(framework.clone(), address).unwrap();
|
||||
|
||||
let addr = server.get_addr();
|
||||
println!("Server: {:?}", addr);
|
||||
|
||||
http_address = Some(addr);
|
||||
|
||||
servers.push(server);
|
||||
}
|
||||
|
||||
let http_address = match http_address {
|
||||
Some(v) => v,
|
||||
None => panic!("No HTTP address found"),
|
||||
};
|
||||
|
||||
let http_address = format!("http://localhost:{}", http_address.port());
|
||||
|
||||
// Init the web view
|
||||
let size = (1024, 500);
|
||||
|
14
src/rest.rs
14
src/rest.rs
@ -47,25 +47,15 @@ impl WebServer {
|
||||
self.addr.clone()
|
||||
}
|
||||
|
||||
/// Creates a new web server, bound to a random port on localhost.
|
||||
pub fn new(framework: InstallerFramework) -> Result<Self, HyperError> {
|
||||
WebServer::with_addr(
|
||||
framework,
|
||||
SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 0),
|
||||
)
|
||||
}
|
||||
|
||||
/// Creates a new web server with the specified address.
|
||||
pub fn with_addr(framework: InstallerFramework, addr: SocketAddr) -> Result<Self, HyperError> {
|
||||
pub fn with_addr(framework: Arc<RwLock<InstallerFramework>>, addr: SocketAddr) -> Result<Self, HyperError> {
|
||||
let (sender, receiver) = channel();
|
||||
|
||||
let handle = thread::spawn(move || {
|
||||
let shared_framework = Arc::new(RwLock::new(framework));
|
||||
|
||||
let server = Http::new()
|
||||
.bind(&addr, move || {
|
||||
Ok(WebService {
|
||||
framework: shared_framework.clone(),
|
||||
framework: framework.clone(),
|
||||
})
|
||||
})
|
||||
.unwrap();
|
||||
|
@ -27,7 +27,7 @@ pub enum TaskParamType {
|
||||
/// Downloaded contents of a file
|
||||
FileContents(Version, Vec<u8>),
|
||||
/// Tells the runtime to break parsing other dependencies
|
||||
Break
|
||||
Break,
|
||||
}
|
||||
|
||||
/// A Task is a small, async task conforming to a fixed set of inputs/outputs.
|
||||
@ -103,7 +103,7 @@ impl DependencyTree {
|
||||
// Check to see if we skip matching other dependencies
|
||||
let do_break = match &result {
|
||||
&TaskParamType::Break => true,
|
||||
_ => false
|
||||
_ => false,
|
||||
};
|
||||
|
||||
inputs.push(result);
|
||||
|
@ -225,9 +225,10 @@
|
||||
app.modify_install = false;
|
||||
},
|
||||
"uninstall": function() {
|
||||
app.is_installing = true;
|
||||
app.confirm_uninstall = false;
|
||||
this.select_packages = false;
|
||||
this.is_installing = true;
|
||||
app.modify_install = false;
|
||||
app.select_packages = false;
|
||||
|
||||
stream_ajax("/api/uninstall", function(line) {
|
||||
if (line.hasOwnProperty("Status")) {
|
||||
|
Loading…
Reference in New Issue
Block a user