fragmentor

package
v0.0.0-...-9e90a31 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAX_FRAGMENTOR_NOTICES               = 3
	MAX_FRAGMENTOR_ITERATIONS_PER_NOTICE = 5
)

Variables

This section is empty.

Functions

func GetUpstreamMetricsNames

func GetUpstreamMetricsNames() []string

GetUpstreamMetricsNames returns the upstream metrics parameter names.

Types

type Config

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

Config specifies a fragmentor configuration. NewUpstreamConfig and NewDownstreamConfig will generate configurations based on the given client parameters.

func NewDownstreamConfig

func NewDownstreamConfig(
	p parameters.ParametersAccessor, tunnelProtocol string, seed *prng.Seed) *Config

NewDownstreamConfig creates a new Config; may return nil. Specifying the PRNG seed allows for optional replay of a fragmentor sequence.

func NewUpstreamConfig

func NewUpstreamConfig(
	p parameters.ParametersAccessor, tunnelProtocol string, seed *prng.Seed) *Config

NewUpstreamConfig creates a new Config; may return nil. Specifying the PRNG seed allows for optional replay of a fragmentor sequence.

func (*Config) MayFragment

func (config *Config) MayFragment() bool

MayFragment indicates whether the fragmentor configuration may result in any fragmentation; config can be nil. When MayFragment is false, the caller should skip wrapping the associated conn with a fragmentor.Conn.

type Conn

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

Conn implements simple fragmentation of application-level messages/packets into multiple TCP packets by splitting writes into smaller sizes and adding delays between writes.

The intent of Conn is both to frustrate firewalls that perform DPI on application-level messages that cross TCP packets as well as to perform a simple size and timing transformation to the traffic shape of the initial portion of a TCP flow.

func NewConn

func NewConn(
	config *Config,
	noticeEmitter func(string),
	conn net.Conn) *Conn

NewConn creates a new Conn. When no seed was provided in the Config, SetReplay must be called before the first Write.

func (*Conn) Close

func (c *Conn) Close() (err error)

func (*Conn) CloseWrite

func (c *Conn) CloseWrite() error

func (*Conn) GetMetrics

func (c *Conn) GetMetrics() common.LogFields

GetMetrics implements the common.MetricsSource interface.

func (*Conn) GetReplay

func (c *Conn) GetReplay() (*prng.Seed, bool)

GetReplay returns the seed for the fragmentor PRNG, and whether the fragmentor was configured to replay. The seed return value may be nil when isReplay is false.

GetReplay implements GetReplay.

func (*Conn) IsClosed

func (c *Conn) IsClosed() bool

func (*Conn) SetReplay

func (c *Conn) SetReplay(PRNG *prng.PRNG)

SetReplay sets the PRNG to be used by the fragmentor, allowing for replay of a fragmentor sequence. SetReplay may be used to set the PRNG after a conn has already been wrapped with a fragmentor.Conn, when no PRNG is specified in the config, and before the first Write. SetReplay sets the fragmentor isReplay flag to true.

For replay coordinated with a peer, SetReplay may be used with obfuscator.GetDerivedPRNG, using a seed provided by the peer.

If no seed is specified in NewUp/DownstreamConfig and SetReplay is not called before the first Write, the Write will fail. If a seed was specified in the config, or SetReplay was already called, or the input PRNG is nil, SetReplay has no effect.

SetReplay implements FragmentorReplayAccessor.

func (*Conn) StopFragmenting

func (c *Conn) StopFragmenting()

Stops the fragmentor from fragmenting any further writes.

func (*Conn) Write

func (c *Conn) Write(buffer []byte) (int, error)

Jump to

Keyboard shortcuts

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