Optimizer

package module
v0.0.0-...-cac72fb Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2020 License: BSD-2-Clause, BSD-3-Clause Imports: 4 Imported by: 6

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 []Transport
	Strategy   Strategy
}

func NewOptimizerClient

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

func (*Client) Dial

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

type FirstStrategy

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

begin refactor

func (*FirstStrategy) Choose

func (strategy *FirstStrategy) Choose() Transport

func (*FirstStrategy) Report

func (strategy *FirstStrategy) Report(transport Transport, success bool, durationElapsed float64)

type RandomStrategy

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

end refactor

func (*RandomStrategy) Choose

func (strategy *RandomStrategy) Choose() Transport

func (*RandomStrategy) Report

func (strategy *RandomStrategy) Report(transport Transport, success bool, durationElapsed float64)

type RotateStrategy

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

func (*RotateStrategy) Choose

func (strategy *RotateStrategy) Choose() Transport

func (*RotateStrategy) Report

func (strategy *RotateStrategy) Report(transport Transport, success bool, durationElapsed float64)

type Strategy

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

func NewFirstStrategy

func NewFirstStrategy(transports []Transport) Strategy

func NewMinimizeDialDuration

func NewMinimizeDialDuration(transport []Transport) Strategy

func NewRandomStrategy

func NewRandomStrategy(transports []Transport) Strategy

func NewRotateStrategy

func NewRotateStrategy(transports []Transport) Strategy

func NewTrackStrategy

func NewTrackStrategy(transport []Transport) Strategy

type TrackStrategy

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

func (*TrackStrategy) Choose

func (strategy *TrackStrategy) Choose() Transport

func (*TrackStrategy) Report

func (strategy *TrackStrategy) Report(transport Transport, success bool, durationElapsed float64)

type Transport

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

Jump to

Keyboard shortcuts

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