web

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIHostname     = "chat.signal.org"
	StorageHostname = "storage.signal.org"
	CDN1Hostname    = "cdn.signal.org"
	CDN2Hostname    = "cdn2.signal.org"
	CDN3Hostname    = "cdn3.signal.org"
)
View Source
const WebsocketPath = "/v1/websocket/"
View Source
const WebsocketProvisioningPath = "/v1/websocket/provisioning/"

Variables

View Source
var SignalAgent = "MAU"
View Source
var SignalHTTPClient = &http.Client{
	Transport: signalTransport,
}
View Source
var UserAgent = "signalmeow/0.1.0 libsignal/" + libsignalgo.Version + " go/" + strings.TrimPrefix(runtime.Version(), "go")

Functions

func CreateWSRequest

func CreateWSRequest(method string, path string, body []byte, username *string, password *string) *signalpb.WebSocketRequestMessage

func CreateWSResponse

func CreateWSResponse(ctx context.Context, id uint64, status int) *signalpb.WebSocketMessage

func DecodeHTTPResponseBody

func DecodeHTTPResponseBody(ctx context.Context, out any, resp *http.Response) error

DecodeHTTPResponseBody checks status code, reads an http.Response's Body and decodes it into the provided interface.

func GetAttachment

func GetAttachment(ctx context.Context, path string, cdnNumber uint32, opt *HTTPReqOpt) (*http.Response, error)

func OpenWebsocket

func OpenWebsocket(ctx context.Context, path string) (*websocket.Conn, *http.Response, error)

func OpenWebsocketURL

func OpenWebsocketURL(ctx context.Context, url string) (*websocket.Conn, *http.Response, error)

func SendHTTPRequest

func SendHTTPRequest(ctx context.Context, method string, path string, opt *HTTPReqOpt) (*http.Response, error)

Types

type ContentType

type ContentType string
const (
	ContentTypeJSON        ContentType = "application/json"
	ContentTypeProtobuf    ContentType = "application/x-protobuf"
	ContentTypeOctetStream ContentType = "application/octet-stream"
)

type HTTPReqOpt

type HTTPReqOpt struct {
	Body        []byte
	Username    *string
	Password    *string
	ContentType ContentType
	Host        string
	Headers     map[string]string
	OverrideURL string // Override the full URL, if set ignores path and Host
}

type SignalWebsocket

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

func NewSignalWebsocket

func NewSignalWebsocket(path string, username *string, password *string) *SignalWebsocket

func (*SignalWebsocket) Close

func (s *SignalWebsocket) Close() error

func (*SignalWebsocket) Connect

func (*SignalWebsocket) IsConnected

func (s *SignalWebsocket) IsConnected() bool

func (*SignalWebsocket) SendRequest

type SignalWebsocketConnectionEvent

type SignalWebsocketConnectionEvent int
const (
	SignalWebsocketConnectionEventConnecting SignalWebsocketConnectionEvent = iota // Implicit to catch default value (0), doesn't get sent
	SignalWebsocketConnectionEventConnected
	SignalWebsocketConnectionEventDisconnected
	SignalWebsocketConnectionEventLoggedOut
	SignalWebsocketConnectionEventError
	SignalWebsocketConnectionEventCleanShutdown
)

func (SignalWebsocketConnectionEvent) String

Implement the fmt.Stringer interface

type SignalWebsocketConnectionStatus

type SignalWebsocketConnectionStatus struct {
	Event SignalWebsocketConnectionEvent
	Err   error
}

type SignalWebsocketSendMessage

type SignalWebsocketSendMessage struct {
	// Populate if we're sending a request:
	RequestTime     time.Time
	ResponseChannel chan *signalpb.WebSocketResponseMessage
	// Populate if we're sending a response:
	ResponseMessage *SimpleResponse
	// Populate this for request AND response
	RequestMessage *signalpb.WebSocketRequestMessage
}

type SimpleResponse

type SimpleResponse struct {
	Status int
}

Jump to

Keyboard shortcuts

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