summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
e6431ad)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
const METADATA_MAX_LEN: usize = MAX_OVERHEAD;
const METADATA_MAX_LEN: usize = MAX_OVERHEAD;
-type AllClients = HashMap<ClientName, ClientHandles>;
+#[derive(Debug)]
+struct Global {
+ config: config::InstanceConfigGlobal,
+ all_clients: HashMap<ClientName, ClientHandles>,
+}
struct ClientHandles {
ic: Arc<InstanceConfig>,
web: tokio::sync::mpsc::Sender<WebRequest>,
struct ClientHandles {
ic: Arc<InstanceConfig>,
web: tokio::sync::mpsc::Sender<WebRequest>,
async fn handle(
conn: Arc<String>,
async fn handle(
conn: Arc<String>,
- all_clients: Arc<AllClients>,
req: hyper::Request<hyper::Body>
) -> Result<hyper::Response<hyper::Body>, hyper::http::Error> {
if req.method() == Method::GET {
req: hyper::Request<hyper::Body>
) -> Result<hyper::Response<hyper::Body>, hyper::http::Error> {
if req.method() == Method::GET {
let hmac_got = &hmac_got[0..hmac_got_l];
let client_name = client;
let hmac_got = &hmac_got[0..hmac_got_l];
let client_name = client;
- let client = all_clients.get(&client_name);
+ let client = global.all_clients.get(&client_name);
// We attempt to hide whether the client exists we don't try to
// hide the hash lookup computationgs, but we do try to hide the
// We attempt to hide whether the client exists we don't try to
// hide the hash lookup computationgs, but we do try to hide the
"hippotatd", LinkEnd::Server,
&opts.config, &opts.log, |ics|
{
"hippotatd", LinkEnd::Server,
&opts.config, &opts.log, |ics|
{
- let global = config::InstanceConfigGlobal::from(&ics);
- let ipif = Ipif::start(&global.ipif, None)?;
+ let global_config = config::InstanceConfigGlobal::from(&ics);
+ let ipif = Ipif::start(&global_config.ipif, None)?;
- let all_clients: AllClients = ics.into_iter().map(|ic| {
+ let all_clients = ics.into_iter().map(|ic| {
let ic = Arc::new(ic);
let (web_send, web_recv) = mpsc::channel(
let ic = Arc::new(ic);
let (web_send, web_recv) = mpsc::channel(
web: web_send,
})
}).collect();
web: web_send,
})
}).collect();
- let all_clients = Arc::new(all_clients);
+ let global = Arc::new(Global {
+ config: global_config,
+ all_clients,
+ });
- for addr in &global.addrs {
- let all_clients_ = all_clients.clone();
+ for addr in &global.config.addrs {
+ let global_ = global.clone();
let make_service = hyper::service::make_service_fn(
move |conn: &hyper::server::conn::AddrStream| {
let make_service = hyper::service::make_service_fn(
move |conn: &hyper::server::conn::AddrStream| {
- let all_clients_ = all_clients_.clone();
+ let global_ = global_.clone();
let conn = Arc::new(format!("[{}]", conn.remote_addr()));
async { Ok::<_, Void>( hyper::service::service_fn(move |req| {
let conn = Arc::new(format!("[{}]", conn.remote_addr()));
async { Ok::<_, Void>( hyper::service::service_fn(move |req| {
- handle(conn.clone(), all_clients_.clone(), req)
+ handle(conn.clone(), global_.clone(), req)
- let addr = SocketAddr::new(*addr, global.port);
+ let addr = SocketAddr::new(*addr, global.config.port);
let server = hyper::Server::try_bind(&addr)
.context("bind")?
.http1_preserve_header_case(true)
let server = hyper::Server::try_bind(&addr)
.context("bind")?
.http1_preserve_header_case(true)