added hostname for dns, first step
This commit is contained in:
parent
9861c4e850
commit
41a21188bf
17
Cargo.lock
generated
17
Cargo.lock
generated
@ -1642,13 +1642,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e"
|
||||
|
||||
[[package]]
|
||||
name = "openssl-sys"
|
||||
version = "0.9.110"
|
||||
name = "openssl-src"
|
||||
version = "300.5.4+3.5.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0a9f0075ba3c21b09f8e8b2026584b1d18d49388648f2fbbf3c97ea8deced8e2"
|
||||
checksum = "a507b3792995dae9b0df8a1c1e3771e8418b7c2d9f0baeba32e6fe8b06c7cb72"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "openssl-sys"
|
||||
version = "0.9.111"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "82cab2d520aa75e3c58898289429321eb788c3106963d0dc886ec7a5f4adc321"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"openssl-src",
|
||||
"pkg-config",
|
||||
"vcpkg",
|
||||
]
|
||||
@ -1889,6 +1899,7 @@ dependencies = [
|
||||
"local-ip-address",
|
||||
"num_enum",
|
||||
"once_cell",
|
||||
"openssl-sys",
|
||||
"prost",
|
||||
"prost-build",
|
||||
"rand",
|
||||
|
||||
@ -13,6 +13,7 @@ futures-util = "0.3.30"
|
||||
local-ip-address = "0.6.1"
|
||||
num_enum = "0.7.2"
|
||||
once_cell = "1.19.0"
|
||||
openssl-sys = { version = "0.9.111", features = ["vendored"] }
|
||||
prost = "0.12.6"
|
||||
prost-build = "0.12.6"
|
||||
rand = "0.8.5"
|
||||
|
||||
@ -19,6 +19,7 @@ message SDLDevAddr {
|
||||
bytes mac = 2;
|
||||
uint32 net_addr = 3;
|
||||
uint32 net_bit_len = 4;
|
||||
string network_domain = 5;
|
||||
}
|
||||
|
||||
// tcp通讯消息
|
||||
@ -34,6 +35,7 @@ message SDLRegisterSuper {
|
||||
string pub_key = 5;
|
||||
string token = 6;
|
||||
string network_code = 7;
|
||||
string hostname = 8;
|
||||
}
|
||||
|
||||
message SDLRegisterSuperAck {
|
||||
|
||||
@ -7,6 +7,7 @@ use punchnet::CommandLine;
|
||||
use punchnet::CommandLineInput;
|
||||
use sdlan_sn_rs::log;
|
||||
|
||||
use sdlan_sn_rs::utils::gen_uuid_u64;
|
||||
use tracing::error;
|
||||
|
||||
use std::time::Duration;
|
||||
@ -50,6 +51,7 @@ async fn main() {
|
||||
},
|
||||
tx,
|
||||
&punchnet::get_install_channel(),
|
||||
Some(format!("{:08x}", gen_uuid_u64() as u32)),
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
|
||||
@ -44,6 +44,7 @@ pub async fn run_sdlan(
|
||||
sender: std::sync::mpsc::Sender<bool>,
|
||||
install_channel: &str,
|
||||
|
||||
hostname: Option<String>,
|
||||
connecting_chan: Option<Sender<ConnectionInfo>>, // start_stop_sender: Sender<String>,
|
||||
// start_stop_receiver: Receiver<String>,
|
||||
) -> Result<()> {
|
||||
@ -53,6 +54,8 @@ pub async fn run_sdlan(
|
||||
|
||||
init_arp();
|
||||
|
||||
let hostname = hostname.unwrap_or("".to_owned());
|
||||
|
||||
if let Err(e) = init_edge(
|
||||
&args.token,
|
||||
&args.network_code,
|
||||
@ -61,6 +64,7 @@ pub async fn run_sdlan(
|
||||
start_stop_sender,
|
||||
args.mtu,
|
||||
connecting_chan.clone(),
|
||||
hostname,
|
||||
)
|
||||
.await
|
||||
{
|
||||
|
||||
@ -63,6 +63,7 @@ async fn handle_tcp_message(msg: SdlanTcp) {
|
||||
let ip = ip_to_string(&dev.net_addr);
|
||||
// debug!("aes key is {:?}, ip is {}/{}", aes, ip, dev.net_bit_len,);
|
||||
println!("assigned ip: {}", ip);
|
||||
println!("network is: {}.{}", edge.hostname, dev.network_domain);
|
||||
edge.device_config
|
||||
.ip
|
||||
.net_addr
|
||||
@ -317,10 +318,12 @@ pub async fn async_main(
|
||||
net_addr: 0,
|
||||
network_id: 0,
|
||||
net_bit_len: 0,
|
||||
network_domain: "".to_owned(),
|
||||
}),
|
||||
pub_key: edge.rsa_pubkey.clone(),
|
||||
token,
|
||||
network_code: code,
|
||||
hostname: edge.hostname.clone(),
|
||||
};
|
||||
// debug!("send register super: {:?}", register_super);
|
||||
let packet_id = match pkt_id {
|
||||
|
||||
@ -38,6 +38,7 @@ pub async fn init_edge(
|
||||
start_stop: Sender<StartStopInfo>,
|
||||
mtu: u32,
|
||||
connecting_chan: Option<Sender<ConnectionInfo>>,
|
||||
hostname: String,
|
||||
) -> Result<()> {
|
||||
// gen public key
|
||||
let rsa_path = format!("{}/.client", get_base_dir());
|
||||
@ -81,6 +82,7 @@ pub async fn init_edge(
|
||||
start_stop,
|
||||
mtu,
|
||||
connecting_chan,
|
||||
hostname,
|
||||
);
|
||||
do_init_edge(edge)?;
|
||||
|
||||
@ -118,6 +120,8 @@ pub struct Node {
|
||||
packet_id: AtomicU32,
|
||||
|
||||
pub network_id: AtomicU32,
|
||||
|
||||
pub hostname: String,
|
||||
|
||||
pub tcp_pong: Arc<AtomicU64>,
|
||||
|
||||
@ -261,6 +265,7 @@ impl Node {
|
||||
start_stop: Sender<StartStopInfo>,
|
||||
mtu: u32,
|
||||
connecting_chan: Option<Sender<ConnectionInfo>>,
|
||||
hostname: String,
|
||||
) -> Self {
|
||||
let mode = if cfg!(not(feature = "tun")) {
|
||||
Mode::Tap
|
||||
@ -271,6 +276,7 @@ impl Node {
|
||||
Self {
|
||||
packet_id: AtomicU32::new(1),
|
||||
network_id: AtomicU32::new(0),
|
||||
hostname,
|
||||
_token: Mutex::new(token.to_owned()),
|
||||
network_code: Mutex::new(network_code.to_owned()),
|
||||
|
||||
|
||||
@ -29,6 +29,8 @@ pub struct SdlDevAddr {
|
||||
pub net_addr: u32,
|
||||
#[prost(uint32, tag = "4")]
|
||||
pub net_bit_len: u32,
|
||||
#[prost(string, tag = "5")]
|
||||
pub network_domain: ::prost::alloc::string::String,
|
||||
}
|
||||
/// tcp通讯消息
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
@ -51,6 +53,8 @@ pub struct SdlRegisterSuper {
|
||||
pub token: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "7")]
|
||||
pub network_code: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "8")]
|
||||
pub hostname: ::prost::alloc::string::String,
|
||||
}
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user