修改stun

This commit is contained in:
lbl8603
2024-06-27 21:58:17 +08:00
parent 9e249862dc
commit 916fd8254b
5 changed files with 77 additions and 30 deletions
+4 -4
View File
@@ -156,9 +156,9 @@ pub fn parse_args_config() -> anyhow::Result<Option<(Config, Vec<String>, bool)>
let mut stun_server = matches.opt_strs("e");
if stun_server.is_empty() {
stun_server.push("stun1.l.google.com:19302".to_string());
stun_server.push("stun2.l.google.com:19302".to_string());
stun_server.push("stun.miwifi.com:3478".to_string());
for x in config::PUB_STUN {
stun_server.push(x.to_string());
}
}
let dns = matches.opt_strs("dns");
let in_ip = matches.opt_strs("i");
@@ -340,7 +340,7 @@ fn print_usage(program: &str, _opts: Options) {
println!(" -n <name> 给设备一个名字,便于区分不同设备,默认使用系统版本");
println!(" -d <id> 设备唯一标识符,不使用--ip参数时,服务端凭此参数分配虚拟ip,注意不能重复");
println!(" -s <server> 注册和中继服务器地址,以'TXT:'开头表示解析TXT记录");
println!(" -e <stun-server> stun服务器,用于探测NAT类型,可使用多个地址,如-e stun1.l.google.com -e stun2.l.google.com");
println!(" -e <stun-server> stun服务器,用于探测NAT类型,可使用多个地址,如-e stun.miwifi.com -e turn.cloudflare.com");
#[cfg(target_os = "windows")]
#[cfg(feature = "integrated_tun")]
println!(
+6 -6
View File
@@ -2,8 +2,8 @@ use anyhow::anyhow;
use std::net::Ipv4Addr;
use std::str::FromStr;
use crate::args_parse;
use crate::config::get_device_id;
use crate::{args_parse, config};
use serde::{Deserialize, Serialize};
use vnt::channel::punch::PunchModel;
use vnt::channel::UseChannelType;
@@ -49,6 +49,10 @@ pub struct FileConfig {
impl Default for FileConfig {
fn default() -> Self {
let mut stun_server = Vec::new();
for x in config::PUB_STUN {
stun_server.push(x.to_string());
}
Self {
#[cfg(target_os = "windows")]
tap: false,
@@ -59,11 +63,7 @@ impl Default for FileConfig {
.unwrap_or("UnknownName")
.to_string(),
server_address: "nat1.wherewego.top:29872".to_string(),
stun_server: vec![
"stun1.l.google.com:19302".to_string(),
"stun2.l.google.com:19302".to_string(),
"stun.miwifi.com:3478".to_string(),
],
stun_server,
dns: vec![],
in_ips: vec![],
out_ips: vec![],
+6
View File
@@ -1,3 +1,9 @@
pub const PUB_STUN: [&'static str; 4] = [
"stun.miwifi.com",
"stun.chat.bilibili.com",
"stun.hitv.com",
"stun.cdnbye.com",
];
#[cfg(feature = "file_config")]
mod file_config;