pub async fn connect_udp_remote(
        context: SharedContext,
        svr_cfg: &ServerConfig,
        ns: Address,
        connect_opts: &ConnectOpts,
        flow_stat: Arc<FlowStat>,
    ) -> io::Result<Self> {
        let socket = ProxySocket::connect_with_opts(context.clone(), svr_cfg, connect_opts).await?;
        let socket = MonProxySocket::from_socket(socket, flow_stat.clone());
        let mut control = UdpSocketControlData::default();
        control.client_session_id = generate_client_session_id();
        control.packet_id = 0; // AEAD-2022 Packet ID starts from 1
        Ok(Self::UdpRemote {
            socket,
            ns,
            control,
            // NOTE: expiry duration should be configurable. But the Client is held by DnsClientCache, which expires very quickly.
            server_windows: LruCache::with_expiry_duration(DEFAULT_UDP_EXPIRY_DURATION),
        })
    }
Connect to remote DNS server through proxy in UDP
crates/shadowsocks-service/src/local/dns/upstream.rs