增加-o默认ip
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
use std::net::Ipv4Addr;
|
use std::net::Ipv4Addr;
|
||||||
|
|
||||||
pub fn ips_parse(ips: &Vec<String>) -> Result<Vec<(u32, u32, Ipv4Addr)>, String> {
|
pub fn ips_parse(ips: &Vec<String>,in_ip:bool) -> Result<Vec<(u32, u32, Ipv4Addr)>, String> {
|
||||||
let mut in_ips_c = vec![];
|
let mut in_ips_c = vec![];
|
||||||
for x in ips {
|
for x in ips {
|
||||||
let mut split = x.split(",");
|
let mut split = x.split(",");
|
||||||
@@ -12,7 +12,10 @@ pub fn ips_parse(ips: &Vec<String>) -> Result<Vec<(u32, u32, Ipv4Addr)>, String>
|
|||||||
let ip = if let Some(ip) = split.next() {
|
let ip = if let Some(ip) = split.next() {
|
||||||
ip
|
ip
|
||||||
} else {
|
} else {
|
||||||
return Err("ipv4/mask,ipv4".to_string());
|
if in_ip{
|
||||||
|
return Err("ipv4/mask,ipv4".to_string());
|
||||||
|
}
|
||||||
|
"0.0.0.0"
|
||||||
};
|
};
|
||||||
let ip = if let Ok(ip) = ip.parse::<Ipv4Addr>() {
|
let ip = if let Ok(ip) = ip.parse::<Ipv4Addr>() {
|
||||||
ip
|
ip
|
||||||
|
|||||||
@@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
在B配置 **-o 192.168.0.0/24,192.168.0.10** ,表示允许将192.168.0.0/24的数据从网卡192.168.0.10转发出去
|
在B配置 **-o 192.168.0.0/24,192.168.0.10** ,表示允许将192.168.0.0/24的数据从网卡192.168.0.10转发出去
|
||||||
|
|
||||||
|
注:-o 可以不配置出口ip,如直接使用 **-o 192.168.0.0/24** , 这将使用默认ip转发
|
||||||
|
|
||||||
### -w `<password>`
|
### -w `<password>`
|
||||||
|
|
||||||
提升通信安全性,使用该密码生成的密钥对客户端数据进行加密,并且服务端无法解密。使用相同密码的客户端才能通信
|
提升通信安全性,使用该密码生成的密钥对客户端数据进行加密,并且服务端无法解密。使用相同密码的客户端才能通信
|
||||||
|
|||||||
+2
-2
@@ -140,7 +140,7 @@ async fn main0() {
|
|||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let in_ip = matches.opt_strs("i");
|
let in_ip = matches.opt_strs("i");
|
||||||
let in_ip = match ips_parse(&in_ip) {
|
let in_ip = match ips_parse(&in_ip, true) {
|
||||||
Ok(in_ip) => { in_ip }
|
Ok(in_ip) => { in_ip }
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
print_usage(&program, opts);
|
print_usage(&program, opts);
|
||||||
@@ -150,7 +150,7 @@ async fn main0() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
let out_ip = matches.opt_strs("o");
|
let out_ip = matches.opt_strs("o");
|
||||||
let out_ip = match ips_parse(&out_ip) {
|
let out_ip = match ips_parse(&out_ip, false) {
|
||||||
Ok(out_ip) => { out_ip }
|
Ok(out_ip) => { out_ip }
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
print_usage(&program, opts);
|
print_usage(&program, opts);
|
||||||
|
|||||||
+4
-1
@@ -184,7 +184,10 @@ impl VntUtil {
|
|||||||
// NAT检测
|
// NAT检测
|
||||||
let nat_test = NatTest::new(config.nat_test_server.clone(), response.public_ip, response.public_port, local_ip, local_port);
|
let nat_test = NatTest::new(config.nat_test_server.clone(), response.public_ip, response.public_port, local_ip, local_port);
|
||||||
|
|
||||||
let out_ips = config.out_ips.iter().map(|(_, _, ip)| *ip).collect::<HashSet<Ipv4Addr>>();
|
let mut out_ips = config.out_ips.iter().map(|(_, _, ip)| *ip).collect::<HashSet<Ipv4Addr>>();
|
||||||
|
if out_ips.remove(&Ipv4Addr::UNSPECIFIED) {
|
||||||
|
out_ips.insert(local_ip);
|
||||||
|
}
|
||||||
let out_external_route = ExternalRoute::new(config.out_ips);
|
let out_external_route = ExternalRoute::new(config.out_ips);
|
||||||
let in_external_route = if config.in_ips.is_empty() {
|
let in_external_route = if config.in_ips.is_empty() {
|
||||||
None
|
None
|
||||||
|
|||||||
Reference in New Issue
Block a user