added loop socket multicast
This commit is contained in:
parent
5b32c51936
commit
49d8ca9375
@ -312,10 +312,14 @@ pub async fn async_main(
|
|||||||
async fn run_edge_loop(eee: &'static Node, cancel: CancellationToken) {
|
async fn run_edge_loop(eee: &'static Node, cancel: CancellationToken) {
|
||||||
ping_to_sn().await;
|
ping_to_sn().await;
|
||||||
{
|
{
|
||||||
|
let cancel2 = cancel.clone();
|
||||||
let cancel = cancel.clone();
|
let cancel = cancel.clone();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
loop_socket_v4(eee, &eee.udp_sock_v4, cancel).await;
|
loop_socket_v4(eee, &eee.udp_sock_v4, cancel).await;
|
||||||
});
|
});
|
||||||
|
tokio::spawn(async move {
|
||||||
|
loop_socket_v4(eee, &eee.udp_sock_multicast, cancel2).await;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@ -51,8 +51,9 @@ pub async fn init_edge(
|
|||||||
// let edge_uuid = create_or_load_uuid("")?;
|
// let edge_uuid = create_or_load_uuid("")?;
|
||||||
//let node_conf = parse_config(edge_uuid, &args).await?;
|
//let node_conf = parse_config(edge_uuid, &args).await?;
|
||||||
|
|
||||||
let sock_v4 = Socket::build(0, true, true, tos).await?;
|
let sock_v4 = Socket::build(0, true, false, tos).await?;
|
||||||
|
|
||||||
|
let sock_multicast = Socket::build(MULTICAST_PORT, true, true, 0).await?;
|
||||||
// allow multicast
|
// allow multicast
|
||||||
|
|
||||||
// TODO: set the sn's tcp socket
|
// TODO: set the sn's tcp socket
|
||||||
@ -62,6 +63,7 @@ pub async fn init_edge(
|
|||||||
pubkey,
|
pubkey,
|
||||||
node_conf,
|
node_conf,
|
||||||
sock_v4,
|
sock_v4,
|
||||||
|
sock_multicast,
|
||||||
token,
|
token,
|
||||||
privatekey,
|
privatekey,
|
||||||
tcp_pong.clone(),
|
tcp_pong.clone(),
|
||||||
@ -119,6 +121,7 @@ pub struct Node {
|
|||||||
pub known_peers: PeerMap,
|
pub known_peers: PeerMap,
|
||||||
|
|
||||||
// pub tcp_sock_v4: TCPSocket,
|
// pub tcp_sock_v4: TCPSocket,
|
||||||
|
pub udp_sock_multicast: Socket,
|
||||||
pub udp_sock_v4: Socket,
|
pub udp_sock_v4: Socket,
|
||||||
pub outer_ip_v4: AtomicU32,
|
pub outer_ip_v4: AtomicU32,
|
||||||
pub udp_sock_v6: RwLock<Arc<Option<Socket>>>,
|
pub udp_sock_v6: RwLock<Arc<Option<Socket>>>,
|
||||||
@ -158,6 +161,7 @@ impl Node {
|
|||||||
pubkey: String,
|
pubkey: String,
|
||||||
config: NodeConfig,
|
config: NodeConfig,
|
||||||
sock: Socket,
|
sock: Socket,
|
||||||
|
multicast_sock: Socket,
|
||||||
// tcpsock: TCPSocket,
|
// tcpsock: TCPSocket,
|
||||||
token: &str,
|
token: &str,
|
||||||
private: RsaPrivateKey,
|
private: RsaPrivateKey,
|
||||||
@ -190,6 +194,7 @@ impl Node {
|
|||||||
known_peers: PeerMap::new(),
|
known_peers: PeerMap::new(),
|
||||||
|
|
||||||
// tcp_sock_v4: tcpsock,
|
// tcp_sock_v4: tcpsock,
|
||||||
|
udp_sock_multicast: multicast_sock,
|
||||||
udp_sock_v4: sock,
|
udp_sock_v4: sock,
|
||||||
outer_ip_v4: AtomicU32::new(0),
|
outer_ip_v4: AtomicU32::new(0),
|
||||||
udp_sock_v6: RwLock::new(Arc::new(None)),
|
udp_sock_v6: RwLock::new(Arc::new(None)),
|
||||||
@ -467,7 +472,7 @@ impl NodeStats {
|
|||||||
|
|
||||||
use sdlan_sn_rs::peer::SdlanSock;
|
use sdlan_sn_rs::peer::SdlanSock;
|
||||||
|
|
||||||
use crate::config::{self, REGISTER_INTERVAL};
|
use crate::config::{self, MULTICAST_PORT, REGISTER_INTERVAL};
|
||||||
pub struct NodeConfig {
|
pub struct NodeConfig {
|
||||||
// node name
|
// node name
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user