//! Hooks supplied by an embedding VPN application.
//!
//! Android's `VpnService` must exempt the proxy's own carrier and direct
//! sockets from the VPN before they connect, otherwise those connections are
//! captured by the TUN device again. The Java/Kotlin bridge installs a
//! process-wide callback here and forwards each descriptor to
//! `VpnService.protect(int)`.
use std::io;
use std::os::fd::RawFd;
use std::sync::{Arc, RwLock};
use crate::error::{Error, Result};
/// Callback invoked for each externally routed socket before it is used.
///
/// It may be called concurrently from arbitrary runtime threads. The
/// descriptor is borrowed only for the duration of the call and must not be
/// retained or closed by the callback.
pub type SocketProtector = Arc io::Result<()> + Send + Sync + 'static>;
static SOCKET_PROTECTOR: RwLock