mirror of
https://mirror.suhoan.cn/https://github.com/EasyTier/EasyTier.git
synced 2025-12-14 05:37:23 +08:00
fix rpc packet route before first route info exchange (#516)
* fix rpc packet route before first route info exchange * fix install script * update config server help
This commit is contained in:
@@ -26,7 +26,7 @@ use crate::{
|
||||
},
|
||||
};
|
||||
|
||||
pub(crate) const HOLE_PUNCH_PACKET_BODY_LEN: u16 = 32;
|
||||
pub(crate) const HOLE_PUNCH_PACKET_BODY_LEN: u16 = 16;
|
||||
|
||||
fn generate_shuffled_port_vec() -> Vec<u16> {
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
@@ -783,12 +783,9 @@ async fn run_main(cli: Cli) -> anyhow::Result<()> {
|
||||
let config_server_url_s = cli.config_server.clone().unwrap();
|
||||
let config_server_url = match url::Url::parse(&config_server_url_s) {
|
||||
Ok(u) => u,
|
||||
Err(_) => format!(
|
||||
"udp://config-server.easytier.top:22020/{}",
|
||||
config_server_url_s
|
||||
)
|
||||
.parse()
|
||||
.unwrap(),
|
||||
Err(_) => format!("udp://easytier.cn:22020/{}", config_server_url_s)
|
||||
.parse()
|
||||
.unwrap(),
|
||||
};
|
||||
|
||||
let mut c_url = config_server_url.clone();
|
||||
|
||||
@@ -79,7 +79,12 @@ impl PeerRpcManagerTransport for RpcTransport {
|
||||
|
||||
async fn send(&self, mut msg: ZCPacket, dst_peer_id: PeerId) -> Result<(), Error> {
|
||||
let peers = self.peers.upgrade().ok_or(Error::Unknown)?;
|
||||
if !peers.need_relay_by_foreign_network(dst_peer_id).await? {
|
||||
// NOTE: if route info is not exchanged, this will return error. treat it as need relay
|
||||
if !peers
|
||||
.need_relay_by_foreign_network(dst_peer_id)
|
||||
.await
|
||||
.unwrap_or(true)
|
||||
{
|
||||
self.encryptor
|
||||
.encrypt(&mut msg)
|
||||
.with_context(|| "encrypt failed")?;
|
||||
@@ -706,6 +711,9 @@ impl PeerManager {
|
||||
);
|
||||
Err(Error::RouteError(None))
|
||||
}
|
||||
} else if foreign_network_client.has_next_hop(dst_peer_id) {
|
||||
// check foreign network again. so in happy path we can avoid extra check
|
||||
foreign_network_client.send_msg(msg, dst_peer_id).await
|
||||
} else {
|
||||
tracing::debug!(?dst_peer_id, "no gateway for peer");
|
||||
Err(Error::RouteError(None))
|
||||
|
||||
@@ -1395,7 +1395,7 @@ impl PeerRouteServiceImpl {
|
||||
let my_peer_id = self.my_peer_id;
|
||||
|
||||
let (peer_infos, conn_bitmap, foreign_network) = self.build_sync_request(&session);
|
||||
tracing::info!(?foreign_network, "building sync_route request. my_id {:?}, pper_id: {:?}, peer_infos: {:?}, conn_bitmap: {:?}, synced_route_info: {:?} session: {:?}",
|
||||
tracing::trace!(?foreign_network, "building sync_route request. my_id {:?}, pper_id: {:?}, peer_infos: {:?}, conn_bitmap: {:?}, synced_route_info: {:?} session: {:?}",
|
||||
my_peer_id, dst_peer_id, peer_infos, conn_bitmap, self.synced_route_info, session);
|
||||
|
||||
if peer_infos.is_none()
|
||||
@@ -1683,7 +1683,7 @@ impl RouteSessionManager {
|
||||
.map(|x| *x)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
tracing::debug!(?service_impl.my_peer_id, ?peers, ?session_peers, ?initiator_candidates, "maintain_sessions begin");
|
||||
tracing::trace!(?service_impl.my_peer_id, ?peers, ?session_peers, ?initiator_candidates, "maintain_sessions begin");
|
||||
|
||||
if initiator_candidates.is_empty() {
|
||||
next_sleep_ms = 1000;
|
||||
|
||||
@@ -658,7 +658,7 @@ impl UdpTunnelConnector {
|
||||
return;
|
||||
}
|
||||
_ = udp_recv_from_socket_forward_task(socket_clone,false, |zc_packet, addr| {
|
||||
tracing::debug!(?addr, "connector udp forward task done");
|
||||
tracing::trace!(?addr, "connector udp forward task done");
|
||||
if let Err(e) = udp_conn.handle_packet_from_remote(zc_packet) {
|
||||
tracing::trace!(?e, ?addr, "udp forward packet error");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user