Documentation ¶
Index ¶
- Constants
- Variables
- type ClientParams
- type ClientTransport
- func (t *ClientTransport) GetDstPort(seed []byte) (uint16, error)
- func (t *ClientTransport) GetParams() (proto.Message, error)
- func (*ClientTransport) ID() pb.TransportType
- func (t *ClientTransport) Name() string
- func (t ClientTransport) ParseParams(data *anypb.Any) (any, error)
- func (*ClientTransport) Prepare(...) error
- func (t *ClientTransport) PrepareKeys(pubkey [32]byte, sharedSecret []byte, hkdf io.Reader) error
- func (t *ClientTransport) SetParams(p any, unchecked ...bool) error
- func (t *ClientTransport) String() string
- func (t *ClientTransport) WrapConn(conn net.Conn) (net.Conn, error)
- type Prefix
- type PrefixID
- type Transport
- func (t Transport) GetDstPort(libVersion uint, seed []byte, params any) (uint16, error)
- func (Transport) GetIdentifier(d transports.Registration) string
- func (Transport) GetProto() pb.IPProto
- func (Transport) LogPrefix() string
- func (Transport) Name() string
- func (t Transport) ParamStrings(p any) []string
- func (t Transport) ParseParams(libVersion uint, data *anypb.Any) (any, error)
- func (t Transport) WrapConnection(data *bytes.Buffer, c net.Conn, originalDst net.IP, ...) (transports.Registration, net.Conn, error)
Constants ¶
const ( // DefaultFlush uses the flush pattern defined by the chosen prefix DefaultFlush int32 = iota // NoAddedFlush no flushes when writing prefix and tag NoAddedFlush // FlushAfterPrefix flush after the prefix before the tag (if possible), but not after tag // before client data is sent over the connection FlushAfterPrefix // FlushAfterTag do not flush after the prefix before the tag, but do flush after tag before // client data is sent over the connection FlushAfterTag // FlushAfterPrefixAndTag flush after both the prefix before the tag (if possible), as well as // after the tag before client data is sent over the connection FlushAfterPrefixAndTag )
Variables ¶
var ( // ErrUnknownPrefix indicates that the provided Prefix ID is unknown to the transport object. ErrUnknownPrefix = errors.New("unknown / unsupported prefix") // ErrBadParams indicates that the parameters provided to a call on the server side do not make // sense in the context that they are provided and the registration will be ignored. ErrBadParams = errors.New("bad parameters provided") // ErrIncorrectPrefix indicates that tryFindRegistration found a valid registration based on // the obfuscated tag, however the prefix that it matched was not the prefix indicated in the // registration. ErrIncorrectPrefix = errors.New("found connection for unexpected prefix") // ErrIncorrectTransport indicates that tryFindRegistration found a valid registration based on // the obfuscated tag, however the prefix that it matched was not the prefix indicated in the // registration. ErrIncorrectTransport = errors.New("found registration w/ incorrect transport type") )
var DefaultPrefixes = map[PrefixID]Prefix{}
DefaultPrefixes provides the prefixes supported by default for use when by the client.
Functions ¶
This section is empty.
Types ¶
type ClientParams ¶
ClientParams are parameters available to a calling library to configure the Prefix transport outside of the specific Prefix
type ClientTransport ¶
type ClientTransport struct { Prefix Prefix TagObfuscator transports.Obfuscator // contains filtered or unexported fields }
ClientTransport implements the client side transport interface for the Min transport. The significant difference is that there is an instance of this structure per client session, where the station side Transport struct has one instance to be re-used for all sessions.
External libraries must set parameters through SetParams using PrefixTransportParams.
func (*ClientTransport) GetDstPort ¶
func (t *ClientTransport) GetDstPort(seed []byte) (uint16, error)
GetDstPort returns the destination port that the client should open the phantom connection to
func (*ClientTransport) GetParams ¶
func (t *ClientTransport) GetParams() (proto.Message, error)
GetParams returns a generic protobuf with any parameters from both the registration and the transport.
func (*ClientTransport) ID ¶
func (*ClientTransport) ID() pb.TransportType
ID provides an identifier that will be sent to the conjure station during the registration so that the station knows what transport to expect connecting to the chosen phantom.
func (*ClientTransport) Name ¶
func (t *ClientTransport) Name() string
Name returns the human-friendly name of the transport, implementing the Transport interface.
func (ClientTransport) ParseParams ¶
func (t ClientTransport) ParseParams(data *anypb.Any) (any, error)
ParseParams gives the specific transport an option to parse a generic object into parameters provided by the station in the registration response during registration.
func (*ClientTransport) Prepare ¶ added in v0.6.0
func (*ClientTransport) Prepare(dialer func(ctx context.Context, network, laddr, raddr string) (net.Conn, error)) error
Prepare lets the transport use the dialer to prepare. This is called before GetParams to let the transport prepare stuff such as nat traversal.
func (*ClientTransport) PrepareKeys ¶
PrepareKeys provides an opportunity for the transport to integrate the station public key as well as bytes from the deterministic random generator associated with the registration that this ClientTransport is attached to.
func (*ClientTransport) SetParams ¶
func (t *ClientTransport) SetParams(p any, unchecked ...bool) error
SetParams allows the caller to set parameters associated with the transport, returning an error if the provided generic message is not compatible or the parameters are otherwise invalid
func (*ClientTransport) String ¶
func (t *ClientTransport) String() string
String returns a string identifier for the Transport for logging (including string formatters)
type Prefix ¶
Prefix struct used by, selected by, or given to the client. This interface allows for non-uniform behavior like a rand prefix for example.
type PrefixID ¶
type PrefixID int
PrefixID provide an integer Identifier for each individual prefixes allowing clients to indicate to the station the prefix they intend to connect with.
type Transport ¶
type Transport struct { SupportedPrefixes map[PrefixID]prefix TagObfuscator transports.Obfuscator Privkey [32]byte }
Transport provides a struct implementing the Transport, WrappingTransport, PortRandomizingTransport, and FixedPortTransport interfaces.
func Default ¶
Default Given a private key this builds the server side transport with the DEFAULT set of supported prefixes. The optional filepath specifies a file from which to read extra prefixes. If provided only the first variadic string will be used to attempt to parse prefixes. There can be no colliding PrefixIDs - file defined prefixes take precedent over defaults, and within the file first defined takes precedence.
func DefaultSet ¶
func DefaultSet() *Transport
DefaultSet builds a hollow version of the transport with the DEFAULT set of supported prefixes. This is useful in instances where we just need to check whether the prefix ID is known, not actually handle any major operations (tryFindReg / WrapConn)
func New ¶
New Given a private key this builds the server side transport with an EMPTY set of supported prefixes. The optional filepath specifies a file from which to read extra prefixes. If provided only the first variadic string will be used to attempt to parse prefixes. There can be no colliding PrefixIDs - within the file first defined takes precedence.
func (Transport) GetDstPort ¶
GetDstPort Given the library version, a seed, and a generic object containing parameters the transport should be able to return the destination port that a clients phantom connection will attempt to reach
func (Transport) GetIdentifier ¶
func (Transport) GetIdentifier(d transports.Registration) string
GetIdentifier takes in a registration and returns an identifier for it. This identifier should be unique for each registration on a given phantom; registrations on different phantoms can have the same identifier.
func (Transport) GetProto ¶
GetProto returns the next layer protocol that the transport uses. Implements the Transport interface.
func (Transport) LogPrefix ¶
LogPrefix returns the prefix used when including this transport in logs, implementing the Transport interface.
func (Transport) Name ¶
Name returns the human-friendly name of the transport, implementing the Transport interface..
func (Transport) ParamStrings ¶
ParamStrings returns an array of tag string that will be added to tunStats when a proxy session is closed.
func (Transport) ParseParams ¶
ParseParams gives the specific transport an option to parse a generic object into parameters provided by the client during registration. This Transport was written after RandomizeDstPort was added, so it should not be usable by clients who don't support destination port randomization.
func (Transport) WrapConnection ¶
func (t Transport) WrapConnection(data *bytes.Buffer, c net.Conn, originalDst net.IP, regManager transports.RegManager) (transports.Registration, net.Conn, error)
WrapConnection attempts to wrap the given connection in the transport. It takes the information gathered so far on the connection in data, attempts to identify itself, and if it positively identifies itself wraps the connection in the transport, returning a connection that's ready to be used by others.
If the returned error is nil or non-nil and non-{ transports.ErrTryAgain, transports.ErrNotTransport }, the caller may no longer use data or conn.