mirror of
https://github.com/EasyTier/EasyTier.git
synced 2024-11-15 19:22:30 +08:00
some wg & cli & README improve (#47)
1. fix vpn client cannot access local node 2. fix wg client config no allowedip field 3. some cli & README improve
This commit is contained in:
parent
e4be86cf92
commit
892b06dfd3
|
@ -158,13 +158,13 @@
|
|||
Taking two nodes as an example, Node A executes:
|
||||
|
||||
```sh
|
||||
sudo easytier-core -i 10.144.144.1 --network-name abc --network-secret abc -e 'tcp://easytier.public.kkrainbow.top:11010'
|
||||
sudo easytier-core -i 10.144.144.1 --network-name abc --network-secret abc -e tcp://easytier.public.kkrainbow.top:11010
|
||||
```
|
||||
|
||||
Node B executes
|
||||
|
||||
```sh
|
||||
sudo easytier-core --ipv4 10.144.144.2 --network-name abc --network-secret abc -e 'tcp://easytier.public.kkrainbow.top:11010'
|
||||
sudo easytier-core --ipv4 10.144.144.2 --network-name abc --network-secret abc -e tcp://easytier.public.kkrainbow.top:11010
|
||||
```
|
||||
|
||||
After the command is successfully executed, Node A can access Node B through the virtual IP 10.144.144.2.
|
||||
|
|
|
@ -158,13 +158,13 @@ EasyTier 支持共享公网节点进行组网。目前已部署共享的公网
|
|||
以双节点为例,节点 A 执行:
|
||||
|
||||
```sh
|
||||
sudo easytier-core -i 10.144.144.1 --network-name abc --network-secret abc -e 'tcp://easytier.public.kkrainbow.top:11010'
|
||||
sudo easytier-core -i 10.144.144.1 --network-name abc --network-secret abc -e tcp://easytier.public.kkrainbow.top:11010
|
||||
```
|
||||
|
||||
节点 B 执行
|
||||
|
||||
```sh
|
||||
sudo easytier-core --ipv4 10.144.144.2 --network-name abc --network-secret abc -e 'tcp://easytier.public.kkrainbow.top:11010'
|
||||
sudo easytier-core --ipv4 10.144.144.2 --network-name abc --network-secret abc -e tcp://easytier.public.kkrainbow.top:11010
|
||||
```
|
||||
|
||||
命令执行成功后,节点 A 即可通过虚拟 IP 10.144.144.2 访问节点 B。
|
||||
|
|
|
@ -269,9 +269,9 @@ impl CommandHandler {
|
|||
struct PeerTableItem {
|
||||
ipv4: String,
|
||||
hostname: String,
|
||||
cost: i32,
|
||||
lat_ms: f64,
|
||||
loss_rate: f64,
|
||||
cost: String,
|
||||
lat_ms: String,
|
||||
loss_rate: String,
|
||||
rx_bytes: String,
|
||||
tx_bytes: String,
|
||||
tunnel_proto: String,
|
||||
|
@ -279,14 +279,26 @@ impl CommandHandler {
|
|||
id: String,
|
||||
}
|
||||
|
||||
fn cost_to_str(cost: i32) -> String {
|
||||
if cost == 1 {
|
||||
"p2p".to_string()
|
||||
} else {
|
||||
format!("relay({})", cost)
|
||||
}
|
||||
}
|
||||
|
||||
fn float_to_str(f: f64, precision: usize) -> String {
|
||||
format!("{:.1$}", f, precision)
|
||||
}
|
||||
|
||||
impl From<PeerRoutePair> for PeerTableItem {
|
||||
fn from(p: PeerRoutePair) -> Self {
|
||||
PeerTableItem {
|
||||
ipv4: p.route.ipv4_addr.clone(),
|
||||
hostname: p.route.hostname.clone(),
|
||||
cost: p.route.cost,
|
||||
lat_ms: p.get_latency_ms().unwrap_or(0.0),
|
||||
loss_rate: p.get_loss_rate().unwrap_or(0.0),
|
||||
cost: cost_to_str(p.route.cost),
|
||||
lat_ms: float_to_str(p.get_latency_ms().unwrap_or(0.0), 3),
|
||||
loss_rate: float_to_str(p.get_loss_rate().unwrap_or(0.0), 3),
|
||||
rx_bytes: format_size(p.get_rx_bytes().unwrap_or(0), humansize::DECIMAL),
|
||||
tx_bytes: format_size(p.get_tx_bytes().unwrap_or(0), humansize::DECIMAL),
|
||||
tunnel_proto: p.get_conn_protos().unwrap_or(vec![]).join(",").to_string(),
|
||||
|
|
|
@ -403,6 +403,7 @@ impl Instance {
|
|||
|
||||
fn run_proxy_cidrs_route_updater(&mut self) {
|
||||
let peer_mgr = self.peer_manager.clone();
|
||||
let global_ctx = self.global_ctx.clone();
|
||||
let net_ns = self.global_ctx.net_ns.clone();
|
||||
let nic = self.virtual_nic.as_ref().unwrap().clone();
|
||||
|
||||
|
@ -419,6 +420,10 @@ impl Instance {
|
|||
proxy_cidrs.push(cidr);
|
||||
}
|
||||
}
|
||||
// add vpn portal cidr to proxy_cidrs
|
||||
if let Some(vpn_cfg) = global_ctx.config.get_vpn_portal_config() {
|
||||
proxy_cidrs.push(vpn_cfg.client_cidr);
|
||||
}
|
||||
|
||||
// if route is in cur_proxy_cidrs but not in proxy_cidrs, delete it.
|
||||
for cidr in cur_proxy_cidrs.iter() {
|
||||
|
|
|
@ -232,7 +232,11 @@ impl VpnPortal for WireGuard {
|
|||
.map(|x| x.proxy_cidrs.iter().map(String::to_string))
|
||||
.flatten()
|
||||
.collect::<Vec<_>>();
|
||||
for ipv4 in routes.iter().map(|x| &x.ipv4_addr) {
|
||||
for ipv4 in routes
|
||||
.iter()
|
||||
.map(|x| x.ipv4_addr.clone())
|
||||
.chain(global_ctx.get_ipv4().iter().map(|x| x.to_string()))
|
||||
{
|
||||
let Ok(ipv4) = ipv4.parse() else {
|
||||
continue;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user