Skip to content

Commit 029e12a

Browse files
committed
Feature: Force EasyTier to be p2p only
1 parent 859462d commit 029e12a

File tree

6 files changed

+24
-85
lines changed

6 files changed

+24
-85
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2024"
55
build = "build.rs"
66

77
[package.metadata.easytier]
8-
version = "v2.4.5"
8+
version = "v2.4.6"
99

1010
[workspace]
1111
resolver = "3"

build.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ fn download_easytier() {
9090

9191
let conf = match (target_os.as_str(), target_arch.as_str()) {
9292
("windows", "x86_64") => EasytierFiles {
93-
url: "https://github.com/EasyTier/EasyTier/releases/download/{V}/easytier-windows-x86_64-{V}.zip",
93+
url: "https://github.com/burningtnt/EasyTier/releases/download/{V}/easytier-windows-x86_64-{V}.zip",
9494
files: vec![
9595
"easytier-windows-x86_64/easytier-core.exe",
9696
"easytier-windows-x86_64/easytier-cli.exe",
@@ -101,7 +101,7 @@ fn download_easytier() {
101101
desc: "windows-x86_64",
102102
},
103103
("windows", "aarch64") => EasytierFiles {
104-
url: "https://github.com/EasyTier/EasyTier/releases/download/{V}/easytier-windows-arm64-{V}.zip",
104+
url: "https://github.com/burningtnt/EasyTier/releases/download/{V}/easytier-windows-arm64-{V}.zip",
105105
files: vec![
106106
"easytier-windows-arm64/easytier-core.exe",
107107
"easytier-windows-arm64/easytier-cli.exe",
@@ -112,7 +112,7 @@ fn download_easytier() {
112112
desc: "windows-arm64",
113113
},
114114
("linux", "x86_64") => EasytierFiles {
115-
url: "https://github.com/EasyTier/EasyTier/releases/download/{V}/easytier-linux-x86_64-{V}.zip",
115+
url: "https://github.com/burningtnt/EasyTier/releases/download/{V}/easytier-linux-x86_64-{V}.zip",
116116
files: vec![
117117
"easytier-linux-x86_64/easytier-core",
118118
"easytier-linux-x86_64/easytier-cli",
@@ -122,7 +122,7 @@ fn download_easytier() {
122122
desc: "linux-x86_64",
123123
},
124124
("linux", "aarch64") => EasytierFiles {
125-
url: "https://github.com/EasyTier/EasyTier/releases/download/{V}/easytier-linux-aarch64-{V}.zip",
125+
url: "https://github.com/burningtnt/EasyTier/releases/download/{V}/easytier-linux-aarch64-{V}.zip",
126126
files: vec![
127127
"easytier-linux-aarch64/easytier-core",
128128
"easytier-linux-aarch64/easytier-cli",
@@ -132,7 +132,7 @@ fn download_easytier() {
132132
desc: "linux-arm64",
133133
},
134134
("linux", "riscv64") => EasytierFiles {
135-
url: "https://github.com/EasyTier/EasyTier/releases/download/{V}/easytier-linux-riscv64-{V}.zip",
135+
url: "https://github.com/burningtnt/EasyTier/releases/download/{V}/easytier-linux-riscv64-{V}.zip",
136136
files: vec![
137137
"easytier-linux-riscv64/easytier-core",
138138
"easytier-linux-riscv64/easytier-cli",
@@ -142,7 +142,7 @@ fn download_easytier() {
142142
desc: "linux-riscv64",
143143
},
144144
("linux", "loongarch64") => EasytierFiles {
145-
url: "https://github.com/EasyTier/EasyTier/releases/download/{V}/easytier-linux-loongarch64-{V}.zip",
145+
url: "https://github.com/burningtnt/EasyTier/releases/download/{V}/easytier-linux-loongarch64-{V}.zip",
146146
files: vec![
147147
"easytier-linux-loongarch64/easytier-core",
148148
"easytier-linux-loongarch64/easytier-cli",
@@ -152,7 +152,7 @@ fn download_easytier() {
152152
desc: "linux-loongarch64",
153153
},
154154
("macos", "x86_64") => EasytierFiles {
155-
url: "https://github.com/EasyTier/EasyTier/releases/download/{V}/easytier-macos-x86_64-{V}.zip",
155+
url: "https://github.com/burningtnt/EasyTier/releases/download/{V}/easytier-macos-x86_64-{V}.zip",
156156
files: vec![
157157
"easytier-macos-x86_64/easytier-core",
158158
"easytier-macos-x86_64/easytier-cli",
@@ -162,7 +162,7 @@ fn download_easytier() {
162162
desc: "macos-x86_64",
163163
},
164164
("macos", "aarch64") => EasytierFiles {
165-
url: "https://github.com/EasyTier/EasyTier/releases/download/{V}/easytier-macos-aarch64-{V}.zip",
165+
url: "https://github.com/burningtnt/EasyTier/releases/download/{V}/easytier-macos-aarch64-{V}.zip",
166166
files: vec![
167167
"easytier-macos-aarch64/easytier-core",
168168
"easytier-macos-aarch64/easytier-cli",
@@ -172,7 +172,7 @@ fn download_easytier() {
172172
desc: "macos-arm64",
173173
},
174174
("freebsd", "x86_64") => EasytierFiles {
175-
url: "https://github.com/EasyTier/EasyTier/releases/download/{V}/easytier-freebsd-13.2-x86_64-{V}.zip",
175+
url: "https://github.com/burningtnt/EasyTier/releases/download/{V}/easytier-freebsd-13.2-x86_64-{V}.zip",
176176
files: vec![
177177
"easytier-freebsd-13.2-x86_64/easytier-core",
178178
"easytier-freebsd-13.2-x86_64/easytier-cli",

src/controller/rooms/experimental/room.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ pub fn start_host(room: Room, port: u16, player: Option<String>, capture: AppSta
170170
thread::spawn(move || {
171171
let mut counter = 0;
172172
loop {
173+
thread::sleep(Duration::from_secs(5));
174+
173175
if legacy::check_mc_conn(port) {
174176
counter = 0;
175177
} else {
@@ -282,8 +284,8 @@ pub fn start_guest(room: Room, player: Option<String>, capture: AppStateCapture)
282284
}
283285

284286
let mut session = 'session: {
285-
for timeout in [4, 4, 8, 4, 8, 16] {
286-
thread::sleep(Duration::from_secs(timeout));
287+
for _ in 0..60 {
288+
thread::sleep(Duration::from_secs(4));
287289

288290
const FINGERPRINT: [u8; 16] = [0x41, 0x57, 0x48, 0x44, 0x86, 0x37, 0x40, 0x59, 0x57, 0x44, 0x92, 0x43, 0x96, 0x99, 0x85, 0x01];
289291
if let Ok(mut session) = ClientSession::open(IpAddr::V4(Ipv4Addr::LOCALHOST), scaffolding_port)
@@ -563,7 +565,7 @@ pub fn start_guest(room: Room, player: Option<String>, capture: AppStateCapture)
563565
}
564566

565567
fn compute_arguments(room: &Room, public_servers: PublicServers) -> Vec<Argument> {
566-
static DEFAULT_ARGUMENTS: [Argument; 7] = [
568+
static DEFAULT_ARGUMENTS: [Argument; 8] = [
567569
Argument::NoTun,
568570
Argument::Compression(Cow::Borrowed("zstd")),
569571
Argument::MultiThread,
@@ -577,6 +579,7 @@ fn compute_arguments(room: &Room, public_servers: PublicServers) -> Vec<Argument
577579
address: SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, 0).into(),
578580
proto: Proto::TCP,
579581
},
582+
Argument::P2POnly
580583
];
581584

582585
let mut args: Vec<Argument> = Vec::with_capacity(32);

src/easytier/argument.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ pub enum Argument {
4545
IPv4(Ipv4Addr),
4646
TcpWhitelist(u16),
4747
UdpWhitelist(u16),
48+
P2POnly,
4849
}

src/easytier/executable_impl.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ impl EasytierFactory {
102102
Argument::IPv4(address) => push!["--ipv4", address.to_string()],
103103
Argument::TcpWhitelist(port) => push![format!("--tcp-whitelist={}", port)],
104104
Argument::UdpWhitelist(port) => push![format!("--udp-whitelist={}", port)],
105+
Argument::P2POnly => push!["--p2p-only"],
105106
}
106107
}
107108
built

src/easytier/publics.rs

Lines changed: 6 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,10 @@
1-
use std::io;
2-
use std::time::Duration;
3-
use rand_chacha::ChaCha12Rng;
4-
use rand_core::{RngCore, SeedableRng};
5-
use serde_json::Value;
6-
use crate::controller::{Room, RoomKind};
1+
use crate::controller::Room;
72

83
pub type PublicServers = Vec<String>;
94

10-
pub fn fetch_public_nodes(room: &Room) -> PublicServers {
11-
static FALLBACK_SERVERS: [&str; 2] = [
12-
"tcp://public.easytier.top:11010",
13-
"tcp://public2.easytier.cn:54321",
14-
];
15-
16-
fn fetch_inner(room: &Room) -> io::Result<Vec<String>> {
17-
static LIMIT: usize = 5;
18-
19-
let mut servers: Vec<String> = serde_json::from_reader::<_, Value>(
20-
reqwest::blocking::Client::builder()
21-
.user_agent(format!("Terracotta v{}/s={}", env!("TERRACOTTA_ET_VERSION"), option_env!("TERRACOTTA_U_S").unwrap_or("SNAPSHOT")))
22-
.timeout(Some(Duration::from_secs(10)))
23-
.build()
24-
.map_err(io::Error::other)?
25-
.get("https://uptime.easytier.cn/api/nodes?is_active=true&page=1&per_page=100&&tags=MC%E4%B8%AD%E7%BB%A7")
26-
.send()
27-
.map_err(io::Error::other)?
28-
).map_err(io::Error::other)?
29-
.as_object()
30-
.and_then(|object| {
31-
if !object.get("success")?.as_bool()? {
32-
return None;
33-
}
34-
35-
Some(object.get("data")?.as_object()?
36-
.get("items")?.as_array()?
37-
.iter()
38-
.filter_map(|node| node.as_object())
39-
.flat_map(|node| {
40-
let address = node.get("address")?.as_str()?;
41-
if node.get("allow_relay")?.as_bool()? && node.get("is_active")?.as_bool()? && !FALLBACK_SERVERS.contains(&address) {
42-
Some(address.to_string())
43-
} else {
44-
None
45-
}
46-
})
47-
.collect())
48-
})
49-
.ok_or(io::Error::from(io::ErrorKind::InvalidData))?;
50-
51-
if servers.len() > LIMIT {
52-
let mut rng = ChaCha12Rng::from_seed(match room.kind {
53-
RoomKind::Experimental { seed } => {
54-
let mut value = [0u8; 32];
55-
value[0..16].copy_from_slice(&seed.to_be_bytes());
56-
value
57-
}
58-
_ => unreachable!(),
59-
});
60-
61-
for i in (1..servers.len()).rev() {
62-
servers.swap(i, rng.next_u32() as usize % (i + 1));
63-
}
64-
servers.truncate(5);
65-
}
66-
for fallback in FALLBACK_SERVERS {
67-
servers.push(fallback.to_string());
68-
}
69-
Ok(servers)
70-
}
71-
72-
fetch_inner(room).unwrap_or_else(|e| {
73-
logging!("RoomExperiment", "Cannot fetch EasyTier public nodes: {:?}.", e);
74-
FALLBACK_SERVERS.map(|s| s.into()).to_vec()
75-
})
5+
pub fn fetch_public_nodes(_: &Room) -> PublicServers {
6+
vec![
7+
"tcp://public.easytier.top:11010".into(),
8+
"tcp://public2.easytier.cn:54321".into()
9+
]
7610
}

0 commit comments

Comments
 (0)