fix some warning, and tested with mac
This commit is contained in:
parent
8db61a7bbb
commit
c2a3048427
@ -3,7 +3,8 @@ linker = "x86_64-linux-musl-gcc"
|
||||
|
||||
[target.aarch64-unknown-linux-gnu]
|
||||
linker = "aarch64-linux-gnu-gcc"
|
||||
ar = "aarch64-linux-gnu-ar"
|
||||
ar = "aarch64-linux-gnu-gcc"
|
||||
strip = { path = "aarch64-linux-gnu-strip" }
|
||||
# ranlib = "aarch64-linux-gnu-ranlib"
|
||||
|
||||
[target.x86_64-pc-windows-gnu]
|
||||
|
||||
16
Cargo.toml
16
Cargo.toml
@ -35,3 +35,19 @@ tun = []
|
||||
|
||||
[build-dependencies]
|
||||
cargo-deb = "3.6.2"
|
||||
|
||||
[package.metadata.deb]
|
||||
maintainer = "alex <asxalex@163.com>"
|
||||
copyright = "2025, alex"
|
||||
# license-file = ["MIT"]
|
||||
depends = "$auto"
|
||||
|
||||
## assets
|
||||
assets = [
|
||||
# executable
|
||||
["target/release/punchnet", "usr/local/punchnet/punchnet", "755"],
|
||||
# lib
|
||||
["libtuntap.so", "usr/lib/", "755"],
|
||||
]
|
||||
|
||||
maintainer-scripts = "debian"
|
||||
9
Makefile
9
Makefile
@ -28,4 +28,11 @@ libtun-so-aarch64:
|
||||
cd src/network && aarch64-linux-gnu-gcc -fPIC -shared -o libtuntap.so tuntap.c && cp libtuntap.so ../.. && cd -
|
||||
|
||||
pack:
|
||||
tar -czvf punchnet.tar.gz punchnet punchnet.service libtuntap.so install.sh
|
||||
tar -czvf punchnet.tar.gz punchnet punchnet.service libtuntap.so install.sh
|
||||
|
||||
deb: libtun-so
|
||||
RUSTFLAGS="-L ." cargo deb
|
||||
|
||||
deb-aarch64: libtun-so-aarch64
|
||||
RUSTFLAGS="-L ." cargo deb --target aarch64-unknown-linux-gnu
|
||||
|
||||
|
||||
9
debian/postinst
vendored
Normal file
9
debian/postinst
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
ln -sf /usr/local/punchnet/punchnet /usr/bin/punchnet
|
||||
|
||||
exit 0;
|
||||
9
debian/postrm
vendored
Normal file
9
debian/postrm
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
rm -rf /usr/lib/libswscale.so.5
|
||||
|
||||
exit 0;
|
||||
@ -1,4 +1,4 @@
|
||||
use std::{fs, os};
|
||||
use std::fs;
|
||||
|
||||
use once_cell::sync::OnceCell;
|
||||
use sdlan_sn_rs::utils::Mac;
|
||||
@ -31,7 +31,7 @@ pub fn get_base_dir() -> &'static str {
|
||||
pub fn set_base_dir(base_dir: &str) {
|
||||
fs::create_dir_all(base_dir).unwrap();
|
||||
let base = base_dir.trim_end_matches("/");
|
||||
if let Err(e) = BASE_DIR.set(base.to_owned()) {
|
||||
if let Err(_) = BASE_DIR.set(base.to_owned()) {
|
||||
println!("failed to set base dir");
|
||||
}
|
||||
}
|
||||
@ -1,3 +1,5 @@
|
||||
#![allow(unused)]
|
||||
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
sync::atomic::{AtomicU8, Ordering},
|
||||
@ -35,7 +37,6 @@ const ETHER_TYPE_IP6: u16 = 0x86dd;
|
||||
const ARP_MAX_AGE: u8 = 128;
|
||||
|
||||
const ARP_HWTYPE_ETH: u16 = 1;
|
||||
|
||||
pub const ARP_REQUEST: u16 = 1;
|
||||
pub const ARP_REPLY: u16 = 2;
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ use crate::ConnectionState;
|
||||
use sdlan_sn_rs::config::AF_INET;
|
||||
use sdlan_sn_rs::peer::{SdlanSock, V6Info};
|
||||
use sdlan_sn_rs::utils::{get_current_timestamp, ip_to_string, is_multi_broadcast, rsa_decrypt};
|
||||
use sdlan_sn_rs::utils::{Mac, Result, gen_rsa_keys};
|
||||
use sdlan_sn_rs::utils::{Mac, Result};
|
||||
use tokio::io::AsyncWriteExt;
|
||||
use tokio::sync::mpsc::{channel, Receiver, Sender};
|
||||
use tokio_util::sync::CancellationToken;
|
||||
@ -85,6 +85,7 @@ async fn handle_tcp_message(msg: SdlanTcp) {
|
||||
send_stun_request(edge).await;
|
||||
tokio::spawn(async {
|
||||
let nattype = edge.probe_nat_type().await;
|
||||
debug!("nat type is {:?}", nattype);
|
||||
// println!("nat type is: {:?}", nattype);
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
use std::sync::Mutex;
|
||||
use std::{
|
||||
net::{IpAddr, Ipv6Addr},
|
||||
time::Duration,
|
||||
@ -6,7 +5,7 @@ use std::{
|
||||
|
||||
use sdlan_sn_rs::{config::AF_INET6, peer::SdlanSock};
|
||||
use std::sync::Arc;
|
||||
use tokio::{net::UdpSocket, sync::mpsc::Receiver};
|
||||
use tokio::{sync::mpsc::Receiver};
|
||||
use tokio_util::sync::CancellationToken;
|
||||
use tracing::error;
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ use crate::pb::{
|
||||
encode_to_tcp_message, encode_to_udp_message, SdlEmpty, SdlStunProbe, SdlStunProbeReply,
|
||||
};
|
||||
use crate::tcp::{get_tcp_conn, NatType, PacketType, StunProbeAttr};
|
||||
use crate::utils::{PidRecorder, Socket};
|
||||
use crate::utils::{Socket};
|
||||
|
||||
use sdlan_sn_rs::peer::{IpSubnet, V6Info};
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ use crate::{
|
||||
};
|
||||
use etherparse::Ethernet2Header;
|
||||
use prost::Message;
|
||||
use sdlan_sn_rs::utils::{aes_encrypt, BROADCAST_MAC};
|
||||
use sdlan_sn_rs::utils::{BROADCAST_MAC};
|
||||
use sdlan_sn_rs::{
|
||||
config::{AF_INET, AF_INET6},
|
||||
peer::{is_sdlan_sock_equal, SdlanSock, V6Info},
|
||||
@ -809,7 +809,8 @@ async fn send_register(
|
||||
*/
|
||||
}
|
||||
|
||||
pub fn printHex(key: &[u8]) {
|
||||
#[allow(unused)]
|
||||
pub fn print_hex(key: &[u8]) {
|
||||
let mut value = vec![];
|
||||
for item in key {
|
||||
value.push(format!("0x{:02x}", item))
|
||||
@ -1193,6 +1194,7 @@ pub async fn update_supernode_reg(eee: &Node) {
|
||||
}
|
||||
*/
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn form_ethernet_packet(src_mac: Mac, dst_mac: Mac, data: &[u8]) -> Vec<u8> {
|
||||
let mut etherheader = Ethernet2Header::default();
|
||||
etherheader.destination = dst_mac;
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
use etherparse::ether_type::ARP;
|
||||
use etherparse::{Ethernet2Header, IpHeaders};
|
||||
use etherparse::{Ethernet2Header};
|
||||
use sdlan_sn_rs::config::SDLAN_DEFAULT_TTL;
|
||||
use sdlan_sn_rs::utils::{
|
||||
aes_encrypt, ip_to_string, is_ipv6_multicast, is_multi_broadcast, net_bit_len_to_mask,
|
||||
SDLanError, BROADCAST_MAC,
|
||||
aes_encrypt, ip_to_string, is_ipv6_multicast, net_bit_len_to_mask,
|
||||
SDLanError,
|
||||
};
|
||||
use std::ffi::CStr;
|
||||
use std::ffi::{c_char, c_int};
|
||||
@ -19,13 +18,9 @@ use std::process::Command;
|
||||
use tracing::{debug, error, info};
|
||||
|
||||
use crate::get_edge;
|
||||
use crate::network::{
|
||||
add_to_arp_wait_list, arp_arrived, generate_arp_request, send_arp_request, send_packet_to_net,
|
||||
ArpHdr, ArpRequestInfo, ArpResponse, ARP_REPLY, ARP_REQUEST,
|
||||
};
|
||||
use crate::network::send_packet_to_net;
|
||||
use crate::pb::{encode_to_udp_message, SdlData};
|
||||
use crate::tcp::PacketType;
|
||||
use crate::utils::{caculate_crc, mac_to_string};
|
||||
|
||||
use super::device::{DeviceConfig, Mode};
|
||||
use super::TunTapPacketHandler;
|
||||
@ -218,7 +213,7 @@ impl TunTapPacketHandler for Iface {
|
||||
|
||||
send_packet_to_net(edge, target, &msg, size as u64).await;
|
||||
}
|
||||
Err(e) => {
|
||||
Err(_) => {
|
||||
error!("failed to parse packet from device");
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
use dashmap::DashMap;
|
||||
use etherparse::Ethernet2Header;
|
||||
use once_cell::sync::OnceCell;
|
||||
use sdlan_sn_rs::{
|
||||
config::SDLAN_DEFAULT_TTL,
|
||||
|
||||
@ -8,7 +8,6 @@ use sdlan_sn_rs::utils::Mac;
|
||||
pub use socks::*;
|
||||
|
||||
mod pid_recorder;
|
||||
pub use pid_recorder::PidRecorder;
|
||||
|
||||
// pub const CRC_HASH: crc::Crc<u32> = crc::Crc::<u32>::new(&crc::CRC_32_XFER);
|
||||
|
||||
|
||||
@ -2,8 +2,9 @@ use std::{
|
||||
fs::{self, OpenOptions},
|
||||
io::Write,
|
||||
};
|
||||
use tracing::{debug, error};
|
||||
use tracing::{error};
|
||||
|
||||
#[allow(unused)]
|
||||
pub struct PidRecorder(String);
|
||||
|
||||
impl PidRecorder {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user