mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-04-11 17:42:02 +00:00
version_info method
Some checks are pending
Push or PR / build_n_test (macos-latest) (push) Waiting to run
Push or PR / build_n_test (ubuntu-latest) (push) Waiting to run
Push or PR / build_n_test (windows-latest) (push) Waiting to run
Push or PR / build_n_test_android (push) Waiting to run
Push or PR / build_n_test_ios (push) Waiting to run
Push or PR / Check semver (push) Waiting to run
Integration Tests / Proxy Tests (push) Waiting to run
Some checks are pending
Push or PR / build_n_test (macos-latest) (push) Waiting to run
Push or PR / build_n_test (ubuntu-latest) (push) Waiting to run
Push or PR / build_n_test (windows-latest) (push) Waiting to run
Push or PR / build_n_test_android (push) Waiting to run
Push or PR / build_n_test_ios (push) Waiting to run
Push or PR / Check semver (push) Waiting to run
Integration Tests / Proxy Tests (push) Waiting to run
This commit is contained in:
parent
ca7cd25c4e
commit
61bbafcf82
3 changed files with 24 additions and 3 deletions
|
@ -56,6 +56,7 @@ unicase = "2"
|
|||
url = "2"
|
||||
|
||||
[build-dependencies]
|
||||
chrono = "0.4"
|
||||
serde_json = "1"
|
||||
|
||||
[target.'cfg(target_os="linux")'.dependencies]
|
||||
|
@ -77,5 +78,5 @@ nix = { version = "0.29", default-features = false, features = [
|
|||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
windows-service = "0.8"
|
||||
|
||||
[profile.release]
|
||||
strip = "symbols"
|
||||
# [profile.release]
|
||||
# strip = "symbols"
|
||||
|
|
16
build.rs
16
build.rs
|
@ -1,4 +1,13 @@
|
|||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
if let Ok(git_hash) = get_git_hash() {
|
||||
// Set the environment variables
|
||||
println!("cargo:rustc-env=GIT_HASH={}", git_hash.trim());
|
||||
}
|
||||
|
||||
// Get the build time
|
||||
let build_time = chrono::Utc::now().format("%Y-%m-%d %H:%M:%S").to_string();
|
||||
println!("cargo:rustc-env=BUILD_TIME={}", build_time);
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
if let Ok(cargo_target_dir) = get_cargo_target_dir() {
|
||||
let mut f = std::fs::File::create(cargo_target_dir.join("build.log"))?;
|
||||
|
@ -85,3 +94,10 @@ fn get_crate_dir(crate_name: &str) -> Result<std::path::PathBuf, Box<dyn std::er
|
|||
}
|
||||
Ok(crate_dir.ok_or("crate_dir")?)
|
||||
}
|
||||
|
||||
fn get_git_hash() -> std::io::Result<String> {
|
||||
use std::process::Command;
|
||||
let git_hash = Command::new("git").args(["rev-parse", "--short", "HEAD"]).output()?.stdout;
|
||||
let git_hash = String::from_utf8(git_hash).map_err(|e| std::io::Error::new(std::io::ErrorKind::InvalidData, e))?;
|
||||
Ok(git_hash)
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ use std::net::{IpAddr, SocketAddr, ToSocketAddrs};
|
|||
use std::str::FromStr;
|
||||
|
||||
#[derive(Debug, Clone, clap::Parser)]
|
||||
#[command(author, version, about = "Tunnel interface to proxy.", long_about = None)]
|
||||
#[command(author, version = version_info(), about = "Tunnel interface to proxy.", long_about = None)]
|
||||
pub struct Args {
|
||||
/// Proxy URL in the form proto://[username[:password]@]host:port,
|
||||
/// where proto is one of socks4, socks5, http.
|
||||
|
@ -127,6 +127,10 @@ pub struct Args {
|
|||
pub udpgw_keepalive: Option<u64>,
|
||||
}
|
||||
|
||||
fn version_info() -> &'static str {
|
||||
concat!(env!("CARGO_PKG_VERSION"), " (", env!("GIT_HASH"), " ", env!("BUILD_TIME"), ")")
|
||||
}
|
||||
|
||||
fn validate_tun(p: &str) -> Result<String> {
|
||||
#[cfg(target_os = "macos")]
|
||||
if p.len() <= 4 || &p[..4] != "utun" {
|
||||
|
|
Loading…
Add table
Reference in a new issue