Documentation
¶
Index ¶
- Constants
- Variables
- func CreateWSRequest(method string, path string, body []byte, username *string, password *string) *signalpb.WebSocketRequestMessage
- func CreateWSResponse(ctx context.Context, id uint64, status int) *signalpb.WebSocketMessage
- func DecodeHTTPResponseBody(ctx context.Context, out any, resp *http.Response) error
- func GetAttachment(ctx context.Context, path string, cdnNumber uint32, opt *HTTPReqOpt) (*http.Response, error)
- func OpenWebsocket(ctx context.Context, path string) (*websocket.Conn, *http.Response, error)
- func OpenWebsocketURL(ctx context.Context, url string) (*websocket.Conn, *http.Response, error)
- func SendHTTPRequest(ctx context.Context, method string, path string, opt *HTTPReqOpt) (*http.Response, error)
- type ContentType
- type HTTPReqOpt
- type RequestHandlerFunc
- type SignalWebsocket
- func (s *SignalWebsocket) Close() error
- func (s *SignalWebsocket) Connect(ctx context.Context, requestHandler *RequestHandlerFunc) chan SignalWebsocketConnectionStatus
- func (s *SignalWebsocket) IsConnected() bool
- func (s *SignalWebsocket) SendRequest(ctx context.Context, request *signalpb.WebSocketRequestMessage) (*signalpb.WebSocketResponseMessage, error)
- type SignalWebsocketConnectionEvent
- type SignalWebsocketConnectionStatus
- type SignalWebsocketSendMessage
- type SimpleResponse
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 CDNHosts = []string{ CDN1Hostname, CDN1Hostname, CDN2Hostname, CDN3Hostname, }
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 CreateWSResponse ¶
func DecodeHTTPResponseBody ¶
DecodeHTTPResponseBody checks status code, reads an http.Response's Body and decodes it into the provided interface.
func GetAttachment ¶
func OpenWebsocket ¶
func OpenWebsocketURL ¶
func SendHTTPRequest ¶
Types ¶
type ContentType ¶
type ContentType string
const ( ContentTypeJSON ContentType = "application/json" ContentTypeProtobuf ContentType = "application/x-protobuf" ContentTypeOctetStream ContentType = "application/octet-stream" ContentTypeOffsetOctetStream ContentType = "application/offset+octet-stream" )
type HTTPReqOpt ¶
type RequestHandlerFunc ¶
type RequestHandlerFunc func(context.Context, *signalpb.WebSocketRequestMessage) (*SimpleResponse, error)
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 (s *SignalWebsocket) Connect(ctx context.Context, requestHandler *RequestHandlerFunc) chan SignalWebsocketConnectionStatus
func (*SignalWebsocket) IsConnected ¶
func (s *SignalWebsocket) IsConnected() bool
func (*SignalWebsocket) SendRequest ¶
func (s *SignalWebsocket) SendRequest( ctx context.Context, request *signalpb.WebSocketRequestMessage, ) (*signalpb.WebSocketResponseMessage, error)
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 ¶
func (s SignalWebsocketConnectionEvent) String() 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
}
Click to show internal directories.
Click to hide internal directories.