mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-06-18 15:15:22 +00:00
version_info & about_info
This commit is contained in:
parent
88423039c6
commit
2ead13a3f4
3 changed files with 19 additions and 8 deletions
17
src/args.rs
17
src/args.rs
|
@ -8,8 +8,19 @@ use std::ffi::OsString;
|
|||
use std::net::{IpAddr, SocketAddr, ToSocketAddrs};
|
||||
use std::str::FromStr;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! version_info {
|
||||
() => {
|
||||
concat!(env!("CARGO_PKG_VERSION"), " (", env!("GIT_HASH"), " ", env!("BUILD_TIME"), ")")
|
||||
};
|
||||
}
|
||||
|
||||
fn about_info() -> &'static str {
|
||||
concat!("Tunnel interface to proxy.\nVersion: ", version_info!())
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, clap::Parser)]
|
||||
#[command(author, version = version_info(), about = "Tunnel interface to proxy.", long_about = None)]
|
||||
#[command(author, version = version_info!(), about = about_info(), 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,10 +138,6 @@ 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" {
|
||||
|
|
|
@ -28,8 +28,12 @@ impl Client {
|
|||
}
|
||||
}
|
||||
|
||||
fn about_info() -> &'static str {
|
||||
concat!("UDP Gateway Server for tun2proxy\nVersion: ", tun2proxy::version_info!())
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, clap::Parser)]
|
||||
#[command(author, version, about = "UDP Gateway Server for tun2proxy", long_about = None)]
|
||||
#[command(author, version = tun2proxy::version_info!(), about = about_info(), long_about = None)]
|
||||
pub struct UdpGwArgs {
|
||||
/// UDP gateway listen address
|
||||
#[arg(short, long, value_name = "IP:PORT", default_value = "127.0.0.1:7300")]
|
||||
|
@ -193,7 +197,7 @@ async fn write_to_client(addr: SocketAddr, mut writer: WriteHalf<'_>, mut rx: Re
|
|||
}
|
||||
|
||||
async fn main_async(args: UdpGwArgs) -> Result<(), BoxError> {
|
||||
log::info!("{} {} starting...", module_path!(), env!("CARGO_PKG_VERSION"));
|
||||
log::info!("{} {} starting...", module_path!(), tun2proxy::version_info!());
|
||||
log::info!("UDP Gateway Server running at {}", args.listen_addr);
|
||||
|
||||
let shutdown_token = tokio_util::sync::CancellationToken::new();
|
||||
|
|
|
@ -157,7 +157,7 @@ pub async fn run<D>(device: D, mtu: u16, args: Args, shutdown_token: Cancellatio
|
|||
where
|
||||
D: AsyncRead + AsyncWrite + Unpin + Send + 'static,
|
||||
{
|
||||
log::info!("{} {} starting...", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));
|
||||
log::info!("{} {} starting...", env!("CARGO_PKG_NAME"), version_info!());
|
||||
log::info!("Proxy {} server: {}", args.proxy.proxy_type, args.proxy.addr);
|
||||
|
||||
let server_addr = args.proxy.addr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue