feat: add Windows 7 SP1 x64 tool bundle

This commit is contained in:
lbl committed 2026-11-25 18:14:01 +08:00
1 parent 1436aa3b95
commit 034235d65e
15 files changed
+286 -14

No files matched your search

+3
View File
@@ -13,6 +13,9 @@
linker = "aarch64-linux-musl-gcc"
rustflags = ["-C", "target-feature=+crt-static", "-C", "strip=symbols"]
[target.x86_64-win7-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static", "-C", "link-arg=/SUBSYSTEM:CONSOLE,6.01"]
[target.mipsel-unknown-linux-musl]
linker = "mipsel-linux-muslsf-gcc"
rustflags = ["-C", "target-feature=+crt-static","-C", "strip=symbols","-C", "link-arg=-static",
+56
View File
@@ -0,0 +1,56 @@
# Requires MSVC x64 build tools and llvm-readobj on PATH.
$ErrorActionPreference = 'Stop'
$toolchain = 'nightly-2026-06-12'
$target = 'x86_64-win7-windows-msvc'
$binaries = @('vnt2_cli', 'vnt2_ctrl', 'vnt2_web')
$llvm = Get-Command llvm-readobj -CommandType Application | Select-Object -First 1
$previousSkipUiBuild = $env:VNT_WEB_SKIP_UI_BUILD
Push-Location (Join-Path $PSScriptRoot '../..')
try {
if (!(Test-Path 'vnt-web/static/index.html' -PathType Leaf) -or
!(Get-ChildItem 'vnt-web/static/assets' -Filter '*.js' -File -ErrorAction SilentlyContinue)) {
throw 'Build the Web frontend with pnpm build:web or restore its build artifact first.'
}
rustup toolchain install $toolchain --profile minimal --component rust-src --no-self-update
if ($LASTEXITCODE -ne 0) { throw 'Could not install the Windows 7 Rust toolchain.' }
$env:VNT_WEB_SKIP_UI_BUILD = '1'
$binArgs = foreach ($binary in $binaries) { '--bin'; $binary }
cargo "+$toolchain" build --locked --release -p vnt2 --target $target --target-dir target `
-Z build-std=std,panic_abort --features vnt-ipc,vnt-web @binArgs
if ($LASTEXITCODE -ne 0) { throw 'Windows 7 build failed.' }
$images = @($binaries | ForEach-Object { "target/$target/release/$_.exe" })
$images += 'dll/amd64/wintun.dll'
foreach ($image in $images) {
$report = & $llvm.Source --file-headers --coff-imports $image | Out-String
if ($LASTEXITCODE -ne 0) { throw "Could not inspect $image." }
if ($report -notmatch '(?m)^ Machine: IMAGE_FILE_MACHINE_AMD64\b') {
throw "$image is not an x64 PE image."
}
if ($image.EndsWith('.exe') -and
($report -notmatch '(?m)^ MajorSubsystemVersion: 6\s*$' -or
$report -notmatch '(?m)^ MinorSubsystemVersion: 1\s*$' -or
$report -notmatch '(?m)^ Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI\b')) {
throw "$image must use the Windows console subsystem version 6.01."
}
# Wintun delay-loads APIs used by its newer Windows paths. Inspect them
# in the report, while checking eager imports for loader failures.
Write-Output $report
$eagerImports = [regex]::Matches($report, '(?m)^Import \{\r?\n[\s\S]*?^\}')
if ($eagerImports.Count -eq 0) { throw "Could not find the import table for $image." }
foreach ($entry in $eagerImports) {
if ($entry.Value -match '(?im)^ Name: (?:api-ms-win-|ext-ms-win-|bcryptprimitives\.dll|ucrtbase\.dll|vcruntime\d|msvcp\d)' -or
$entry.Value -match '(?m)^ Symbol: (?:GetSystemTimePreciseAsFileTime|GetOverlappedResultEx|SetThreadDescription|WaitOnAddress|WakeByAddressAll|WakeByAddressSingle|ProcessPrng) \(') {
throw "$image eagerly imports a DLL or API outside the Windows 7 baseline:`n$($entry.Value)"
}
}
}
}
finally {
$env:VNT_WEB_SKIP_UI_BUILD = $previousSkipUiBuild
Pop-Location
}
@@ -18,6 +18,7 @@ const TOOL_TARGETS = [
["Windows", "x86_64", "x86_64-pc-windows-msvc"],
["Windows", "x86", "i686-pc-windows-msvc"],
["Windows", "ARM64", "aarch64-pc-windows-msvc"],
["Windows 7 SP1(预览)", "x86_64", "x86_64-win7-windows-msvc"],
["Linux", "x86_64", "x86_64-unknown-linux-musl"],
["Linux", "ARM64", "aarch64-unknown-linux-musl"],
["Linux", "ARMv7 hard-float", "armv7-unknown-linux-musleabihf"],
@@ -23,6 +23,21 @@ test("builds links for desktop installers and target tool bundles", () => {
assert.doesNotMatch(section, /VNT\.Desktop_2\.0\.0_windows_x64\.msi/);
});
test("lists the Windows 7 preview ZIP when present", () => {
const args = {
version: "2.0.0",
tag: "v2.0.0",
releaseUrl: "https://github.com/vnt-dev/vnt/releases/download/v2.0.0",
};
const filename = "vnt2-x86_64-win7-windows-msvc-v2.0.0.zip";
assert.equal(buildDownloadSection({ ...args, assetNames: new Set() }), undefined);
assert.ok(
buildDownloadSection({ ...args, assetNames: new Set([filename]) }).includes(
`| Windows 7 SP1(预览) | x86_64 | [ZIP](${args.releaseUrl}/${filename}) |`,
),
);
});
test("replaces an existing release download section", () => {
const oldSection = [
"<!-- vnt-downloads:start -->",
+36
View File
@@ -37,6 +37,14 @@ jobs:
- name: Build shared Web frontend
run: pnpm build:web
- name: Upload Web static files
uses: actions/upload-artifact@v4
with:
name: vnt-web-static
path: vnt-web/static
if-no-files-found: error
retention-days: 1
- name: Build Tauri frontend
run: pnpm build:desktop-ui
@@ -84,3 +92,31 @@ jobs:
- name: Run tests
run: cargo test --workspace --all-targets
win7:
name: Windows 7 x64 build and PE checks
needs: frontend
runs-on: windows-latest
steps:
- name: Check out repository
uses: actions/checkout@v5
- name: Download Web static files
uses: actions/download-artifact@v4
with:
name: vnt-web-static
path: vnt-web/static
- name: Build and inspect Windows 7 binaries
shell: pwsh
run: ./.github/scripts/build-win7.ps1
- name: Upload Windows 7 binaries for runtime testing
uses: actions/upload-artifact@v4
with:
name: Vnt-x86_64-win7-windows-msvc
path: |
target/x86_64-win7-windows-msvc/release/vnt2_cli.exe
target/x86_64-win7-windows-msvc/release/vnt2_ctrl.exe
target/x86_64-win7-windows-msvc/release/vnt2_web.exe
if-no-files-found: error
+9 -3
View File
@@ -71,6 +71,8 @@ jobs:
OS: windows-latest
- TARGET: x86_64-pc-windows-msvc
OS: windows-latest
- TARGET: x86_64-win7-windows-msvc
OS: windows-latest
- TARGET: aarch64-pc-windows-msvc
OS: windows-latest
- TARGET: mipsel-unknown-linux-musl
@@ -108,7 +110,7 @@ jobs:
if: runner.os == 'macOS'
run: brew install protobuf
- name: Install Protobuf (Windows)
if: runner.os == 'Windows'
if: runner.os == 'Windows' && !contains(matrix.TARGET, '-win7-')
run: choco install protoc
- name: Use strawberry perl
if: startsWith(matrix.os, 'windows')
@@ -248,10 +250,14 @@ jobs:
rustflags = ["-C", "target-feature=+crt-static","-C", "strip=symbols"]
EOF
- name: Install rust target
if: ${{ ! endsWith(matrix.TARGET, 'freebsd') && ! startsWith(matrix.TARGET, 'mips') }}
if: ${{ ! endsWith(matrix.TARGET, 'freebsd') && ! startsWith(matrix.TARGET, 'mips') && ! contains(matrix.TARGET, '-win7-') }}
run: rustup target add $TARGET
- name: Build and inspect Windows 7 binaries
if: contains(matrix.TARGET, '-win7-')
shell: pwsh
run: ./.github/scripts/build-win7.ps1
- name: Run build Vnt
if: ${{ ! endsWith(matrix.TARGET, 'freebsd') }}
if: ${{ ! endsWith(matrix.TARGET, 'freebsd') && ! contains(matrix.TARGET, '-win7-') }}
run: |
if [[ $TARGET =~ ^mips.*$ ]]; then
cargo +nightly build --release --verbose --target $TARGET -Z build-std=std,panic_abort --bin vnt2_web --features vnt-web
Generated
+1
View File
@@ -6418,6 +6418,7 @@ dependencies = [
"prost",
"prost-build",
"protoc-bin-vendored",
"subtle",
"time",
"tokio",
"tokio-util",
+4
View File
@@ -79,6 +79,10 @@ VNT组网可使用VNT桌面客户端、`vnt2_web`和`vnt2_cli`。
## 常见问题
### Win7 安装虚拟网卡时提示无法验证驱动签名怎么办?
在「控制面板 → 程序和功能 → 查看已安装的更新」中检查 KB4490628 和 KB4474419。若缺少相关更新,按微软说明补装,重启后再试。 [Microsoft 更新说明](https://support.microsoft.com/en-gb/servicing/os/windows/2020/09/2019-sha-2-code-signing-support-requirement-for-windows-and-wsus)
### Windows 上提示需要管理员权限?
创建虚拟网卡需要以管理员身份运行程序,右键选择"以管理员身份运行"即可。
+12 -3
View File
@@ -1,6 +1,7 @@
use super::{Args, FileConfig, resolve_configuration};
use anyhow::Context;
use std::sync::Arc;
use tokio_util::sync::CancellationToken;
use vnt_core::api::VntApi;
use vnt_core::log_manager::InstanceLog;
use vnt_core::managed_config::Subscription;
@@ -14,6 +15,8 @@ pub(crate) async fn run(
log: Arc<InstanceLog>,
ctrl_port: Option<u16>,
) -> anyhow::Result<()> {
let shutdown = CancellationToken::new();
let ipc_shutdown = vnt_ipc::stop_token()?.map(|token| (token, shutdown.clone()));
// 配置管理器:持有订阅连接与组网实例;托管模式在此等待服务端首份配置
// (本地配置的身份字段已剥离,resolved 时 network_code 仅为占位符,
// 首份信封到达后由 merge_present_config 以信封身份覆盖)
@@ -27,10 +30,11 @@ pub(crate) async fn run(
network.prefix_len,
manager.device_mode()
);
let mut ipc = IpcPublisher::new(ctrl_port);
let mut ipc = IpcPublisher::new(ctrl_port, ipc_shutdown);
ipc.publish(manager.api());
loop {
tokio::select! {
_ = shutdown.cancelled() => break,
result = tokio::signal::ctrl_c() => {
result.context("install Ctrl+C handler")?;
log::info!("Ctrl+c received!");
@@ -69,13 +73,15 @@ pub(crate) async fn run(
struct IpcPublisher {
ctrl_port: Option<u16>,
sender: Option<tokio::sync::watch::Sender<VntApi>>,
shutdown: Option<(String, CancellationToken)>,
}
impl IpcPublisher {
fn new(ctrl_port: Option<u16>) -> Self {
fn new(ctrl_port: Option<u16>, shutdown: Option<(String, CancellationToken)>) -> Self {
Self {
ctrl_port,
sender: None,
shutdown,
}
}
@@ -93,8 +99,11 @@ impl IpcPublisher {
let (sender, receiver) = tokio::sync::watch::channel(api);
self.sender = Some(sender);
let ctrl_port = self.ctrl_port;
let shutdown = self.shutdown.take();
tokio::spawn(async move {
if let Err(error) = vnt_ipc::server::run_server_dynamic(ctrl_port, receiver).await {
if let Err(error) =
vnt_ipc::server::run_server_with_shutdown(ctrl_port, receiver, shutdown).await
{
log::error!("ipc:{error:?}");
}
});
+21
View File
@@ -1,4 +1,5 @@
use clap::{Parser, Subcommand};
use vnt_ipc::message::StopCmd;
use vnt_ipc::message::ipc_request::IpcCmd;
/// 操作vnt进程
@@ -23,20 +24,40 @@ enum Commands {
Clients,
/// 输出IP路由信息
Route,
/// 正常停止 CLI 实例,需要在两端设置 VNT_IPC_STOP_TOKEN
Stop,
}
#[tokio::main]
pub async fn main() {
let args = Args::parse();
let port = args.port;
let stopping = matches!(args.command, Commands::Stop);
let cmd = match args.command {
Commands::Info => IpcCmd::AppInfo(Default::default()),
Commands::Ips => IpcCmd::ClientIps(Default::default()),
Commands::Clients => IpcCmd::ClientList(Default::default()),
Commands::Route => IpcCmd::AllRoute(Default::default()),
Commands::Stop => {
let token = match vnt_ipc::stop_token() {
Ok(Some(token)) => token,
Ok(None) => {
eprintln!("Set {} before requesting a stop.", vnt_ipc::STOP_TOKEN_ENV);
std::process::exit(1);
}
Err(error) => {
eprintln!("{error}");
std::process::exit(1);
}
};
IpcCmd::Stop(StopCmd { token })
}
};
if let Err(e) = vnt_ipc::client::run_client(cmd, port).await {
eprintln!("{:?}", e);
if stopping {
std::process::exit(1);
}
}
}
+1
View File
@@ -16,6 +16,7 @@ log.workspace = true
time.workspace = true
console = "0.16.2"
cli-table = "0.5.0"
subtle = "2.6"
[build-dependencies]
prost-build = "0.14"
+10
View File
@@ -8,6 +8,7 @@ message IpcRequest{
ClientIpsCMD client_ips = 2;
ClientListCMD client_list = 3;
AllRouteCMD all_route = 4;
StopCMD stop = 5;
}
}
message AppInfoCMD{
@@ -24,12 +25,21 @@ message AllRouteCMD{
}
message StopCMD {
string token = 1;
}
message StopResult {
bool accepted = 1;
}
message IpcResponse{
oneof response_payload{
AppInfo app_info = 1;
ClientIpList client_ips = 2;
ClientInfoList client_list = 3;
ClientRouteList all_route = 4;
StopResult stop = 5;
}
}
+13 -3
View File
@@ -18,6 +18,7 @@ use tokio::net::TcpStream;
use tokio_util::codec::{Framed, LengthDelimitedCodec};
pub async fn run_client(cmd: IpcCmd, port: Option<u16>) -> anyhow::Result<()> {
let stop_requested = matches!(cmd, IpcCmd::Stop(_));
let path = get_port_file_path();
let port = if let Some(port) = port {
port
@@ -47,10 +48,13 @@ pub async fn run_client(cmd: IpcCmd, port: Option<u16>) -> anyhow::Result<()> {
.context("Response timed out")?
.context("Unexpected end of stream")??;
let response = IpcResponse::decode(response).context("decode response error")?;
match response
let payload = response
.response_payload
.context("response payload is empty")?
{
.context("response payload is empty")?;
if stop_requested != matches!(payload, ResponsePayload::Stop(_)) {
anyhow::bail!("Unexpected response to the control command");
}
match payload {
ResponsePayload::AppInfo(info) => {
print_app_info(info);
}
@@ -61,6 +65,12 @@ pub async fn run_client(cmd: IpcCmd, port: Option<u16>) -> anyhow::Result<()> {
ResponsePayload::AllRoute(route_list) => {
print_route_list(route_list)?;
}
ResponsePayload::Stop(result) if result.accepted => {
println!("Stop requested.");
}
ResponsePayload::Stop(_) => {
anyhow::bail!("Stop denied: the instance has no stop token or the token is invalid");
}
};
Ok(())
}
+9
View File
@@ -4,6 +4,15 @@ pub mod server;
pub use vnt_core::*;
const DEFAULT_PORT: u16 = 11233;
pub const STOP_TOKEN_ENV: &str = "VNT_IPC_STOP_TOKEN";
pub fn stop_token() -> anyhow::Result<Option<String>> {
match std::env::var(STOP_TOKEN_ENV) {
Ok(token) if token.len() >= 16 => Ok(Some(token)),
Err(std::env::VarError::NotPresent) => Ok(None),
_ => anyhow::bail!("{STOP_TOKEN_ENV} must contain at least 16 bytes of UTF-8"),
}
}
const PORT_FILE: &str = "PORT";
+95 -5
View File
@@ -4,20 +4,29 @@ use crate::message::ipc_request::IpcCmd;
use crate::message::ipc_response::ResponsePayload;
use crate::message::{
AppInfo, ClientInfoItem, ClientInfoList, ClientIpItem, ClientIpList, ClientRouteItem,
ClientRouteList, IpcRequest, IpcResponse, PacketLoss, Route, ServerInfo,
ClientRouteList, IpcRequest, IpcResponse, PacketLoss, Route, ServerInfo, StopResult,
};
use anyhow::bail;
use futures::{SinkExt, StreamExt};
use prost::Message;
use std::fs;
use std::net::Ipv4Addr;
use std::sync::Arc;
use std::time::Duration;
use subtle::ConstantTimeEq;
use tokio::io::{self};
use tokio::net::{TcpListener, TcpStream};
use tokio_util::codec::{Framed, LengthDelimitedCodec};
use tokio_util::sync::CancellationToken;
use vnt_core::api::VntApi;
async fn handle_connection(stream: TcpStream, vnt_api: VntApi) -> anyhow::Result<()> {
type ShutdownControl = (String, CancellationToken);
async fn handle_connection(
stream: TcpStream,
vnt_api: VntApi,
shutdown: Option<&ShutdownControl>,
) -> anyhow::Result<()> {
let mut framed = Framed::new(stream, LengthDelimitedCodec::new());
// 读请求加超时:空闲连接不能永久占用任务
@@ -32,6 +41,7 @@ async fn handle_connection(stream: TcpStream, vnt_api: VntApi) -> anyhow::Result
let Some(cmd) = request.ipc_cmd else {
bail!("Received an IpcRequest but it was None");
};
let mut stop = None;
let rs = match cmd {
IpcCmd::AppInfo(_) => {
let info = app_info(&vnt_api);
@@ -107,13 +117,27 @@ async fn handle_connection(stream: TcpStream, vnt_api: VntApi) -> anyhow::Result
let route_list = all_route(&vnt_api);
ResponsePayload::AllRoute(route_list)
}
IpcCmd::Stop(request) => {
stop = shutdown
.filter(|(token, _)| {
bool::from(token.as_bytes().ct_eq(request.token.as_bytes()))
})
.map(|(_, cancellation)| cancellation);
ResponsePayload::Stop(StopResult {
accepted: stop.is_some(),
})
}
};
let rs = IpcResponse {
response_payload: Some(rs),
};
framed
let response = framed
.send(prost::bytes::Bytes::from(rs.encode_to_vec()))
.await?;
.await;
if let Some(cancellation) = stop {
cancellation.cancel();
}
response?;
}
Ok(())
@@ -192,6 +216,15 @@ pub async fn run_server_dynamic(
bind_port: Option<u16>,
vnt_api: tokio::sync::watch::Receiver<VntApi>,
) -> anyhow::Result<()> {
run_server_with_shutdown(bind_port, vnt_api, None).await
}
pub async fn run_server_with_shutdown(
bind_port: Option<u16>,
vnt_api: tokio::sync::watch::Receiver<VntApi>,
shutdown: Option<(String, CancellationToken)>,
) -> anyhow::Result<()> {
let shutdown = shutdown.map(Arc::new);
let mut port = bind_port.unwrap_or(DEFAULT_PORT);
let listener;
@@ -226,10 +259,67 @@ pub async fn run_server_dynamic(
let (stream, peer_addr) = listener.accept().await?;
log::info!("IPC Connection from {}", peer_addr);
let vnt_api = vnt_api.borrow().clone();
let shutdown = shutdown.clone();
tokio::spawn(async move {
if let Err(e) = handle_connection(stream, vnt_api).await {
if let Err(e) = handle_connection(stream, vnt_api, shutdown.as_deref()).await {
log::warn!("IPC Error handling client: {:?},peer_addr={peer_addr}", e);
}
});
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::message::StopCmd;
use vnt_core::context::config::{Config, DeviceMode};
use vnt_core::log_manager::InstanceLog;
use vnt_core::network_info::RuntimeChangeManager;
#[tokio::test]
async fn stop_requires_an_enabled_matching_token() {
let config = Config {
network_code: "ipc-shutdown-test".into(),
device_id: "ipc-shutdown-test".into(),
ip: Some("10.26.0.2/24".parse().unwrap()),
device_mode: DeviceMode::No,
no_punch: true,
tunnel_addr: vec!["127.0.0.1:0".parse().unwrap()],
..Default::default()
};
let mut manager = RuntimeChangeManager::new(
config,
None,
Arc::new(InstanceLog::new("ipc-shutdown-test")),
)
.await
.unwrap();
let api = manager.api().unwrap();
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
let port = listener.local_addr().unwrap().port();
let cancellation = CancellationToken::new();
let valid = "valid-shutdown-token";
let shutdown = (valid.into(), cancellation.clone());
for (control, token, should_stop) in [
(None, valid, false),
(Some(&shutdown), "fake-shutdown-token", false),
(Some(&shutdown), valid, true),
] {
let server = async {
let (stream, _) = listener.accept().await.unwrap();
handle_connection(stream, api.clone(), control).await
};
let request = IpcCmd::Stop(StopCmd {
token: token.into(),
});
let (server, client) =
tokio::join!(server, crate::client::run_client(request, Some(port)));
server.unwrap();
assert_eq!(client.is_ok(), should_stop);
assert_eq!(cancellation.is_cancelled(), should_stop);
}
drop(api);
manager.stop().await;
}
}