mobile

package
v0.0.0-...-d4fcde0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package mobile is the gomobile-compatible IPv4 tunnel client. Operating-system VPN services own routes and DNS; this package owns transport.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is single-use. Create a new instance after Close or a terminal error. All exported methods are safe to call from different native threads.

func NewClient

func NewClient(configJSON string, protector SocketProtector) (*Client, error)

func (*Client) AttachFD

func (c *Client) AttachFD(fd int) error

func (*Client) Close

func (c *Client) Close() error

func (*Client) Connect

func (c *Client) Connect() (string, error)

Connect authenticates before the OS installs VPN routes. The result is JSON containing the negotiated addresses, endpoint_ipv4 and MTU.

func (*Client) ReadPacket

func (c *Client) ReadPacket() ([]byte, error)

ReadPacket blocks until one raw IPv4 packet arrives or Close is called. Use a background thread, never the UI thread.

func (*Client) Start

func (c *Client) Start() error

Start begins relaying after the caller has configured the native VPN.

func (*Client) Status

func (c *Client) Status() string

func (*Client) WritePacket

func (c *Client) WritePacket(packet []byte) error

WritePacket copies one raw IPv4 packet from the OS. Under congestion packets are dropped instead of blocking the native VPN callback.

type SocketProtector

type SocketProtector interface {
	ProtectSocket(fd int) bool
}

SocketProtector must protect the fd synchronously before returning. Android passes VpnService.protect; iOS passes nil (provider sockets bypass VPN).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL