obfsvpn

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2025 License: BSD-2-Clause Imports: 19 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultKCPSendWindowSize    int  = 65535
	DefaultKCPReceiveWindowSize int  = 65535
	DefaultKCPReadBuffer        int  = 16 * 1024 * 1024
	DefaultKCPWriteBuffer       int  = 16 * 1024 * 1024
	DefaultNoDelay              bool = true
	DefaultInterval             int  = 10
	DefaultResend               int  = 2
	DefaultDisableFlowControl   bool = true
	DefaultMTU                  int  = 1400
)
View Source
const MaxHopPort uint = 65535
View Source
const MaxUDPLen uint = 65507
View Source
const MinHopPort uint = 49152

Variables

View Source
var (
	ErrCannotDial = errors.New("cannot dial")
)

Functions

func GetKCPDialer

func GetKCPDialer(kcpConfig KCPConfig, logger func(format string, a ...interface{})) func(network, address string) (net.Conn, error)

func GetKCPStats added in v1.1.0

func GetKCPStats() *kcp.Snmp

func GetQUICDialer added in v1.3.0

func GetQUICDialer(ctx context.Context, logger func(format string, a ...interface{})) func(network, address string) (net.Conn, error)

func NewServerState

func NewServerState(stateDir string) error

NewServerState will create all the state (node-id, private-key, public-key, drbg-seed, iat-mode) that the OBFS4 server needs to function. It will write it into the passed stateDir folder.

func ReadTCPFrameUDP

func ReadTCPFrameUDP(tcpConn net.Conn, datagramBuffer []byte, lengthBuffer []byte) ([]byte, error)

ReadTCPFrameUDP reads from a tcp connection and returns a framed UDP buffer

func ReadUDPFrameTCP

func ReadUDPFrameTCP(udpConn *net.UDPConn, datagramBuffer []byte) ([]byte, *net.UDPAddr, error)

ReadUDPFrameTCP reads from a udp connection and returns a framed TCP buffer

Types

type Dialer

type Dialer struct {
	Dialer net.Dialer

	NodeID    *ntor.NodeID
	PublicKey *ntor.PublicKey
	IATMode   IATMode
	DialFunc  func(string, string) (net.Conn, error)
	// contains filtered or unexported fields
}

Dialer contains options for connecting to an address and obfuscating traffic with the obfs4 protocol. It performs the ntor handshake on all dialed connections.

func NewDialerFromArgs

func NewDialerFromArgs(args pt.Args) (*Dialer, error)

NewDialerFromArgs creates a dialer from existing pluggable transport arguments.

func NewDialerFromCert

func NewDialerFromCert(cert string) (*Dialer, error)

NewDialerFromCert creates a dialer from a node certificate.

func (*Dialer) Args

func (d *Dialer) Args() pt.Args

Args returns the dialers options as pluggable transport arguments. The args include valid args for the "new" (version >= 0.0.3) bridge lines that use a unified "cert" argument as well as the legacy lines that use a separate Node ID and Public Key.

func (*Dialer) Dial

func (d *Dialer) Dial(network, address string) (net.Conn, error)

Dial creates an outbound net.Conn and performs the ntor handshake.

func (*Dialer) DialContext

func (d *Dialer) DialContext(ctx context.Context, network, address string) (net.Conn, error)

DialContext creates an outbound net.Conn and performs the ntor handshake.

type IATMode

type IATMode int

IATMode determines the amount of time sent between packets.

const (
	IATNone IATMode = iota
	IATEnabled
	IATParanoid
)

Valid IAT modes.

type KCPConfig

type KCPConfig struct {
	Enabled            bool `json:"enabled"`
	SendWindowSize     int  `json:"send_window_size"`
	ReceiveWindowSize  int  `json:"receive_window_size"`
	ReadBuffer         int  `json:"read_buffer"`
	WriteBuffer        int  `json:"write_buffer"`
	NoDelay            bool `json:"no_delay"`
	Interval           int  `json:"interval"`
	Resend             int  `json:"resend"`
	DisableFlowControl bool `json:"disable_flow_control"`
	MTU                int  `json:"mtu"`
}

https://github.com/skywind3000/kcp/blob/master/README.en.md#protocol-configuration

func DefaultKCPConfig

func DefaultKCPConfig() *KCPConfig

type ListenConfig

type ListenConfig struct {
	ListenConfig net.ListenConfig
	KCPConfig    KCPConfig
	QUICConfig   QUICConfig

	NodeID     *ntor.NodeID
	PrivateKey *ntor.PrivateKey
	PublicKey  string
	Seed       [ntor.KeySeedLength]byte
	StateDir   string
}

ListenConfig contains options for listening to an address. If Seed is not set it defaults to a randomized value. If StateDir is not set the current working directory is used.

func NewListenConfig

func NewListenConfig(nodeIDStr, privKeyStr, pubKeyStr, seedStr, stateDir string, kcpConfig KCPConfig, quicConfig QUICConfig) (*ListenConfig, error)

NewListenConfig returns a ListenConfig and any error during the initialization. perhaps this is redundant, but using the same json format than ss for debug.

func NewListenConfigCert

func NewListenConfigCert(cert string) (*ListenConfig, error)

NewListenConfigCert creates a listener config by unpacking the node ID from its certificate. The private key must still be specified.

func (*ListenConfig) Listen

func (lc *ListenConfig) Listen(ctx context.Context, address string) (*Listener, error)

Listen listens on the local network address. See func net.Dial for a description of the network and address parameters.

func (*ListenConfig) Wrap

func (lc *ListenConfig) Wrap(ctx context.Context, ln net.Listener) (*Listener, error)

Wrap takes an existing net.Listener and wraps it in a listener that is configured to perform the ntor handshake and copy data through the obfuscated conn. Values from the inner net.ListenConfig are ignored.

type Listener

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

Listener is a network listener that accepts obfuscated connections and performs the ntor handshake on them.

func (*Listener) Accept

func (l *Listener) Accept() (net.Conn, error)

Accept waits for and returns the next connection to the listener.

func (*Listener) Addr

func (l *Listener) Addr() net.Addr

Addr returns the listener's network address.

func (*Listener) Close

func (l *Listener) Close() error

Close closes the listener. Any blocked Accept operations will be unblocked and return errors.

type QUICConfig added in v1.3.0

type QUICConfig struct {
	Enabled bool
	TLSCert *tls.Certificate
}

func DefaultQUICConfig added in v1.3.0

func DefaultQUICConfig() *QUICConfig

type QUICConn added in v1.3.0

type QUICConn struct {
	quic.Stream
	// contains filtered or unexported fields
}

func (*QUICConn) Close added in v1.3.0

func (q *QUICConn) Close() error

func (*QUICConn) LocalAddr added in v1.3.0

func (q *QUICConn) LocalAddr() net.Addr

func (*QUICConn) RemoteAddr added in v1.3.0

func (q *QUICConn) RemoteAddr() net.Addr

type QUICListener added in v1.3.0

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

func (*QUICListener) Accept added in v1.3.0

func (q *QUICListener) Accept() (net.Conn, error)

func (*QUICListener) Addr added in v1.3.0

func (q *QUICListener) Addr() net.Addr

Addr returns the listener's network address.

func (*QUICListener) Close added in v1.3.0

func (q *QUICListener) Close() error

Jump to

Keyboard shortcuts

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