use log::{error, info};
use tokio::sync::mpsc;
use tokio_stream::wrappers::ReceiverStream;
-use http::request::Parts;
-use http::Response;
-use hyper::{Body, StatusCode};
-use hyper::header;
-use proxmox::api::RpcEnvironmentType;
+use proxmox_router::RpcEnvironmentType;
use pbs_client::DEFAULT_VSOCK_PORT;
use proxmox_rest_server::{ApiConfig, RestServer};
/// This is expected to be run by 'proxmox-file-restore' within a mini-VM
fn main() -> Result<(), Error> {
+ pbs_tools::setup_libc_malloc_opts();
+
if !Path::new(VM_DETECT_FILE).exists() {
bail!(
"This binary is not supposed to be run manually, use 'proxmox-file-restore' instead."
// don't have a real syslog (and no persistance), so use env_logger to print to a log file (via
// stdout to a serial terminal attached by QEMU)
- env_logger::from_env(env_logger::Env::default().default_filter_or("info"))
+ env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info"))
.write_style(env_logger::WriteStyle::Never)
.format_timestamp_millis()
.init();
info!("disk scan complete, starting main runtime...");
- pbs_runtime::main(run())
+ proxmox_async::runtime::main(run())
}
/// ensure we have our /run dirs, system users and stuff like that setup
Ok(())
}
-fn get_index(
- _auth_id: Option<String>,
- _language: Option<String>,
- _api: &ApiConfig,
- _parts: Parts,
-) -> Response<Body> {
-
- let index = "<center><h1>Proxmox Backup Restore Daemon/h1></center>";
-
- Response::builder()
- .status(StatusCode::OK)
- .header(header::CONTENT_TYPE, "text/html")
- .body(index.into())
- .unwrap()
-}
async fn run() -> Result<(), Error> {
watchdog_init();
- let auth_config = Arc::new(
- auth::ticket_auth().map_err(|err| format_err!("reading ticket file failed: {}", err))?,
- );
- let config = ApiConfig::new("", &ROUTER, RpcEnvironmentType::PUBLIC, auth_config, get_index)?;
+ let adaptor = StaticAuthAdapter::new()
+ .map_err(|err| format_err!("reading ticket file failed: {}", err))?;
+
+ let config = ApiConfig::new("", &ROUTER, RpcEnvironmentType::PUBLIC, adaptor)?;
let rest_server = RestServer::new(config);
let vsock_fd = get_vsock_fd()?;