protector

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2017 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package protected is used for creating "protected" connections that bypass Android's VpnService

Index

Constants

View Source
const (
	SO_MARK = 0x24
)

Variables

View Source
var SocketMark int

Functions

func Configure

func Configure(protect Protect, dnsServer string)

func Dial

func Dial(network, addr string, timeout time.Duration) (net.Conn, error)

func DialContext added in v0.26.4

func DialContext(ctx context.Context, network, addr string) (net.Conn, error)

Dial creates a new protected connection, it assumes that the address has already been resolved to an IPv4 address.

  • syscall API calls are used to create and bind to the specified system device (this is primarily used for Android VpnService routing functionality)

func DialUDP added in v0.27.2

func DialUDP(network string, laddr, raddr *net.UDPAddr) (net.PacketConn, error)

func ListenUDP added in v0.27.2

func ListenUDP(network string, laddr *net.UDPAddr) (net.PacketConn, error)

func Resolve

func Resolve(network string, addr string) (*net.TCPAddr, error)

Resolve resolves the given address using a DNS lookup on a UDP socket protected by the currnet Protector.

func SetDNSServer added in v0.26.0

func SetDNSServer(server string)

func SplitHostPort

func SplitHostPort(addr string) (string, int, error)

wrapper around net.SplitHostPort that also converts uses strconv to convert the port to an int

Types

type DNSRecord added in v0.26.0

type DNSRecord struct {
	IP       net.IP
	ExpireAt time.Time
}

type DnsResponse

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

func DnsLookup added in v0.26.0

func DnsLookup(addr string, conn net.Conn) (*DnsResponse, error)

dnsLookup is used whenever we need to conduct a DNS query over a given TCP connection

func (*DnsResponse) PickRandomIP

func (response *DnsResponse) PickRandomIP() (net.IP, error)

PickRandomIP picks a random IP address from a DNS response

func (*DnsResponse) PickRecord added in v0.26.0

func (response *DnsResponse) PickRecord() (*DNSRecord, error)

type Protect

type Protect func(fileDescriptor int) error

type ProtectedConn

type ProtectedConn struct {
	net.Conn
	ProtectedConnBase
}

func (*ProtectedConn) Close

func (conn *ProtectedConn) Close() (err error)

Close is used to destroy a protected connection

type ProtectedConnBase added in v0.27.2

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

type ProtectedPacketConn added in v0.27.2

type ProtectedPacketConn struct {
	ProtectedConnBase
	net.PacketConn
	// contains filtered or unexported fields
}

func (*ProtectedPacketConn) Close added in v0.28.0

func (c *ProtectedPacketConn) Close() error

func (*ProtectedPacketConn) Write added in v0.28.0

func (c *ProtectedPacketConn) Write(b []byte) (int, error)

Jump to

Keyboard shortcuts

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