tun2socks

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2019 License: MIT Imports: 16 Imported by: 0

README

go-tun2socks-android

Demo for building and using go-tun2socks on Android.

Including V2Ray features

Refer here for details, specifically, features to include are defining in these two files.

Integrating into your Android project

Checkout this repo for a demo: https://github.com/eycorsican/kitsunebi-android

Prerequisites

Build

go get -d ./...
make

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 SetLocalDNS added in v0.3.0

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

func SetNonblock(fd int, nonblocking bool) bool

SetNonblock puts the fd in blocking or non-blocking mode.

func StartV2Ray

func StartV2Ray(packetFlow PacketFlow, vpnService VpnService, dbService DBService, configBytes []byte, assetPath, proxyLogDBPath string)

StartV2Ray sets up lwIP stack, starts a V2Ray instance and registers the instance as the connection handler for tun2socks.

func StopV2Ray

func StopV2Ray()

Types

type DBService added in v0.4.0

type DBService interface {
	InsertProxyLog(target, tag string, startTime, endTime int64, uploadBytes, downloadBytes int32, recordType, dnsQueryType int32, dnsRequest, dnsResponse string, dnsNumIPs int32)
}

type PacketFlow

type PacketFlow interface {
	// WritePacket should writes packets to the TUN fd.
	WritePacket(packet []byte)
}

PacketFlow should be implemented in Java/Kotlin.

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.

Jump to

Keyboard shortcuts

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