Skip to content

Commit

Permalink
windows build (#152)
Browse files Browse the repository at this point in the history
* windows build

Signed-off-by: Yuwei Ba <[email protected]>

* Update ci.yml

Signed-off-by: Yuwei Ba <[email protected]>

* update tun

* update

* f

* f

* update doc

* f

* iup

* Update ci.yml

Signed-off-by: Yuwei Ba <[email protected]>

* f

* f

* f

* fix tests

---------

Signed-off-by: Yuwei Ba <[email protected]>
  • Loading branch information
ibigbug authored Nov 5, 2023
1 parent 001e068 commit 58d8e88
Show file tree
Hide file tree
Showing 12 changed files with 166 additions and 61 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: test on ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, macos-13]
os: [ubuntu-22.04, macos-13, windows-2022]
runs-on: ${{ matrix.os }}

steps:
Expand All @@ -23,6 +23,7 @@ jobs:
- uses: actions/setup-go@v4
with:
go-version: '1.20'
- uses: ilammy/setup-nasm@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
Expand All @@ -39,7 +40,7 @@ jobs:
container: ${{ matrix.container }}
strategy:
matrix:
os: [ubuntu-22.04, macos-13]
os: [ubuntu-22.04, macos-13, windows-2022]
include:
- os: ubuntu-22.04
targets: >
Expand All @@ -48,13 +49,17 @@ jobs:
targets: >
aarch64-apple-darwin
x86_64-apple-darwin
- os: windows-2022
targets: >
x86_64-pc-windows-msvc
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-go@v4
with:
go-version: '1.20'
- uses: ilammy/setup-nasm@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
Expand Down
143 changes: 112 additions & 31 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ A custom protocol, rule based network proxy software.

- Linux
- macOS
- Windows(Untested)
- You need to copy the [wintun.dll](https://wintun.net/) file which matches your architecture to the same directory as your executable and run you program as administrator.

## 📦 Install

Expand Down
7 changes: 4 additions & 3 deletions clash_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ axum = { version = "0.6.20", features = ["ws"] }
tower-http = { version = "0.4.0", features = ["fs", "trace", "cors"] }
chrono = { version = "0.4.26", features = ["serde"] }

tun = { git = "https://github.com/Watfaq/rust-tun.git", rev = "28936b6", features = ["async"] }
netstack-lwip = { git = "https://github.com/Watfaq/netstack-lwip.git", rev = "0528151" }
boringtun = { version = "0.6.0", features = ["device"] }
tun = { git = "https://github.com/Watfaq/rust-tun.git", rev = "8f7568190f1200d3e272ca534baf8d1578147e18", features = ["async"] }
netstack-lwip = { git = "https://github.com/Watfaq/netstack-lwip.git", rev = "2817bf82740e04bbee6b7bf1165f55657a6ed163" }

boringtun = { version = "0.6.0" }

serde = { version = "1.0", features=["derive"] }
serde_yaml = "0.9"
Expand Down
10 changes: 5 additions & 5 deletions clash_lib/src/app/remote_content_manager/providers/fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,15 @@ mod tests {
let tx1 = tx.clone();

let mut mock_vehicle = MockProviderVehicle::new();
let mock_file = "/tmp/mock_provider_vehicle";
if Path::new(mock_file).exists() {
std::fs::remove_file(mock_file).unwrap();
let mock_file = std::env::temp_dir().join("mock_provider_vehicle");
if Path::new(mock_file.to_str().unwrap()).exists() {
std::fs::remove_file(&mock_file).unwrap();
}
std::fs::write(mock_file, vec![1, 2, 3]).unwrap();
std::fs::write(&mock_file, vec![1, 2, 3]).unwrap();

mock_vehicle
.expect_path()
.return_const(mock_file.to_owned());
.return_const(mock_file.to_str().unwrap().to_owned());
mock_vehicle.expect_read().returning(|| Ok(vec![4, 5, 6]));
mock_vehicle
.expect_typ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,9 @@ mod tests {
let u = "https://httpbin.yba.dev/base64/SFRUUEJJTiBpcyBhd2Vzb21l"
.parse::<Uri>()
.unwrap();
let p = std::env::temp_dir().join("test_http_vehicle");
let r = Arc::new(Resolver::new_default().await);
let v = super::Vehicle::new(
u,
"/tmp/test_http_vehicle",
None,
r.clone() as ThreadSafeDNSResolver,
);
let v = super::Vehicle::new(u, p, None, r.clone() as ThreadSafeDNSResolver);

let data = v.read().await.unwrap();
assert_eq!(str::from_utf8(&data).unwrap(), "HTTPBIN is awesome");
Expand Down
2 changes: 2 additions & 0 deletions clash_lib/src/common/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ pub fn new_http_client(dns_resolver: ThreadSafeDNSResolver) -> std::io::Result<H
let mut ssl = SslConnector::builder(SslMethod::tls()).map_err(map_io_error)?;
ssl.set_alpn_protos(b"\x02h2\x08http/1.1")
.map_err(map_io_error)?;
#[cfg(target_os = "windows")]
ssl.set_verify(boring::ssl::SslVerifyMode::NONE); // TODO: verify certificate

let connector = HttpsConnector::with_connector(connector, ssl).map_err(map_io_error)?;
Ok(hyper::Client::builder().build::<_, hyper::Body>(connector))
Expand Down
Loading

0 comments on commit 58d8e88

Please sign in to comment.