Added tppBind
This commit is contained in:
parent
7313c4af99
commit
f25815aa1b
4 changed files with 31 additions and 12 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
|
@ -4317,7 +4317,7 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ttp-core"
|
name = "ttp-core"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.methanium.net/Tensamin/TTP.git#929cb9d3a6aebebe6365973f13062ac2a8e03af6"
|
source = "git+https://git.methanium.net/Tensamin/TTP.git#7e5d1953df8592a1feba0f390d205d0ef61a3119"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
|
|
@ -4330,7 +4330,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ttp-native"
|
name = "ttp-native"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.methanium.net/Tensamin/TTP.git#929cb9d3a6aebebe6365973f13062ac2a8e03af6"
|
source = "git+https://git.methanium.net/Tensamin/TTP.git#7e5d1953df8592a1feba0f390d205d0ef61a3119"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quinn",
|
"quinn",
|
||||||
"rustls",
|
"rustls",
|
||||||
|
|
|
||||||
10
flake.lock
generated
10
flake.lock
generated
|
|
@ -59,15 +59,15 @@
|
||||||
"ttp": {
|
"ttp": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1778329030,
|
"lastModified": 1778948017,
|
||||||
"narHash": "sha256-qEEPlOuGVco1g6lI/kfEvIZkJmBbjehuchGWPTywR10=",
|
"narHash": "sha256-hqBYSZnPq7f/F2Z6nJK+6a8ITk6WRCcVBcNT0CR6SnM=",
|
||||||
"rev": "929cb9d3a6aebebe6365973f13062ac2a8e03af6",
|
"rev": "7e5d1953df8592a1feba0f390d205d0ef61a3119",
|
||||||
"revCount": 115,
|
"revCount": 117,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.methanium.net/Tensamin/TTP.git"
|
"url": "https://git.methanium.net/Tensamin/TTP.git"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"rev": "929cb9d3a6aebebe6365973f13062ac2a8e03af6",
|
"rev": "7e5d1953df8592a1feba0f390d205d0ef61a3119",
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.methanium.net/Tensamin/TTP.git"
|
"url": "https://git.methanium.net/Tensamin/TTP.git"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
18
flake.nix
18
flake.nix
|
|
@ -5,7 +5,7 @@
|
||||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
||||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
ttp = {
|
ttp = {
|
||||||
url = "git+https://git.methanium.net/Tensamin/TTP.git?rev=929cb9d3a6aebebe6365973f13062ac2a8e03af6";
|
url = "git+https://git.methanium.net/Tensamin/TTP.git?rev=7e5d1953df8592a1feba0f390d205d0ef61a3119";
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -98,6 +98,18 @@
|
||||||
description = "Whether to open the firewall for ports used by Iota.";
|
description = "Whether to open the firewall for ports used by Iota.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ttpBind = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "0.0.0.0";
|
||||||
|
description = "IP address to bind the TTP/QUIC server to.";
|
||||||
|
};
|
||||||
|
|
||||||
|
bindAddress = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "0.0.0.0";
|
||||||
|
description = "IP address to bind the HTTP server to.";
|
||||||
|
};
|
||||||
|
|
||||||
package = lib.mkOption {
|
package = lib.mkOption {
|
||||||
type = lib.types.package;
|
type = lib.types.package;
|
||||||
default = defaultPackage;
|
default = defaultPackage;
|
||||||
|
|
@ -190,6 +202,10 @@
|
||||||
RestrictSUIDSGID = true;
|
RestrictSUIDSGID = true;
|
||||||
LockPersonality = true;
|
LockPersonality = true;
|
||||||
MemoryDenyWriteExecute = true;
|
MemoryDenyWriteExecute = true;
|
||||||
|
Environment = [
|
||||||
|
"TTP_BIND=${cfg.ttpBind}"
|
||||||
|
"BIND_ADDRESS=${cfg.bindAddress}"
|
||||||
|
];
|
||||||
} // lib.optionalAttrs (cfg.environmentFiles != [ ]) {
|
} // lib.optionalAttrs (cfg.environmentFiles != [ ]) {
|
||||||
EnvironmentFile = cfg.environmentFiles;
|
EnvironmentFile = cfg.environmentFiles;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,13 @@ use tokio::sync::oneshot;
|
||||||
pub async fn start(port: u16) -> bool {
|
pub async fn start(port: u16) -> bool {
|
||||||
let (tx, rx) = oneshot::channel::<ServerHandle>();
|
let (tx, rx) = oneshot::channel::<ServerHandle>();
|
||||||
|
|
||||||
|
let bind_addr = std::env::var("BIND_ADDRESS").unwrap_or_else(|_| "0.0.0.0".to_string());
|
||||||
|
let bind_ip: std::net::IpAddr = bind_addr.parse().expect("Invalid BIND_ADDRESS");
|
||||||
|
|
||||||
let _ = tokio::spawn(async move {
|
let _ = tokio::spawn(async move {
|
||||||
let server = match load_tls_config() {
|
let server = match load_tls_config() {
|
||||||
Ok(Some(tls_config)) => {
|
Ok(Some(tls_config)) => {
|
||||||
log!("HTTPS (HTTP/2) Server running on 0.0.0.0:{}", port);
|
log!("HTTPS (HTTP/2) Server running on {}:{}", bind_addr, port);
|
||||||
let _config = (*tls_config).clone();
|
let _config = (*tls_config).clone();
|
||||||
HttpServer::new(move || {
|
HttpServer::new(move || {
|
||||||
App::new()
|
App::new()
|
||||||
|
|
@ -30,19 +33,19 @@ pub async fn start(port: u16) -> bool {
|
||||||
.configure(api_config)
|
.configure(api_config)
|
||||||
.default_service(web::to(web_path_parser::handle))
|
.default_service(web::to(web_path_parser::handle))
|
||||||
})
|
})
|
||||||
.bind(("0.0.0.0", port))
|
.bind((bind_ip, port))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.run()
|
.run()
|
||||||
}
|
}
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
log!("HTTP Server running on 0.0.0.0:{}", port);
|
log!("HTTP Server running on {}:{}", bind_addr, port);
|
||||||
HttpServer::new(move || {
|
HttpServer::new(move || {
|
||||||
App::new()
|
App::new()
|
||||||
.app_data(web::Data::new(false))
|
.app_data(web::Data::new(false))
|
||||||
.configure(api_config)
|
.configure(api_config)
|
||||||
.default_service(web::to(web_path_parser::handle))
|
.default_service(web::to(web_path_parser::handle))
|
||||||
})
|
})
|
||||||
.bind(("0.0.0.0", port))
|
.bind((bind_ip, port))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.run()
|
.run()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue