obfs4

package
v0.0.0-...-1add468 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: BSD-2-Clause, BSD-3-Clause Imports: 31 Imported by: 0

Documentation

Overview

Package obfs4 provides an implementation of the Tor Project's obfs4 obfuscation protocol.

Index

Constants

View Source
const (
	PacketOverhead          = f.LengthLength + f.TypeLength
	MaxPacketPayloadLength  = framing.MaximumFramePayloadLength - PacketOverhead
	SeedPacketPayloadLength = seedLength
)

Variables

View Source
var ErrInvalidHandshake = errors.New("handshake: Failed to find M_[C,S]")

ErrInvalidHandshake is the error returned when the obfs4 handshake fails due to the peer not sending the correct mark. This error is fatal and the connection MUST be dropped.

View Source
var ErrMarkNotFoundYet = errors.New("handshake: M_[C,S] not found yet")

ErrMarkNotFoundYet is the error returned when the obfs4 handshake is incomplete and requires more data to continue. This error is non-fatal and is the equivalent to EAGAIN/EWOULDBLOCK.

View Source
var ErrNtorFailed = errors.New("handshake: ntor handshake failure")

ErrNtorFailed is the error returned when the ntor handshake fails. This error is fatal and the connection MUST be dropped.

View Source
var ErrReplayedHandshake = errors.New("handshake: Replay detected")

ErrReplayedHandshake is the error returned when the obfs4 handshake fails due it being replayed. This error is fatal and the connection MUST be dropped.

Functions

func MakePayload

func MakePayload(pktType uint8, data []byte, padLen uint16) []byte

func MakeUnpaddedPayload

func MakeUnpaddedPayload(pktType uint8, data []byte) []byte

func ParseCert

func ParseCert(args *pt.Args) (nodeID *ntor.NodeID, publicKey *ntor.PublicKey, err error)

Types

type ClientArgs

type ClientArgs struct {
	NodeID     *ntor.NodeID
	PublicKey  *ntor.PublicKey
	SessionKey *ntor.Keypair
	IatMode    int
}

type ClientFactory

type ClientFactory struct {
	Trans base.Transport
}

func (*ClientFactory) Dial

func (cf *ClientFactory) Dial(network, addr string, dialer net.Dialer, args interface{}) (net.Conn, error)

func (*ClientFactory) ParseArgs

func (cf *ClientFactory) ParseArgs(args *pt.Args) (interface{}, error)

func (*ClientFactory) Transport

func (cf *ClientFactory) Transport() base.Transport

type Conn

type Conn struct {
	net.Conn
	// contains filtered or unexported fields
}

func NewClientConn

func NewClientConn(conn net.Conn, args *ClientArgs) (c *Conn, err error)

func (*Conn) GetDummyTraffic

func (conn *Conn) GetDummyTraffic(n int) ([]byte, error)

getDummyTraffic must be of type sharknado.DummyTrafficFunc and return `n` bytes of dummy traffic that's ready to be written to the wire.

func (*Conn) Read

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

func (*Conn) SetDeadline

func (conn *Conn) SetDeadline(t time.Time) error

func (*Conn) SetWriteDeadline

func (conn *Conn) SetWriteDeadline(t time.Time) error

func (*Conn) Write

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

type InvalidAuthError

type InvalidAuthError struct {
	Derived  *ntor.Auth
	Received *ntor.Auth
}

InvalidAuthError is the error returned when the ntor AUTH tags do not match. This error is fatal and the connection MUST be dropped.

func (*InvalidAuthError) Error

func (e *InvalidAuthError) Error() string

type InvalidMacError

type InvalidMacError struct {
	Derived  []byte
	Received []byte
}

InvalidMacError is the error returned when the handshake MACs do not match. This error is fatal and the connection MUST be dropped.

func (*InvalidMacError) Error

func (e *InvalidMacError) Error() string

type ServerFactory

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

func NewServerFactory

func NewServerFactory(t base.Transport, stateDir string, args *pt.Args) (*ServerFactory, error)

func (*ServerFactory) Args

func (sf *ServerFactory) Args() *pt.Args

func (*ServerFactory) Transport

func (sf *ServerFactory) Transport() base.Transport

func (*ServerFactory) WrapConn

func (sf *ServerFactory) WrapConn(conn net.Conn) (net.Conn, error)

type Transport

type Transport struct{}

Transport is the obfs4 implementation of the base.Transport interface.

func (*Transport) ClientFactory

func (t *Transport) ClientFactory(stateDir string) (base.ClientFactory, error)

ClientFactory returns a new ClientFactory instance.

func (*Transport) Name

func (t *Transport) Name() string

Name returns the name of the obfs4 transport protocol.

func (*Transport) ServerFactory

func (t *Transport) ServerFactory(stateDir string, args *pt.Args) (base.ServerFactory, error)

ServerFactory returns a new ServerFactory instance.

Directories

Path Synopsis
Package framing implements the obfs4 link framing and cryptography.
Package framing implements the obfs4 link framing and cryptography.

Jump to

Keyboard shortcuts

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