Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultRoutesToTUN will route all system traffic through the TUN. DefaultRoutesToTUN = []*route.Addr{ route.MustParseAddr("0.0.0.0/1"), route.MustParseAddr("128.0.0.0/1"), } )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the actual VPN cl. It manages connections, routing and tunneling of the requests. It is safe to make a Client connection as it does not change the default system routing and just adds on existing infrastructure.
func NewClient ¶
NewClient initializes default Client with default proxy address. If you want more options use Client struct.
func NewClientWithOpts ¶
NewClientWithOpts initializes Client with specified Config. It is recommended to just use NewClient().
func (*Client) BytesWritten ¶
BytesWritten returns number of bytes written to TUN device.
func (*Client) Connect ¶
Connect creates a global tunnel and routes all incoming connections (or traffic specified in Config.RoutesToTUN) to the VPN server via newly created defaultInboundProxy.
func (*Client) Disconnect ¶
Disconnect stops all listeners and cleans up route for XRay server.
It will block till all resources are done processing or context is cancelled (method also enforces timeout of disconnectTimeout)
func (*Client) GatewayIP ¶
GatewayIP returns gateway IP used to route outbound traffic through. It is used to route packets destined to XRay remote server.
func (*Client) InboundProxy ¶
InboundProxy returns proxy address initialized by XRay core. Traffic from TUN device is routed to this proxy.
func (*Client) TUNAddress ¶
TUNAddress returns address the TUN device is set up on. Traffic is routed to this TUN device.
type Config ¶
type Config struct { // GatewayIP to direct outbound traffic. Must be able to reach remote XRay server. // (default: will be dynamically detected from your default gateway). // // Client will determine the system gateway IP automatically, // and you don't have to set this field explicitly. GatewayIP *net.IP // Socks proxy address on which XRay creates inbound proxy (default: 127.0.0.1:10808). InboundProxy *Proxy // TUN device address (default: 192.18.0.1). TUNAddress *net.IPNet // List of routes to be pointed to TUN device (default: DefaultRoutesToTUN). // // One exception is explicitly added for XRay remote server IP and can not be altered. RoutesToTUN []*route.Addr // Whether to allow self-signed certificates or not. TLSAllowInsecure bool // Pass logger with debug level to observe debug logs (default: slog.TextHandler). Logger *slog.Logger // XRayLogType is used to redefine xray core log type (default: LogType_None). XRayLogType xapplog.LogType }
Config serves configuration for new Client. Empty fields will be set up with defaults values.
It is advised to not configure the cl yourself, please use NewClient() with default config values, normally you don't have to set these fields yourself.