tnt

package
v0.0.0-...-c2df4b6 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2017 License: LGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ReadTimeout time.Duration
)

Functions

func Base64Decode

func Base64Decode(src []byte) ([]byte, error)

Base64Decode decode to base64

func Base64Encode

func Base64Encode(src []byte) []byte

Base64Encode encode to base64

func Drain

func Drain(conn net.Conn)

Drain stream

func HTTPProtocolHeader

func HTTPProtocolHeader(domain string) []byte

HTTPProtocolHeader ...

func HandlePanic

func HandlePanic()

HandlePanic when panic from somewhere

func Ping

func Ping(c net.Conn) (result bool)

Ping test connectivity

func Pipe

func Pipe(src, dst net.Conn)

Pipe ...

func Pour

func Pour(conn net.Conn, data []byte)

Pour stream

func RawAddr

func RawAddr(domain string, port uint16) []byte

RawAddr according to domain and port

func ReadStream

func ReadStream(conn net.Conn) *bytes.Buffer

ReadStream ...

Types

type Cipher

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

Cipher - crypto struct

func NewCipher

func NewCipher(method, password string) (*Cipher, error)

NewCipher create new cipher

func (*Cipher) Copy

func (c *Cipher) Copy() *Cipher

Copy copy with initial state.

type Config

type Config struct {
	LocalAddr    string `json:"local"`
	ServerAddr   string `json:"server"`
	Password     string `json:"password"`
	Method       string `json:"method"`
	Timeout      int    `json:"timeout"`
	TargetDomain string `json:"target_domain"`
	TargetPort   uint16 `json:"target_port"`
}

func ParseConfig

func ParseConfig(fpath string) (config *Config, err error)

func (*Config) String

func (c *Config) String() string

type Conn

type Conn struct {
	net.Conn
	*Cipher
	ID []byte // [16]byte
}

func ConnectToServer

func ConnectToServer(network, addr string, tp TrafficType, rawaddr []byte, cipher *Cipher) (c *Conn, err error)

ConnectToServer write rawaddr to server

func NewConn

func NewConn(c net.Conn, cipher *Cipher) *Conn

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) Read

func (c *Conn) Read(b []byte) (n int, err error)

func (*Conn) SetReadTimeout

func (c *Conn) SetReadTimeout()

func (*Conn) Write

func (c *Conn) Write(b []byte) (n int, err error)

type DecOrEnc

type DecOrEnc int
const (
	Decrypt DecOrEnc = iota
	Encrypt
)

type Queue

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

Queue for generic purpose

func NewQueue

func NewQueue(capacity uint) (queue *Queue)

func (*Queue) Pop

func (q *Queue) Pop() (elem interface{})

func (*Queue) Push

func (q *Queue) Push(elem interface{}) (err error)

func (*Queue) Size

func (q *Queue) Size() (size uint)

type Socks5Negotiation

type Socks5Negotiation struct {
	Version      uint8
	NumOfMethods uint8
	Methods      []uint8
}

func (*Socks5Negotiation) String

func (s *Socks5Negotiation) String() string

type Socks5Request

type Socks5Request struct {
	Version         uint8
	Command         uint8
	RSV             uint8
	AddressType     uint8
	Address         string
	Port            uint16
	AddressWithPort string
	RawAddr         []byte
}

func (*Socks5Request) String

func (s *Socks5Request) String() string

type Traffic

type Traffic struct {
	Type       TrafficType
	PayloadLen uint16 // length of payload
	Payload    []byte // rawaddr
}

Traffic represent traffic throughout c/s

func NewTraffic

func NewTraffic(tp TrafficType, payload []byte) (r *Traffic)

NewTraffic payload stand for: rawaddr + payload

func UnMarshalTraffic

func UnMarshalTraffic(conn io.Reader) (request *Traffic, err error)

UnMarshalTraffic unmarshal TNTrequest via conn

func (*Traffic) Bytes

func (r *Traffic) Bytes() []byte

type TrafficType

type TrafficType uint8

TrafficType 0: meaningless, 1: request, 2: response, other: invalid

const (
	TrafficMeaningless TrafficType = iota
	TrafficRequest
)

Jump to

Keyboard shortcuts

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