removed some output and ipv6
This commit is contained in:
parent
b5227a9887
commit
f58ead2d29
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"rust-analyzer.cargo.target": "x86_64-pc-windows-gnu",
|
// "rust-analyzer.cargo.target": "x86_64-pc-windows-gnu",
|
||||||
// "rust-analyzer.cargo.features": ["tun"]
|
// "rust-analyzer.cargo.features": ["tun"]
|
||||||
}
|
}
|
||||||
@ -3,7 +3,6 @@ mod local_udp_info;
|
|||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::fs::OpenOptions;
|
|
||||||
use std::process;
|
use std::process;
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
@ -412,6 +411,7 @@ fn main() {
|
|||||||
|
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
if should_daemonize {
|
if should_daemonize {
|
||||||
|
use std::fs::OpenOptions;
|
||||||
let out = OpenOptions::new()
|
let out = OpenOptions::new()
|
||||||
.create(true)
|
.create(true)
|
||||||
.truncate(true)
|
.truncate(true)
|
||||||
|
|||||||
@ -11,7 +11,7 @@ use crate::tcp::{init_quic_conn, send_stun_request};
|
|||||||
use crate::utils::{send_to_sock, CommandLine};
|
use crate::utils::{send_to_sock, CommandLine};
|
||||||
use crate::{ConnectionInfo};
|
use crate::{ConnectionInfo};
|
||||||
use bytes::BytesMut;
|
use bytes::BytesMut;
|
||||||
use etherparse::{PacketBuilder, SlicedPacket};
|
use etherparse::{PacketBuilder};
|
||||||
use sdlan_sn_rs::peer::{SdlanSock};
|
use sdlan_sn_rs::peer::{SdlanSock};
|
||||||
use sdlan_sn_rs::utils::{get_current_timestamp, ip_to_string, is_multi_broadcast};
|
use sdlan_sn_rs::utils::{get_current_timestamp, ip_to_string, is_multi_broadcast};
|
||||||
use sdlan_sn_rs::utils::{Mac, Result};
|
use sdlan_sn_rs::utils::{Mac, Result};
|
||||||
@ -231,8 +231,8 @@ async fn loop_tap(eee: &'static Node, cancel: CancellationToken) {
|
|||||||
if let Ok(mut dns) = simple_dns::Packet::parse(&data) {
|
if let Ok(mut dns) = simple_dns::Packet::parse(&data) {
|
||||||
let transaction_id = dns.id();
|
let transaction_id = dns.id();
|
||||||
if let Some((ip, port, origin_transaction_id)) = eee.dns_matcher.get_client_info(transaction_id) {
|
if let Some((ip, port, origin_transaction_id)) = eee.dns_matcher.get_client_info(transaction_id) {
|
||||||
warn!("got dns reply from global 223.5.5.5: {:?}, will send to {}:{}",
|
warn!("got dns reply from global 223.5.5.5, will send to {}:{}",
|
||||||
data, ip_to_string(&ip), port);
|
ip_to_string(&ip), port);
|
||||||
|
|
||||||
let dstmac = eee.device_config.get_mac();
|
let dstmac = eee.device_config.get_mac();
|
||||||
let srcmac = eee.device_config.dns_mac;
|
let srcmac = eee.device_config.dns_mac;
|
||||||
@ -245,7 +245,7 @@ async fn loop_tap(eee: &'static Node, cancel: CancellationToken) {
|
|||||||
let new_dns_resp = dns.build_bytes_vec().unwrap();
|
let new_dns_resp = dns.build_bytes_vec().unwrap();
|
||||||
let mut response_packet = Vec::with_capacity(builder.size(new_dns_resp.len()));
|
let mut response_packet = Vec::with_capacity(builder.size(new_dns_resp.len()));
|
||||||
if let Ok(_) = builder.write(&mut response_packet, &new_dns_resp) {
|
if let Ok(_) = builder.write(&mut response_packet, &new_dns_resp) {
|
||||||
warn!("will send to tun with packet: {:?}", response_packet);
|
// warn!("will send to tun with packet: {:?}", response_packet);
|
||||||
if let Err(_e) = eee.device.handle_packet_from_net(&response_packet).await {
|
if let Err(_e) = eee.device.handle_packet_from_net(&response_packet).await {
|
||||||
error!("failed to write dns packet to device");
|
error!("failed to write dns packet to device");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -69,6 +69,7 @@ pub async fn run_ipv6(edge: &'static Node, mut v6_may_change: Receiver<bool>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_current_ipv6() -> Option<Ipv6Addr> {
|
pub fn get_current_ipv6() -> Option<Ipv6Addr> {
|
||||||
|
return None;
|
||||||
let Ok(ips) = local_ip_address::list_afinet_netifas() else {
|
let Ok(ips) = local_ip_address::list_afinet_netifas() else {
|
||||||
error!("failed to get ip address");
|
error!("failed to get ip address");
|
||||||
return None;
|
return None;
|
||||||
|
|||||||
@ -518,12 +518,14 @@ impl TunTapPacketHandler for Iface {
|
|||||||
|
|
||||||
let size = data.len();
|
let size = data.len();
|
||||||
|
|
||||||
let Ok(encrypted) = edge.encryptor.load().encrypt(&data) else {
|
let encrypted = match edge.encryptor.load().encrypt(&data) {
|
||||||
// let Ok(encrypted) = edge.encryptor.read().unwrap().encrypt(&data) else {
|
Ok(data) => data,
|
||||||
// let Ok(encrypted) = aes_encrypt(encrypt_key, &data) else {
|
Err(e) => {
|
||||||
error!("failed to encrypt packet request");
|
error!("failed to encrypt packet request: {}", e.as_str());
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let data_bytes = Bytes::from(encrypted);
|
let data_bytes = Bytes::from(encrypted);
|
||||||
let data = SdlData {
|
let data = SdlData {
|
||||||
is_p2p: true,
|
is_p2p: true,
|
||||||
|
|||||||
@ -134,7 +134,7 @@ impl RuleCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn touch_packet(&self, info: FiveTuple) {
|
pub fn touch_packet(&self, info: FiveTuple) {
|
||||||
error!("touch a packet: {:?}", info);
|
// error!("touch a packet: {:?}", info);
|
||||||
self.session_table.add_session_info(info);
|
self.session_table.add_session_info(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user