messages

package
v2.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: BSD-3-Clause Imports: 7 Imported by: 1

Documentation

Overview

import "git.torproject.org/pluggable-transports/snowflake.git/v2/common/messages"

import "git.torproject.org/pluggable-transports/snowflake.git/v2/common/messages"

Index

Constants

View Source
const ClientVersion = "1.0"
View Source
const (
	ProxyUnknown = "unknown"
)

Variables

View Source
var (
	ErrBadRequest = errors.New("bad request")
	ErrInternal   = errors.New("internal error")
	ErrExtraInfo  = errors.New("client sent extra info")

	StrTimedOut  = "timed out waiting for answer!"
	StrNoProxies = "no snowflake proxies currently available"
)
View Source
var KnownProxyTypes = map[string]bool{
	"standalone": true,
	"webext":     true,
	"badge":      true,
	"iptproxy":   true,
}

Functions

func DecodeAnswerRequest

func DecodeAnswerRequest(data []byte) (string, string, error)

Returns the sdp answer and proxy sid

func DecodeAnswerResponse

func DecodeAnswerResponse(data []byte) (bool, error)

func DecodePollResponse

func DecodePollResponse(data []byte) (string, string, error)

func DecodePollResponseWithRelayURL added in v2.3.0

func DecodePollResponseWithRelayURL(data []byte) (string, string, string, error)

Decodes a poll response from the broker and returns an offer and the client's NAT type If there is a client match, the returned offer string will be non-empty

func DecodeProxyPollRequest added in v2.2.0

func DecodeProxyPollRequest(data []byte) (sid string, proxyType string, natType string, clients int, err error)

func DecodeProxyPollRequestWithRelayPrefix added in v2.3.0

func DecodeProxyPollRequestWithRelayPrefix(data []byte) (
	sid string, proxyType string, natType string, clients int, relayPrefix string, relayPrefixAware bool, err error)

Decodes a poll message from a snowflake proxy and returns the sid, proxy type, nat type and clients of the proxy on success and an error if it failed

func EncodeAnswerRequest

func EncodeAnswerRequest(answer string, sid string) ([]byte, error)

func EncodeAnswerResponse

func EncodeAnswerResponse(success bool) ([]byte, error)

func EncodePollResponse

func EncodePollResponse(offer string, success bool, natType string) ([]byte, error)

func EncodePollResponseWithRelayURL added in v2.3.0

func EncodePollResponseWithRelayURL(offer string, success bool, natType, relayURL, failReason string) ([]byte, error)

func EncodeProxyPollRequest added in v2.2.0

func EncodeProxyPollRequest(sid string, proxyType string, natType string, clients int) ([]byte, error)

func EncodeProxyPollRequestWithRelayPrefix added in v2.3.0

func EncodeProxyPollRequestWithRelayPrefix(sid string, proxyType string, natType string, clients int, relayPattern string) ([]byte, error)

Types

type Arg

type Arg struct {
	Body       []byte
	RemoteAddr string
}

type ClientPollRequest

type ClientPollRequest struct {
	Offer       string `json:"offer"`
	NAT         string `json:"nat"`
	Fingerprint string `json:"fingerprint"`
}

func DecodeClientPollRequest

func DecodeClientPollRequest(data []byte) (*ClientPollRequest, error)

Decodes a poll message from a snowflake client

func (*ClientPollRequest) EncodeClientPollRequest added in v2.2.0

func (req *ClientPollRequest) EncodeClientPollRequest() ([]byte, error)

Encodes a poll message from a snowflake client

type ClientPollResponse

type ClientPollResponse struct {
	Answer string `json:"answer,omitempty"`
	Error  string `json:"error,omitempty"`
}

func DecodeClientPollResponse

func DecodeClientPollResponse(data []byte) (*ClientPollResponse, error)

Decodes a poll response for a snowflake client If the Error field is empty, the Answer should be non-empty

func (*ClientPollResponse) EncodePollResponse

func (resp *ClientPollResponse) EncodePollResponse() ([]byte, error)

Encodes a poll response for a snowflake client

type ProxyAnswerRequest

type ProxyAnswerRequest struct {
	Version string
	Sid     string
	Answer  string
}

type ProxyAnswerResponse

type ProxyAnswerResponse struct {
	Status string
}

type ProxyPollRequest

type ProxyPollRequest struct {
	Sid     string
	Version string
	Type    string
	NAT     string
	Clients int

	AcceptedRelayPattern *string
}

type ProxyPollResponse

type ProxyPollResponse struct {
	Status string
	Offer  string
	NAT    string

	RelayURL string
}

Jump to

Keyboard shortcuts

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