messages

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: BSD-3-Clause Imports: 4 Imported by: 1

Documentation

Overview

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

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

Index

Constants

View Source
const ClientVersion = "1.0"

Variables

View Source
var (
	ErrBadRequest = errors.New("bad request")
	ErrInternal   = errors.New("internal error")

	StrTimedOut  = "timed out waiting for answer!"
	StrNoProxies = "no snowflake proxies currently available"
)

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 DecodePollRequest

func DecodePollRequest(data []byte) (sid string, proxyType string, natType string, clients int, 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 DecodePollResponse

func DecodePollResponse(data []byte) (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 EncodeAnswerRequest

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

func EncodeAnswerResponse

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

func EncodePollRequest

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

func EncodePollResponse

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

Types

type Arg added in v1.1.0

type Arg struct {
	Body       []byte
	RemoteAddr string
}

type ClientPollRequest

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

func DecodeClientPollRequest

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

Decodes a poll message from a snowflake client

func (*ClientPollRequest) EncodePollRequest

func (req *ClientPollRequest) EncodePollRequest() ([]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
}

type ProxyPollResponse

type ProxyPollResponse struct {
	Status string
	Offer  string
	NAT    string
}

Jump to

Keyboard shortcuts

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