optimizer

package module
v3.0.12 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2020 License: MIT Imports: 3 Imported by: 0

README

Optimizer

Optimizer is a pluggable transport that uses one of several possible “Strategies” to choose between the transports you provide to create a connection. It is not a standalone transport, but is rather a mechanism for choosing between various transports in order to find the one best suited for the user’s needs. For more information about pluggable transports, please refer to pluggabletransports.info.

Here is a list of the currently available Optimizer strategies:

Rotate Strategy: This strategy simply rotates through the list of provided transports and tries the next one in the list each time a connection is needed.

Choose Random Strategy: A transport is selected at random from the list for each connection request.

Track Strategy: A strategy that attempts to connect with each of the provided transports. It keeps track of which transports are connecting successfully and favors using those.

Minimize Dial Strategy: The transport is chosen based on which has been shown to connect the fastest.

Using Optimizer

Go Version:

Optimizer is one of the transports available in the Shapeshifter-Transports library.

  1. First you will need to initialize the transports you would like Optimizer to use: dialer := proxy.Direct obfs4Transport := obfs4.Transport{ CertString: "InsertCertStringHere", IatMode: 0 or 1, Address: "InsertAddressHere", Dialer: dialer, } shadowTransport := shadow.Transport{"InsertPasswordHere", "InsertCipherNameHere", "InsertAddressHere"}

  2. Create an array with these transports: transports := []Transport{obfs4Transport, shadowTransport}

  3. Initialize the strategy of your choice using the array of transports you created: strategy := NewMinimizeDialDuration(transports)

  4. Create an instance of OptimizerConnectionFactory using your new Strategy instance: optimizerTransport := NewOptimizerClient(transports, strategy)

  5. Call Dial on optimizerTransport: _, err := optimizerTransport.Dial()

Documentation

Overview

Package optimizer provides a PT 2.0 Go API wrapper around the connections used

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Transports []TransportDialer
	Strategy   Strategy
}

Client contains the two parameters needed to use Optimizer.

func NewOptimizerClient

func NewOptimizerClient(Transports []TransportDialer, Strategy Strategy) *Client

NewOptimizerClient is the initializer

func (*Client) Dial

func (OptT *Client) Dial() (net.Conn, error)

Dial connects to the address on the named network

type FirstStrategy

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

FirstStrategy returns the first strategy in the array

func (*FirstStrategy) Choose

func (strategy *FirstStrategy) Choose() TransportDialer

Choose selects a transport in the array

func (*FirstStrategy) Report

func (strategy *FirstStrategy) Report(TransportDialer, bool, float64)

Report returns if the transport was successful and how long the connection took

type RandomStrategy

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

RandomStrategy returns a transport at random

func (*RandomStrategy) Choose

func (strategy *RandomStrategy) Choose() TransportDialer

Choose selects a transport in the array

func (*RandomStrategy) Report

func (strategy *RandomStrategy) Report(TransportDialer, bool, float64)

Report returns if the transport was successful and how long the connection took

type RotateStrategy

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

RotateStrategy cycles through the list of transports, using a different one each time

func (*RotateStrategy) Choose

func (strategy *RotateStrategy) Choose() TransportDialer

Choose selects a transport in the array

func (*RotateStrategy) Report

func (strategy *RotateStrategy) Report(TransportDialer, bool, float64)

Report returns if the transport was successful and how long the connection took

type Strategy

type Strategy interface {
	Choose() TransportDialer
	Report(transport TransportDialer, success bool, durationElapsed float64)
}

Strategy is the method used to choose a transport

func NewFirstStrategy

func NewFirstStrategy(transports []TransportDialer) Strategy

NewFirstStrategy initializes FirstStrategy

func NewMinimizeDialDuration

func NewMinimizeDialDuration(transport []TransportDialer) Strategy

NewMinimizeDialDuration initializes minimizeDialDuration

func NewRandomStrategy

func NewRandomStrategy(transports []TransportDialer) Strategy

NewRandomStrategy initializes RandomStrategy

func NewRotateStrategy

func NewRotateStrategy(transports []TransportDialer) Strategy

NewRotateStrategy initializes RotateStrategy

func NewTrackStrategy

func NewTrackStrategy(transport []TransportDialer) Strategy

NewTrackStrategy initializes TrackStrategy

type TrackStrategy

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

TrackStrategy assigns a score to each transport and server that is remembered and used to choose the best option

func (*TrackStrategy) Choose

func (strategy *TrackStrategy) Choose() TransportDialer

Choose selects a transport in the array

func (*TrackStrategy) Report

func (strategy *TrackStrategy) Report(transport TransportDialer, success bool, _ float64)

Report returns if the transport was successful and how long the connection took

type TransportDialer added in v3.0.2

type TransportDialer interface {
	Dial() (net.Conn, error)
}

TransportDialer is a program that transforms network traffic

type TransportListener added in v3.0.2

type TransportListener interface {
	Listen() (net.Listener, error)
}

Jump to

Keyboard shortcuts

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