Skip to content

Commit 79ecbb6

Browse files
committed
fix windows and CI
1 parent 4c5cc48 commit 79ecbb6

File tree

4 files changed

+27
-20
lines changed

4 files changed

+27
-20
lines changed

.github/workflows/ci-version.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ jobs:
2424
name: Test ${{ matrix.toolchain }} on ${{ matrix.os }} to ${{ matrix.target }}
2525
runs-on: ${{ matrix.os }}
2626
steps:
27+
- name: Install musl-tools (Linux)
28+
run: |
29+
sudo apt update
30+
sudo apt install musl-tools
31+
if: matrix.target == 'x86_64-unknown-linux-musl'
2732
- uses: actions/checkout@v2
2833
- uses: actions-rs/toolchain@v1
2934
with:
@@ -40,8 +45,8 @@ jobs:
4045
fail-fast: false
4146
matrix:
4247
os:
43-
- windows-latest
4448
- macos-latest
49+
- windows-latest
4550
toolchain:
4651
- stable
4752
- nightly

.github/workflows/ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ jobs:
4545
name: Test ${{ matrix.toolchain }} on ${{ matrix.os }} to ${{ matrix.target }}
4646
runs-on: ${{ matrix.os }}
4747
steps:
48+
- name: Install musl-tools (Linux)
49+
run: |
50+
sudo apt update
51+
sudo apt install musl-tools
52+
if: matrix.target == 'x86_64-unknown-linux-musl'
4853
- uses: actions/checkout@v2
4954
- uses: actions-rs/toolchain@v1
5055
with:
@@ -61,8 +66,8 @@ jobs:
6166
fail-fast: false
6267
matrix:
6368
os:
64-
- windows-latest
6569
- macos-latest
70+
- windows-latest
6671
toolchain:
6772
- stable
6873
- nightly

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "wait-service"
3-
version = "0.1.3"
3+
version = "0.1.4"
44
authors = ["Magic Len <len@magiclen.org>"]
55
edition = "2021"
66
repository = "https://github.com/magiclen/wait-service"

src/main.rs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ extern crate dnsclient;
99

1010
use std::error::Error;
1111
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
12-
use std::path::Path;
1312
use std::process::{self, Command};
1413
use std::str::FromStr;
1514
use std::time::Duration;
1615

16+
#[cfg(unix)]
17+
use std::path::Path;
18+
1719
#[cfg(unix)]
1820
use tokio::net::UnixStream;
1921

@@ -55,26 +57,21 @@ async fn tcp(
5557
let ips = match IpAddr::from_str(host) {
5658
Ok(ip) => vec![SocketAddr::new(ip, port)],
5759
Err(_) => {
60+
let dns_servers = vec![
61+
UpstreamServer::new(SocketAddr::new(IpAddr::V4(Ipv4Addr::new(1, 1, 1, 1)), 53)),
62+
UpstreamServer::new(SocketAddr::new(IpAddr::V4(Ipv4Addr::new(8, 8, 8, 8)), 53)),
63+
UpstreamServer::new(SocketAddr::new(IpAddr::V4(Ipv4Addr::new(4, 4, 4, 4)), 53)),
64+
];
65+
66+
#[cfg(unix)]
5867
let client = match DNSClient::new_with_system_resolvers() {
5968
Ok(client) => client,
60-
Err(_) => {
61-
DNSClient::new(vec![
62-
UpstreamServer::new(SocketAddr::new(
63-
IpAddr::V4(Ipv4Addr::new(1, 1, 1, 1)),
64-
53,
65-
)),
66-
UpstreamServer::new(SocketAddr::new(
67-
IpAddr::V4(Ipv4Addr::new(8, 8, 8, 8)),
68-
53,
69-
)),
70-
UpstreamServer::new(SocketAddr::new(
71-
IpAddr::V4(Ipv4Addr::new(4, 4, 4, 4)),
72-
53,
73-
)),
74-
])
75-
}
69+
Err(_) => DNSClient::new(dns_servers),
7670
};
7771

72+
#[cfg(windows)]
73+
let client = DNSClient::new(dns_servers);
74+
7875
let host_with_port = format!("{}:{}", host, port);
7976

8077
client

0 commit comments

Comments
 (0)