fmt
This commit is contained in:
@@ -1,22 +1,22 @@
|
|||||||
use std::{io, thread};
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use std::net::{Ipv4Addr, Shutdown, SocketAddr};
|
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
use std::net::UdpSocket as StdUdpSocket;
|
use std::net::UdpSocket as StdUdpSocket;
|
||||||
|
use std::net::{Ipv4Addr, Shutdown, SocketAddr};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
use std::{io, thread};
|
||||||
|
|
||||||
use crossbeam_utils::atomic::AtomicCell;
|
use crossbeam_utils::atomic::AtomicCell;
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use tokio::net::UdpSocket;
|
use tokio::net::UdpSocket;
|
||||||
use tokio::sync::watch::{channel, Receiver, Sender};
|
use tokio::sync::watch::{channel, Receiver, Sender};
|
||||||
|
|
||||||
use crate::channel::{Route, RouteKey, Status, TCP_ID, UDP_ID};
|
|
||||||
use crate::channel::punch::NatType;
|
use crate::channel::punch::NatType;
|
||||||
|
use crate::channel::{Route, RouteKey, Status, TCP_ID, UDP_ID};
|
||||||
use crate::core::status::VntWorker;
|
use crate::core::status::VntWorker;
|
||||||
use crate::handle::CurrentDeviceInfo;
|
|
||||||
use crate::handle::recv_handler::ChannelDataHandler;
|
use crate::handle::recv_handler::ChannelDataHandler;
|
||||||
|
use crate::handle::CurrentDeviceInfo;
|
||||||
|
|
||||||
pub struct ContextInner {
|
pub struct ContextInner {
|
||||||
//udp用于打洞、服务端通信(可选)
|
//udp用于打洞、服务端通信(可选)
|
||||||
|
|||||||
+2
-2
@@ -68,10 +68,10 @@ impl VntUtil {
|
|||||||
pub fn new(config: Config) -> io::Result<VntUtil> {
|
pub fn new(config: Config) -> io::Result<VntUtil> {
|
||||||
let address: SocketAddr = format!("[::]:{}", config.port).parse().unwrap();
|
let address: SocketAddr = format!("[::]:{}", config.port).parse().unwrap();
|
||||||
//单个udp用同步的性能更好,但是代理和多端口监听用异步更方便,这里将两者结合起来
|
//单个udp用同步的性能更好,但是代理和多端口监听用异步更方便,这里将两者结合起来
|
||||||
let socket = socket2::Socket::new(socket2::Domain::IPV6,socket2::Type::DGRAM,None)?;
|
let socket = socket2::Socket::new(socket2::Domain::IPV6, socket2::Type::DGRAM, None)?;
|
||||||
socket.set_only_v6(false)?;
|
socket.set_only_v6(false)?;
|
||||||
socket.bind(&address.into())?;
|
socket.bind(&address.into())?;
|
||||||
let main_channel:UdpSocket = socket.into();
|
let main_channel: UdpSocket = socket.into();
|
||||||
main_channel.set_write_timeout(Some(Duration::from_secs(5)))?;
|
main_channel.set_write_timeout(Some(Duration::from_secs(5)))?;
|
||||||
main_channel.set_read_timeout(Some(Duration::from_secs(2)))?;
|
main_channel.set_read_timeout(Some(Duration::from_secs(2)))?;
|
||||||
let server_cipher = if config.server_encrypt {
|
let server_cipher = if config.server_encrypt {
|
||||||
|
|||||||
Reference in New Issue
Block a user