diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1526a44..a49a9dd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -45,6 +45,7 @@ jobs: - name: Prepare shell: bash run: | + cargo install cbindgen mkdir release rustup target add ${{ matrix.target }} if [[ "${{ matrix.host_os }}" == "ubuntu-latest" ]]; then diff --git a/Cargo.toml b/Cargo.toml index f91b28e..4cd0dc3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "overtls" -version = "0.2.22" +version = "0.2.23" edition = "2021" license = "MIT" description = "A simple proxy tunnel, minimalist tool for bypassing the GFW." diff --git a/src/config.rs b/src/config.rs index 3042cf3..0ea4ee6 100644 --- a/src/config.rs +++ b/src/config.rs @@ -324,7 +324,7 @@ impl Config { (false, _) => server_host, }; if client.server_host.is_empty() { - client.server_host = server_host.clone(); + client.server_host.clone_from(&server_host); } if client.server_domain.is_none() || client.server_domain.as_ref().unwrap_or(&"".to_string()).is_empty() { client.server_domain = Some(server_host.clone()); diff --git a/src/server.rs b/src/server.rs index 4da0a17..915a9d4 100644 --- a/src/server.rs +++ b/src/server.rs @@ -40,25 +40,20 @@ pub async fn run_server(config: &Config, exiting_flag: crate::CancellationToken) let p = server.listen_port; let addr: SocketAddr = (h, p).to_socket_addrs()?.next().ok_or("Invalid server listen address")?; - let certs = server.certfile.as_ref().and_then(|cert| { - if !config.disable_tls() { - server_load_certs(cert).ok() - } else { - None + let certs = server.certfile.as_ref().filter(|_| !config.disable_tls()).and_then(|cert| { + let certs = server_load_certs(cert); + if let Err(err) = &certs { + log::warn!("failed to load certificate file: {}", err); } + certs.ok() }); - let keys = server.keyfile.as_ref().and_then(|key| { - if !config.disable_tls() { - let keys = server_load_keys(key).ok(); - if keys.as_ref().map(|keys| keys.len()).unwrap_or(0) > 0 { - keys - } else { - None - } - } else { - None + let keys = server.keyfile.as_ref().filter(|_| !config.disable_tls()).and_then(|key| { + let keys = server_load_keys(key); + if let Err(err) = &keys { + log::warn!("failed to load key file: {}", err); } + keys.ok().filter(|keys| !keys.is_empty()) }); let svr_cfg = if let (Some(certs), Some(mut keys)) = (certs, keys) {