ipv6
This commit is contained in:
parent
9261d542d7
commit
a34aa87b02
1 changed files with 19 additions and 7 deletions
26
src/main.rs
26
src/main.rs
|
@ -3,7 +3,12 @@ pub mod message;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate derivative;
|
extern crate derivative;
|
||||||
|
|
||||||
use std::{io::Cursor, mem, net::SocketAddr, sync::Arc};
|
use std::{
|
||||||
|
io::Cursor,
|
||||||
|
mem,
|
||||||
|
net::{Ipv4Addr, Ipv6Addr, SocketAddr},
|
||||||
|
sync::Arc,
|
||||||
|
};
|
||||||
|
|
||||||
use automerge::{
|
use automerge::{
|
||||||
sync::{State as SyncState, SyncDoc},
|
sync::{State as SyncState, SyncDoc},
|
||||||
|
@ -16,7 +21,7 @@ use axum::{
|
||||||
},
|
},
|
||||||
response::Response,
|
response::Response,
|
||||||
routing::get,
|
routing::get,
|
||||||
Router,
|
Router, Server,
|
||||||
};
|
};
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
@ -26,6 +31,7 @@ use frontend::frontend;
|
||||||
use futures::{stream, FutureExt, SinkExt, StreamExt};
|
use futures::{stream, FutureExt, SinkExt, StreamExt};
|
||||||
use message::Message;
|
use message::Message;
|
||||||
use mzlib::axum_error::Result;
|
use mzlib::axum_error::Result;
|
||||||
|
use tokio::join;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
|
@ -76,11 +82,17 @@ async fn main() -> Result<()> {
|
||||||
.fallback(frontend)
|
.fallback(frontend)
|
||||||
.with_state(state);
|
.with_state(state);
|
||||||
|
|
||||||
let bind_addr: SocketAddr = format!("0.0.0.0:{}", opts.port).parse()?;
|
let service = app.into_make_service();
|
||||||
println!("Listening on {}...", bind_addr);
|
|
||||||
axum::Server::bind(&bind_addr)
|
let addr4 = SocketAddr::from((Ipv4Addr::UNSPECIFIED, opts.port));
|
||||||
.serve(app.into_make_service())
|
let addr6 = SocketAddr::from((Ipv6Addr::UNSPECIFIED, opts.port));
|
||||||
.await?;
|
|
||||||
|
let server4 = Server::bind(&addr4).serve(service.clone());
|
||||||
|
let server6 = Server::bind(&addr6).serve(service);
|
||||||
|
|
||||||
|
let (result4, result6) = join!(server4, server6);
|
||||||
|
result4?;
|
||||||
|
result6?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue