Documentation
¶
Overview ¶
Package inbound is the loft client listener: SOCKS5, userspace TUN (ICMP/UDP/TCP), Darwin/Linux DNS and routes, optional overlay IPv6.
Index ¶
- func AcceptTUNFD(ln net.Listener) (int, string, error)
- func JoinDNS(ips []net.IP) string
- func ListenSOCKS5(addr string, d transport.Dialer) (net.Listener, error)
- func ListenTUNSock(path string) (net.Listener, error)
- func OverlayCIDR(overlayIP, tunAddr string) string
- func PacketTUNFromFD(fd int, name string) io.ReadWriteCloser
- func ParseDNSList(s string) []net.IP
- func ResolveDNS(ipcp []net.IP, peer net.IP, extra []net.IP, replace bool) []net.IP
- func SocksOff(addr string) bool
- func WrapL3(d transport.Dialer) (transport.Dialer, error)
- type Device
- func AttachTUN(device, cidr string, d transport.Dialer) (*Device, error)
- func StartStack(rw io.ReadWriteCloser, name string, d transport.Dialer, overlayIP string) (*Device, error)
- func StartTUN(device, cidr string, killSwitch bool, d transport.Dialer, exclude []string) (*Device, error)
- func StartTUNFromFD(fd int, name string, d transport.Dialer) (*Device, error)
- type L3Net
- func (n *L3Net) AttachTUN(tun io.ReadWriteCloser)
- func (n *L3Net) Close() error
- func (n *L3Net) ConnBytes() (uint64, uint64)
- func (n *L3Net) Done() <-chan struct{}
- func (n *L3Net) ListenUDP() (net.PacketConn, error)
- func (n *L3Net) LookupIP4(host string) (net.IP, error)
- func (n *L3Net) Open(target string) (net.Conn, error)
- func (n *L3Net) Session() *mux.Session
- func (n *L3Net) Swap(d transport.Dialer, pump transport.IPPump)
- type SSTPNet
- func (n *SSTPNet) ApplyDNS(extra []net.IP, replace bool)
- func (n *SSTPNet) AttachTUN(tun io.ReadWriteCloser)
- func (n *SSTPNet) Bytes() (up, down uint64)
- func (n *SSTPNet) Close() error
- func (n *SSTPNet) DNS() []net.IP
- func (n *SSTPNet) DialUDP(addr string) (net.Conn, error)
- func (n *SSTPNet) Done() <-chan struct{}
- func (n *SSTPNet) ListenUDP() (net.PacketConn, error)
- func (n *SSTPNet) LookupIP4(host string) (net.IP, error)
- func (n *SSTPNet) Open(target string) (net.Conn, error)
- func (n *SSTPNet) OverlayIP() net.IP
- func (n *SSTPNet) Session() *mux.Session
- func (n *SSTPNet) SetLog(fn func(string, ...any))
- func (n *SSTPNet) SetTap(fn func([]byte))
- type SocksGate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AcceptTUNFD ¶
AcceptTUNFD reads one SCM_RIGHTS fd and the utun name from ln.
func ListenSOCKS5 ¶
ListenSOCKS5 accepts SOCKS5 CONNECT and UDP ASSOCIATE on addr.
func ListenTUNSock ¶
ListenTUNSock binds a unix socket at path (0600) for loft-priv to send a utun fd.
func OverlayCIDR ¶
OverlayCIDR is Status.IP with the prefix from tun_addr (default /24).
func PacketTUNFromFD ¶
func PacketTUNFromFD(fd int, name string) io.ReadWriteCloser
PacketTUNFromFD is a utun fd as IP ReadWriteCloser (no mux stack). For SSTP.
func ParseDNSList ¶
ParseDNSList reads IPv4 addresses separated by comma, space, or semicolon.
func ResolveDNS ¶
ResolveDNS picks SSTP resolvers the way Windows RAS does: IPCP DNS if the server sent any, else the PPP gateway. extra appends to that list; extra with replace uses only extra.
Types ¶
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device is a live TUN. Attach hooks ICMP on each new mux session (metro).
func AttachTUN ¶ added in v1.0.15
AttachTUN opens an existing TUN by name and runs the userspace stack on it. The kernel address, MTU, DNS, and routes stay with the caller (ConnMan, NetworkManager). Same packet path as StartTUN.
func StartStack ¶
func StartStack(rw io.ReadWriteCloser, name string, d transport.Dialer, overlayIP string) (*Device, error)
StartStack binds an IP packet pipe. Mux fronts get gVisor; l3 splices IP. overlayIP is Status (loft) or the synthetic VLESS address. No OS routes.
func StartTUN ¶
func StartTUN(device, cidr string, killSwitch bool, d transport.Dialer, exclude []string) (*Device, error)
StartTUN brings up a real utun/tun, userspace stack, and optional kill-switch.
func StartTUNFromFD ¶
StartTUNFromFD wraps an already-configured utun fd in the userspace stack.
type L3Net ¶ added in v1.0.25
type L3Net struct {
// contains filtered or unexported fields
}
L3Net is a Dialer that opens TCP/UDP on the L3 overlay IP.
func NewL3Net ¶ added in v1.0.25
NewL3Net binds a gVisor IPv4 stack to pump and starts the packet pump.
func (*L3Net) AttachTUN ¶ added in v1.0.25
func (n *L3Net) AttachTUN(tun io.ReadWriteCloser)
AttachTUN splices kernel utun packets with the L3 pump.
func (*L3Net) ListenUDP ¶ added in v1.0.25
func (n *L3Net) ListenUDP() (net.PacketConn, error)
ListenUDP binds one unconnected UDP socket on the overlay.
func (*L3Net) LookupIP4 ¶ added in v1.0.25
LookupIP4 resolves host through the host resolver (debug path).
type SSTPNet ¶
type SSTPNet struct {
// contains filtered or unexported fields
}
SSTPNet is a transport.Dialer that opens TCP/UDP on the SSTP overlay IP.
func NewSSTPNet ¶
NewSSTPNet binds a gVisor IPv4 stack to sess and starts the packet pump.
func (*SSTPNet) ApplyDNS ¶
ApplyDNS sets resolvers: IPCP, else the PPP peer, plus extra. replace with a non-empty extra list skips IPCP and the gateway.
func (*SSTPNet) AttachTUN ¶
func (n *SSTPNet) AttachTUN(tun io.ReadWriteCloser)
AttachTUN splices kernel utun packets with the SSTP session (L3).
func (*SSTPNet) DialUDP ¶
DialUDP opens one connected UDP socket on the SSTP overlay (SOCKS UDP ASSOCIATE).
func (*SSTPNet) ListenUDP ¶
func (n *SSTPNet) ListenUDP() (net.PacketConn, error)
ListenUDP binds one unconnected UDP socket on the overlay (SOCKS UDP ASSOCIATE).
type SocksGate ¶ added in v1.0.4
type SocksGate struct {
// contains filtered or unexported fields
}
SocksGate holds the current SOCKS5 listener. Set replaces it; a bind error leaves the previous listener running.
func NewSocksGate ¶ added in v1.0.4
NewSocksGate serves SOCKS5 through d. No listen until Set.