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]
|
||||
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::{
|
||||
sync::{State as SyncState, SyncDoc},
|
||||
|
@ -16,7 +21,7 @@ use axum::{
|
|||
},
|
||||
response::Response,
|
||||
routing::get,
|
||||
Router,
|
||||
Router, Server,
|
||||
};
|
||||
use chrono::Utc;
|
||||
use clap::Parser;
|
||||
|
@ -26,6 +31,7 @@ use frontend::frontend;
|
|||
use futures::{stream, FutureExt, SinkExt, StreamExt};
|
||||
use message::Message;
|
||||
use mzlib::axum_error::Result;
|
||||
use tokio::join;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
|
@ -76,11 +82,17 @@ async fn main() -> Result<()> {
|
|||
.fallback(frontend)
|
||||
.with_state(state);
|
||||
|
||||
let bind_addr: SocketAddr = format!("0.0.0.0:{}", opts.port).parse()?;
|
||||
println!("Listening on {}...", bind_addr);
|
||||
axum::Server::bind(&bind_addr)
|
||||
.serve(app.into_make_service())
|
||||
.await?;
|
||||
let service = app.into_make_service();
|
||||
|
||||
let addr4 = SocketAddr::from((Ipv4Addr::UNSPECIFIED, opts.port));
|
||||
let addr6 = SocketAddr::from((Ipv6Addr::UNSPECIFIED, opts.port));
|
||||
|
||||
let server4 = Server::bind(&addr4).serve(service.clone());
|
||||
let server6 = Server::bind(&addr6).serve(service);
|
||||
|
||||
let (result4, result6) = join!(server4, server6);
|
||||
result4?;
|
||||
result6?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue