Skip to content

Commit

Permalink
Merge pull request #38 from lbl8603/1.2.x
Browse files Browse the repository at this point in the history
1.2.x
  • Loading branch information
vnt-dev authored May 11, 2024
2 parents ee359dc + 0e42944 commit 4dca4c4
Show file tree
Hide file tree
Showing 62 changed files with 1,795 additions and 1,268 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ jobs:
run: |
# dependencies are only needed on ubuntu as that's the only place where
# we make cross-compilation
rustup set auto-self-update disable
if [[ $OS =~ ^ubuntu.*$ ]]; then
sudo apt-get update && sudo apt-get install -qq crossbuild-essential-arm64 crossbuild-essential-armhf musl-tools
# curl -s musl.cc | grep mipsel
Expand Down Expand Up @@ -136,6 +138,9 @@ jobs:
# mips平台使用1.71.1版本
rustup install 1.71.1
rustup default 1.71.1
else
rustup install 1.77
rustup default 1.77
fi
if [ -n "$MUSL_URI" ]; then
Expand All @@ -144,8 +149,11 @@ jobs:
tar zxf ./musl_gcc/$MUSL_URI.tgz -C ./musl_gcc/
sudo ln -s $(pwd)/musl_gcc/$MUSL_URI/bin/*gcc /usr/bin/
fi
else
rustup install 1.77
rustup default 1.77
fi
rustup -V
# some additional configuration for cross-compilation on linux
cat >>~/.cargo/config <<EOF
Expand Down
151 changes: 151 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions common/src/args_parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,33 @@ pub fn ips_parse(ips: &Vec<String>) -> Result<Vec<(u32, u32, Ipv4Addr)>, String>
let net = if let Some(net) = split.next() {
net
} else {
return Err("ipv4/mask,ipv4".to_string());
return Err(format!("ipv4/mask,ipv4 {:?}", x));
};
let ip = if let Some(ip) = split.next() {
ip
} else {
return Err("ipv4/mask,ipv4".to_string());
return Err(format!("ipv4/mask,ipv4 {:?}", x));
};
let ip = if let Ok(ip) = ip.parse::<Ipv4Addr>() {
ip
} else {
return Err("not ipv4".to_string());
return Err(format!("not ipv4 {:?}", ip));
};
let mut split = net.split("/");
let dest = if let Some(dest) = split.next() {
dest
} else {
return Err("no ipv4/mask".to_string());
return Err(format!("no ipv4/mask {:?}", net));
};
let mask = if let Some(mask) = split.next() {
mask
} else {
return Err("no netmask".to_string());
return Err(format!("no netmask {:?}", net));
};
let dest = if let Ok(dest) = dest.parse::<Ipv4Addr>() {
dest
} else {
return Err("not ipv4".to_string());
return Err(format!("not ipv4 {:?}", dest));
};
let mask = to_ip(mask)?;
in_ips_c.push((u32::from_be_bytes(dest.octets()), mask, ip));
Expand All @@ -48,17 +48,17 @@ pub fn out_ips_parse(ips: &Vec<String>) -> Result<Vec<(u32, u32)>, String> {
let dest = if let Some(dest) = split.next() {
dest
} else {
return Err("no ipv4/mask".to_string());
return Err(format!("no ipv4/mask {:?}", x));
};
let mask = if let Some(mask) = split.next() {
mask
} else {
return Err("no netmask".to_string());
return Err(format!("no netmask {:?}", x));
};
let dest = if let Ok(dest) = dest.parse::<Ipv4Addr>() {
dest
} else {
return Err("not ipv4".to_string());
return Err(format!("not ipv4 {:?}", dest));
};
let mask = to_ip(mask)?;
in_ips_c.push((u32::from_be_bytes(dest.octets()), mask));
Expand Down
7 changes: 5 additions & 2 deletions common/src/identifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ pub fn get_unique_identifier() -> Option<String> {
// 对 linux 或 wsl 来说,读取 /etc/machine-id 即可获取当前操作系统的
// 唯一标识,而且某些环境没有预装`dmidecode`命令
if let Ok(identifier) = std::fs::read_to_string("/etc/machine-id") {
return Some(identifier);
let identifier = identifier.trim();
if !identifier.is_empty() {
return Some(identifier.to_string());
}
}

let output = match Command::new("dmidecode")
Expand All @@ -70,7 +73,7 @@ pub fn get_unique_identifier() -> Option<String> {
};

let result = String::from_utf8_lossy(&output.stdout);
let identifier = result.trim().to_string();
let identifier = result.trim();
if identifier.is_empty() {
None
} else {
Expand Down
17 changes: 9 additions & 8 deletions vnt-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
vnt = { path = "../vnt", package = "vnt",default-features = false }
vnt = { path = "../vnt", package = "vnt", default-features = false }
common = { path = "../common" }
getopts = "0.2.21"
console = "0.15.2"
Expand All @@ -28,16 +28,17 @@ sudo = "0.6.0"
winapi = { version = "0.3.9", features = ["handleapi", "processthreadsapi", "winnt", "securitybaseapi", "impl-default"] }

[features]
default = ["server_encrypt","aes_gcm","aes_cbc","aes_ecb","sm4_cbc","ip_proxy"]
default = ["server_encrypt", "aes_gcm", "aes_cbc", "aes_ecb", "sm4_cbc", "ip_proxy", "port_mapping"]
openssl = ["vnt/openssl"]
openssl-vendored = ["vnt/openssl-vendored"]
ring-cipher = ["vnt/ring-cipher"]
aes_cbc=["vnt/aes_cbc"]
aes_ecb=["vnt/aes_ecb"]
sm4_cbc=["vnt/sm4_cbc"]
aes_gcm=["vnt/aes_gcm"]
server_encrypt=["vnt/server_encrypt"]
ip_proxy=["vnt/ip_proxy"]
aes_cbc = ["vnt/aes_cbc"]
aes_ecb = ["vnt/aes_ecb"]
sm4_cbc = ["vnt/sm4_cbc"]
aes_gcm = ["vnt/aes_gcm"]
server_encrypt = ["vnt/server_encrypt"]
ip_proxy = ["vnt/ip_proxy"]
port_mapping = ["vnt/port_mapping"]
[build-dependencies]
embed-manifest = "1.4.0"
rand = "0.8.5"
Expand Down
Loading

0 comments on commit 4dca4c4

Please sign in to comment.