Documentation ¶
Index ¶
- Constants
- func CheckVersion() string
- func CopyAssets(assetDir string, force bool) error
- func DecodeJSONConfig(reader io.Reader) (*conf.Config, error)
- func GenerateVmessString(profile *Vmess) (string, error)
- func GetFreePort() (int, error)
- func InputPacket(data []byte)
- func QueryOutboundStats(tag string, direct string) int64
- func QueryStats(direct string) int64
- func SetLocalDNS(dns string)
- func SetNonblock(fd int, nonblocking bool) bool
- func StartTrojan(packetFlow PacketFlow, vpnService VpnService, logService LogService, ...) error
- func StartTrojanTunFd(tunFd int, vpnService VpnService, logService LogService, querySpeed QuerySpeed, ...) error
- func StartV2Ray(packetFlow PacketFlow, vpnService VpnService, logService LogService, ...) error
- func StartV2RayWithTunFd(tunFd int, vpnService VpnService, logService LogService, querySpeed QuerySpeed, ...) error
- func StartV2RayWithVmess(packetFlow PacketFlow, vpnService VpnService, logService LogService, ...) error
- func StopV2Ray()
- func TestConfig(ConfigureFileContent string, assetperfix string) error
- func TestConfigLatency(configBytes []byte, assetPath string) (int64, error)
- func TestTCPPing(host string, port int) (int64, error)
- func TestTrojanLatency(trojan *Trojan) (int64, error)
- func TestURLLatency(url string) (int64, error)
- func TestVmessLatency(profile *Vmess, port int) (int64, error)
- type LogService
- type PacketFlow
- type QuerySpeed
- type Trojan
- type Vmess
- type VmessOptions
- type VpnService
Constants ¶
const ( Version5 = 0x05 AuthMethodNotRequired = 0x00 SocksCmdConnect = 0x01 AddrTypeIPv4 = 0x01 AddrTypeFQDN = 0x03 AddrTypeIPv6 = 0x04 StatusSucceeded = 0x00 )
const ( VMESS protocol = protocol("vmess") VLESS protocol = protocol("vless") TROJAN protocol = protocol("trojan") )
Variables ¶
This section is empty.
Functions ¶
func CheckVersion ¶
func CheckVersion() string
func GenerateVmessString ¶
func GetFreePort ¶
func InputPacket ¶
func InputPacket(data []byte)
Write IP packets to the lwIP stack. Call this function in the main loop of the VpnService in Java/Kotlin, which should reads packets from the TUN fd.
func QueryOutboundStats ¶ added in v0.8.0
add in v2ray-core v4.26.0
func QueryStats ¶
~/go/src/v2ray.com/core/proxy/vmess/outbound/outbound.go
func SetLocalDNS ¶
func SetLocalDNS(dns string)
SetLocalDNS sets the DNS server that used by Go's default resolver, it accepts string in the form "host:port", e.g. 223.5.5.5:53
func SetNonblock ¶
SetNonblock puts the fd in blocking or non-blocking mode.
func StartTrojan ¶ added in v0.8.0
func StartTrojan( packetFlow PacketFlow, vpnService VpnService, logService LogService, trojan *Trojan, assetPath string) error
func StartTrojanTunFd ¶ added in v0.8.0
func StartTrojanTunFd( tunFd int, vpnService VpnService, logService LogService, querySpeed QuerySpeed, trojan *Trojan, assetPath string) error
func StartV2Ray ¶
func StartV2Ray( packetFlow PacketFlow, vpnService VpnService, logService LogService, configBytes []byte, assetPath string) error
StartV2Ray sets up lwIP stack, starts a V2Ray instance and registers the instance as the connection handler for tun2socks.
func StartV2RayWithTunFd ¶ added in v0.8.0
func StartV2RayWithTunFd( tunFd int, vpnService VpnService, logService LogService, querySpeed QuerySpeed, profile *Vmess, assetPath string) error
TODO: support ipv6
func StartV2RayWithVmess ¶
func StartV2RayWithVmess( packetFlow PacketFlow, vpnService VpnService, logService LogService, profile *Vmess, assetPath string) error
StartV2Ray sets up lwIP stack, starts a V2Ray instance and registers the instance as the connection handler for tun2socks.
func TestConfig ¶
func TestConfigLatency ¶
func TestTrojanLatency ¶ added in v0.8.0
func TestURLLatency ¶
Types ¶
type LogService ¶
type PacketFlow ¶
type PacketFlow interface { // WritePacket should writes packets to the TUN fd. WritePacket(packet []byte) }
PacketFlow should be implemented in Java/Kotlin.
type QuerySpeed ¶ added in v0.8.0
type Trojan ¶ added in v0.8.0
type Vmess ¶
type Vmess struct { Host string Path string TLS string Add string Port int Aid int Net string ID string Type string // headerType Security string // vnext.Security Protocol protocol VmessOptions Trojan *Trojan }
constructor export New
func ConvertJSONToVmess ¶
type VmessOptions ¶ added in v0.8.0
type VpnService ¶
type VpnService interface { // Protect is just a proxy to the VpnService.protect() method. // See also: https://developer.android.com/reference/android/net/VpnService.html#protect(int) Protect(fd int) bool }
VpnService should be implemented in Java/Kotlin.