Bläddra i källkod

Add --bind parameter to server command.

Kestrel 7 månader sedan
förälder
incheckning
950f1dce00
5 ändrade filer med 7 tillägg och 5 borttagningar
  1. 1 1
      Cargo.lock
  2. 1 1
      Cargo.toml
  3. 3 1
      src/cli.rs
  4. 2 1
      src/server.rs
  5. 0 1
      src/server/session.rs

+ 1 - 1
Cargo.lock

@@ -1400,7 +1400,7 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
 
 [[package]]
 name = "microrm"
-version = "0.4.0-rc.4"
+version = "0.4.0-rc.5"
 dependencies = [
  "clap",
  "itertools",

+ 1 - 1
Cargo.toml

@@ -28,7 +28,7 @@ bincode = "1.3"
 toml = "0.8.2"
 
 # Data storage dependencies
-microrm = { version = "0.4.0-rc.4", path="../microrm/microrm/", features = ["clap"] }
+microrm = { version = "0.4.0-rc.5", path="../microrm/microrm/", features = ["clap"] }
 serde_bytes = { version = "0.11.6" }
 
 # Public API/server dependencies

+ 3 - 1
src/cli.rs

@@ -214,6 +214,8 @@ impl ConfigArgs {
 
 #[derive(Debug, Parser)]
 struct ServerArgs {
+    #[clap(short, long)]
+    bind: Option<String>,
     #[clap(short, long)]
     port: Option<u16>,
 }
@@ -221,7 +223,7 @@ struct ServerArgs {
 impl ServerArgs {
     async fn run(self, args: RunArgs) -> Result<(), UIDCError> {
         let config = config::Config::build_from(&args.db, None);
-        server::run_server(args.db, config, self.port.unwrap_or(2114)).await
+        server::run_server(args.db, config, self.bind.as_deref().unwrap_or("127.0.0.1"), self.port.unwrap_or(2114)).await
     }
 }
 

+ 2 - 1
src/server.rs

@@ -52,6 +52,7 @@ async fn index(req: tide::Request<ServerStateWrapper>) -> tide::Result<tide::Res
 pub async fn run_server(
     db: schema::UIDCDatabase,
     config: config::Config,
+    bind: &str,
     port: u16,
 ) -> Result<(), UIDCError> {
     let core_state = Box::leak(Box::new(ServerState {
@@ -88,7 +89,7 @@ pub async fn run_server(
     oidc::oidc_server(app.at("/:realm/"));
     um::um_server(app.at("/:realm/"));
 
-    app.listen(("127.0.0.1", port))
+    app.listen((bind, port))
         .await
         .map_err(|_| UIDCError::Abort("couldn't listen on port"))?;
 

+ 0 - 1
src/server/session.rs

@@ -319,7 +319,6 @@ async fn v1_login_post(mut req: Request) -> tide::Result<tide::Response> {
                     let user = realm
                         .users
                         .with_id(user_id)
-                        .first()
                         .get()?
                         .ok_or(UIDCError::Abort("session auth refers to nonexistent user"))?;