msgs

package
v0.0.0-...-26d6cb3 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2019 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const EV_BUFFER = 200

TODO: circular buffer, poll event, for debug

Variables

View Source
var (
	ErrInvalidLengthWebpush        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowWebpush          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupWebpush = fmt.Errorf("proto: unexpected end of group")
)
View Source
var Debug = false
View Source
var DefaultMux = NewMux()
View Source
var ReceiveBaseUrl = "https://127.0.0.1:5228/"

Functions

func DebugEventsHandler

func DebugEventsHandler(w http.ResponseWriter, req *http.Request)

Return the sticky and recent events.

func HTTPHandlerEventStream

func HTTPHandlerEventStream(w http.ResponseWriter, req *http.Request)

Used to receive (subscribe) to messages, using HTTP streaming protocol.

TODO: pass the list of subscriptions, filter, 'start' message

func HTTPHandlerSend

func HTTPHandlerSend(w http.ResponseWriter, r *http.Request)

Used to push a message from a remote sender.

Mapped to /msg/

q or path can be used to pass command. Body and query string are sent. TODO: compatibility with cloud events and webpush TODO: RBAC (including admin check for system notifications)

func InitMux

func InitMux(mux *http.ServeMux)

Mux corresponds to a server with TLS certificates. MTLS is optional, can be used instead of VAPID tokens.

func MonitorNode

func MonitorNode(w *Mux, hc *http.Client, idhex *net.IPAddr) error

func ParseMessage

func ParseMessage(data []byte, mtype int) (cmd string, meta map[string]string, outd []byte, end int)

Parse a message. Currently used in the UDS mapping, using a HTTP1-like text format

func Send

func Send(msgType string, meta ...string)

Send a message to the default mux. Will serialize the event and save it for debugging.

Local handlers and debug tools/admin can subscribe.

func SendFrameLenBinary

func SendFrameLenBinary(con io.Writer, data ...[]byte) (int, error)

Send a binary packet, with len prefix. Currently used in the UDS mapping.

func SubscribeHandler

func SubscribeHandler(res http.ResponseWriter, req *http.Request)

Subscribe creates a subscription. Initial version is just a random - some interface will be added later, to allow sets.

Types

type AckRequest

type AckRequest struct {
	MessageId string `protobuf:"bytes,1,opt,name=message_id,proto3" json:"message_id,omitempty"`
}

func (*AckRequest) Descriptor

func (*AckRequest) Descriptor() ([]byte, []int)

func (*AckRequest) GetMessageId

func (m *AckRequest) GetMessageId() string

func (*AckRequest) Marshal

func (m *AckRequest) Marshal() (dAtA []byte, err error)

func (*AckRequest) MarshalTo

func (m *AckRequest) MarshalTo(dAtA []byte) (int, error)

func (*AckRequest) MarshalToSizedBuffer

func (m *AckRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*AckRequest) ProtoMessage

func (*AckRequest) ProtoMessage()

func (*AckRequest) Reset

func (m *AckRequest) Reset()

func (*AckRequest) Size

func (m *AckRequest) Size() (n int)

func (*AckRequest) String

func (m *AckRequest) String() string

func (*AckRequest) Unmarshal

func (m *AckRequest) Unmarshal(dAtA []byte) error

func (*AckRequest) XXX_DiscardUnknown

func (m *AckRequest) XXX_DiscardUnknown()

func (*AckRequest) XXX_Marshal

func (m *AckRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*AckRequest) XXX_Merge

func (m *AckRequest) XXX_Merge(src proto.Message)

func (*AckRequest) XXX_Size

func (m *AckRequest) XXX_Size() int

func (*AckRequest) XXX_Unmarshal

func (m *AckRequest) XXX_Unmarshal(b []byte) error

type AckResponse

type AckResponse struct {
}

func (*AckResponse) Descriptor

func (*AckResponse) Descriptor() ([]byte, []int)

func (*AckResponse) Marshal

func (m *AckResponse) Marshal() (dAtA []byte, err error)

func (*AckResponse) MarshalTo

func (m *AckResponse) MarshalTo(dAtA []byte) (int, error)

func (*AckResponse) MarshalToSizedBuffer

func (m *AckResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*AckResponse) ProtoMessage

func (*AckResponse) ProtoMessage()

func (*AckResponse) Reset

func (m *AckResponse) Reset()

func (*AckResponse) Size

func (m *AckResponse) Size() (n int)

func (*AckResponse) String

func (m *AckResponse) String() string

func (*AckResponse) Unmarshal

func (m *AckResponse) Unmarshal(dAtA []byte) error

func (*AckResponse) XXX_DiscardUnknown

func (m *AckResponse) XXX_DiscardUnknown()

func (*AckResponse) XXX_Marshal

func (m *AckResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*AckResponse) XXX_Merge

func (m *AckResponse) XXX_Merge(src proto.Message)

func (*AckResponse) XXX_Size

func (m *AckResponse) XXX_Size() int

func (*AckResponse) XXX_Unmarshal

func (m *AckResponse) XXX_Unmarshal(b []byte) error

type Backoff

type Backoff interface {
	BackoffSleep()
	BackoffReset()
}

type ChannelHandler

type ChannelHandler struct {
	MsgChan chan *Message
}

func NewChannelHandler

func NewChannelHandler() *ChannelHandler

func (*ChannelHandler) HandleMessage

func (u *ChannelHandler) HandleMessage(ctx context.Context, cmdS string, meta map[string]string, data []byte)

func (*ChannelHandler) WaitEvent

func (u *ChannelHandler) WaitEvent(name string) *Message

type EventStreamConnection

type EventStreamConnection struct {
	MsgConnection
}

type Gateway

type Gateway struct {

	// technically we could handle multiple mux and ids in a gateway - but
	// not clear use case (besides tests)
	NodeId string
	// contains filtered or unexported fields
}

Gateway handles the incoming and outgoing connections, and adaptation between protocols. Messages for local pod are handled by Mux.

func (*Gateway) OnRemoteMessage

func (mux *Gateway) OnRemoteMessage(ev *Message, from, self string, connName string) error

Message from a remote, will be forwarded to subscribed connections.

func (*Gateway) RemoveConnection

func (gate *Gateway) RemoveConnection(id string, cp *MsgConnection)

func (*Gateway) Send

func (gate *Gateway) Send(ev *Message) error

Send a message to one or more connections.

type HandlerCallbackFunc

type HandlerCallbackFunc func(ctx context.Context, cmdS string, meta map[string]string, data []byte)

Adapter from func to interface

func (HandlerCallbackFunc) HandleMessage

func (f HandlerCallbackFunc) HandleMessage(ctx context.Context, cmdS string, meta map[string]string, data []byte)

ServeHTTP calls f(w, r).

type Message

type Message struct {

	//RFC3339 "2018-04-05T17:31:00Z"
	Time string `json:"time,omitempty"`

	// ID of event, to dedup.
	Id string `json:"id,omitempty"`

	// Can be 'topic', or destination
	To string `json:"to,omitempty"`

	Subject string `json:"subject,omitempty"`

	// VIPs in the path
	Path []string `json:"path,omitempty"`

	// Describes the event producer - VIP or public key
	From string `json:"from,omitempty"`

	// JSON-serializable payload.
	// Interface means will be serialized as base64 if []byte, as String if string or actual Json without encouding
	// otherwise.
	Data interface{} `json:"data,omitempty"`

	// TS is the timestamp, in go format. When sending over the wire, converted to Time. From time when received.
	TS time.Time `json:"-"`

	// If data is a map (common case)
	Meta map[string]string `json:"meta,omitempty"`

	// If received from a remote, the connection it was received on.
	// nil if generated locally
	Connection *MsgConnection `json:"-"`

	// Extracted from To URL
	Topic string `json:"-"`
}

Records recent received messages and broadcasts, for debug and UI

func NewMessage

func NewMessage(cmdS string, meta map[string]string) *Message

func ParseJSON

func ParseJSON(data []byte) *Message

func (*Message) Binary

func (ev *Message) Binary() []byte

Return a binary representation of the data: either the []byte for raw data, or the marshalled json starting with {.

func (*Message) MarshalJSON

func (ev *Message) MarshalJSON() []byte

func (*Message) SetDataJSON

func (ev *Message) SetDataJSON(data interface{}) *Message

type MessageEnvelope

type MessageEnvelope struct {
	MessageId string `protobuf:"bytes,1,opt,name=message_id,proto3" json:"message_id,omitempty"`
	// Maps to the SubscribeResponse push parameter, returned as Link rel="urn:ietf:params:push"
	// in the push promise.
	Push string `protobuf:"bytes,2,opt,name=push,proto3" json:"push,omitempty"`
	// If 'dh' and 'salt' are set, will contain encrypted data.
	Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
	// Identifies the sender.
	Sender          *Vapid `protobuf:"bytes,4,opt,name=sender,proto3" json:"sender,omitempty"`
	ContentEncoding string `protobuf:"bytes,7,opt,name=content_encoding,proto3" json:"content_encoding,omitempty"`
	Salt            []byte `protobuf:"bytes,8,opt,name=salt,proto3" json:"salt,omitempty"`
	Dh              []byte `protobuf:"bytes,9,opt,name=dh,proto3" json:"dh,omitempty"`
}

Message is returned as PUSH PROMISE frames in the spec. The alternative protocol wraps it in Any field or other framing.

func (*MessageEnvelope) Descriptor

func (*MessageEnvelope) Descriptor() ([]byte, []int)

func (*MessageEnvelope) GetContentEncoding

func (m *MessageEnvelope) GetContentEncoding() string

func (*MessageEnvelope) GetData

func (m *MessageEnvelope) GetData() []byte

func (*MessageEnvelope) GetDh

func (m *MessageEnvelope) GetDh() []byte

func (*MessageEnvelope) GetMessageId

func (m *MessageEnvelope) GetMessageId() string

func (*MessageEnvelope) GetPush

func (m *MessageEnvelope) GetPush() string

func (*MessageEnvelope) GetSalt

func (m *MessageEnvelope) GetSalt() []byte

func (*MessageEnvelope) GetSender

func (m *MessageEnvelope) GetSender() *Vapid

func (*MessageEnvelope) Marshal

func (m *MessageEnvelope) Marshal() (dAtA []byte, err error)

func (*MessageEnvelope) MarshalTo

func (m *MessageEnvelope) MarshalTo(dAtA []byte) (int, error)

func (*MessageEnvelope) MarshalToSizedBuffer

func (m *MessageEnvelope) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*MessageEnvelope) ProtoMessage

func (*MessageEnvelope) ProtoMessage()

func (*MessageEnvelope) Reset

func (m *MessageEnvelope) Reset()

func (*MessageEnvelope) Size

func (m *MessageEnvelope) Size() (n int)

func (*MessageEnvelope) String

func (m *MessageEnvelope) String() string

func (*MessageEnvelope) Unmarshal

func (m *MessageEnvelope) Unmarshal(dAtA []byte) error

func (*MessageEnvelope) XXX_DiscardUnknown

func (m *MessageEnvelope) XXX_DiscardUnknown()

func (*MessageEnvelope) XXX_Marshal

func (m *MessageEnvelope) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*MessageEnvelope) XXX_Merge

func (m *MessageEnvelope) XXX_Merge(src proto.Message)

func (*MessageEnvelope) XXX_Size

func (m *MessageEnvelope) XXX_Size() int

func (*MessageEnvelope) XXX_Unmarshal

func (m *MessageEnvelope) XXX_Unmarshal(b []byte) error

type MessageHandler

type MessageHandler interface {
	// Handle a message. Context may provide access to the actual message object
	// and mux.
	HandleMessage(ctx context.Context, cmdS string, meta map[string]string, data []byte)
}

Local processing of messages. Interface doesn't use any specific struct, to avoid creating deps.

type Metric

type Metric interface {
	Add(float64)
}

Metric is an interface for applications updating metrics Expvar is an interface between metric and the collection system.

type MetricProvider

type MetricProvider interface {
	Metric(string) Metric
}

type MonitorRequest

type MonitorRequest struct {
	// This is the push or push_set in the subscribe response.
	PushSet string `protobuf:"bytes,1,opt,name=push_set,proto3" json:"push_set,omitempty"`
	// JWT token, signed with key
	Authorization string `protobuf:"bytes,2,opt,name=authorization,proto3" json:"authorization,omitempty"`
	// Public key used for signing, identifies sender/receiver
	Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"`
}

func (*MonitorRequest) Descriptor

func (*MonitorRequest) Descriptor() ([]byte, []int)

func (*MonitorRequest) GetAuthorization

func (m *MonitorRequest) GetAuthorization() string

func (*MonitorRequest) GetKey

func (m *MonitorRequest) GetKey() string

func (*MonitorRequest) GetPushSet

func (m *MonitorRequest) GetPushSet() string

func (*MonitorRequest) Marshal

func (m *MonitorRequest) Marshal() (dAtA []byte, err error)

func (*MonitorRequest) MarshalTo

func (m *MonitorRequest) MarshalTo(dAtA []byte) (int, error)

func (*MonitorRequest) MarshalToSizedBuffer

func (m *MonitorRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*MonitorRequest) ProtoMessage

func (*MonitorRequest) ProtoMessage()

func (*MonitorRequest) Reset

func (m *MonitorRequest) Reset()

func (*MonitorRequest) Size

func (m *MonitorRequest) Size() (n int)

func (*MonitorRequest) String

func (m *MonitorRequest) String() string

func (*MonitorRequest) Unmarshal

func (m *MonitorRequest) Unmarshal(dAtA []byte) error

func (*MonitorRequest) XXX_DiscardUnknown

func (m *MonitorRequest) XXX_DiscardUnknown()

func (*MonitorRequest) XXX_Marshal

func (m *MonitorRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*MonitorRequest) XXX_Merge

func (m *MonitorRequest) XXX_Merge(src proto.Message)

func (*MonitorRequest) XXX_Size

func (m *MonitorRequest) XXX_Size() int

func (*MonitorRequest) XXX_Unmarshal

func (m *MonitorRequest) XXX_Unmarshal(b []byte) error

type MsgConnection

type MsgConnection struct {

	// Key used in mux to track this connection
	Name string

	// Broadcast subscriptions to forward to the remote. Will have a 'From' set to current node.
	// VPN and upstream server use "*" to receive/pass up all events.
	// TODO: keep some messages local, by using To=., and indicate broadcasts as *.
	SubscriptionsToSend []string

	// OnMessage is called when a message for this connection is dispatched.
	// The message should be either a broadcast, have as To the vip of the connection or
	// another vip reachable from the connection.
	//
	// The topic of the message should be in the Subscription list if the destination is this vip.
	//
	// Internal handlers may use the same interface.
	SendMessageToRemote func(ev *Message) error
	// contains filtered or unexported fields
}

One connection - incoming or outgoing. Can send messages to the remote end, which may in turn forward messages for other nodes.

Incoming messages are dispatched to the mux, which may deliver locally or forward.

func (*MsgConnection) Close

func (mc *MsgConnection) Close()

func (*MsgConnection) HandleMessageStream

func (mconn *MsgConnection) HandleMessageStream(cb func(message *Message), br *bufio.Reader, from string, self string)

Messages received from remote, over SSH.

from is the authenticated VIP of the sender. self is my own VIP

type Mux

type Mux struct {
	Gate *Gateway
	// contains filtered or unexported fields
}

Mux handles processing messages for this node, and sending messages from local code.

func NewMux

func NewMux() *Mux

func (*Mux) AddConnection

func (mux *Mux) AddConnection(id string, cp *MsgConnection)

id - remote id. "uds" for the primary upstream uds connection to host (android app or wifi/root app)

func (*Mux) AddHandler

func (mux *Mux) AddHandler(path string, cp MessageHandler)

Add a local handler for a specific message type or * This is a local function.

func (*Mux) HTTPUDS

func (mux *Mux) HTTPUDS(w http.ResponseWriter, r *http.Request)

Currently mapped to /dmesh/uds - sends a message to a specific connection, defaults to the UDS connection to the android or root dmwifi app.

func (*Mux) HandleMessageForNode

func (mux *Mux) HandleMessageForNode(ev *Message) error

Called for local events (host==. or empty). Called when a message is received from one of the local streams ( UDS, etc ), if the final destination is the current node.

Message will be passed to one or more of the local handlers, based on type.

TODO: authorization (based on identity of the caller)

func (*Mux) Send

func (mux *Mux) Send(msgType string, meta ...string) error

func (*Mux) SendMessage

func (mux *Mux) SendMessage(ev *Message) error

Publish a message. Will be distributed to remote listeners. TODO: routing for directed messages (to specific destination) TODO: up/down indication for multicast, subscription

type PushRequest

type PushRequest struct {
	// The value returned in the SubscribeResponse push, without the hostname.
	Push    string `protobuf:"bytes,1,opt,name=push,proto3" json:"push,omitempty"`
	Ttl     int32  `protobuf:"varint,2,opt,name=ttl,proto3" json:"ttl,omitempty"`
	Data    []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
	Urgency string `protobuf:"bytes,4,opt,name=urgency,proto3" json:"urgency,omitempty"`
	// Prefer header indicating delivery receipt request.
	RespondAsync    bool   `protobuf:"varint,5,opt,name=respond_async,proto3" json:"respond_async,omitempty"`
	Topic           string `protobuf:"bytes,6,opt,name=topic,proto3" json:"topic,omitempty"`
	ContentEncoding string `protobuf:"bytes,7,opt,name=content_encoding,proto3" json:"content_encoding,omitempty"`
	Salt            string `protobuf:"bytes,8,opt,name=salt,proto3" json:"salt,omitempty"`
	Dh              string `protobuf:"bytes,9,opt,name=dh,proto3" json:"dh,omitempty"`
}

func (*PushRequest) Descriptor

func (*PushRequest) Descriptor() ([]byte, []int)

func (*PushRequest) GetContentEncoding

func (m *PushRequest) GetContentEncoding() string

func (*PushRequest) GetData

func (m *PushRequest) GetData() []byte

func (*PushRequest) GetDh

func (m *PushRequest) GetDh() string

func (*PushRequest) GetPush

func (m *PushRequest) GetPush() string

func (*PushRequest) GetRespondAsync

func (m *PushRequest) GetRespondAsync() bool

func (*PushRequest) GetSalt

func (m *PushRequest) GetSalt() string

func (*PushRequest) GetTopic

func (m *PushRequest) GetTopic() string

func (*PushRequest) GetTtl

func (m *PushRequest) GetTtl() int32

func (*PushRequest) GetUrgency

func (m *PushRequest) GetUrgency() string

func (*PushRequest) Marshal

func (m *PushRequest) Marshal() (dAtA []byte, err error)

func (*PushRequest) MarshalTo

func (m *PushRequest) MarshalTo(dAtA []byte) (int, error)

func (*PushRequest) MarshalToSizedBuffer

func (m *PushRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*PushRequest) ProtoMessage

func (*PushRequest) ProtoMessage()

func (*PushRequest) Reset

func (m *PushRequest) Reset()

func (*PushRequest) Size

func (m *PushRequest) Size() (n int)

func (*PushRequest) String

func (m *PushRequest) String() string

func (*PushRequest) Unmarshal

func (m *PushRequest) Unmarshal(dAtA []byte) error

func (*PushRequest) XXX_DiscardUnknown

func (m *PushRequest) XXX_DiscardUnknown()

func (*PushRequest) XXX_Marshal

func (m *PushRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PushRequest) XXX_Merge

func (m *PushRequest) XXX_Merge(src proto.Message)

func (*PushRequest) XXX_Size

func (m *PushRequest) XXX_Size() int

func (*PushRequest) XXX_Unmarshal

func (m *PushRequest) XXX_Unmarshal(b []byte) error

type PushResponse

type PushResponse struct {
	MessageId string `protobuf:"bytes,1,opt,name=message_id,proto3" json:"message_id,omitempty"`
	// If request includes the respond_async parameter.
	//
	PushReceipt string `protobuf:"bytes,2,opt,name=push_receipt,proto3" json:"push_receipt,omitempty"`
}

func (*PushResponse) Descriptor

func (*PushResponse) Descriptor() ([]byte, []int)

func (*PushResponse) GetMessageId

func (m *PushResponse) GetMessageId() string

func (*PushResponse) GetPushReceipt

func (m *PushResponse) GetPushReceipt() string

func (*PushResponse) Marshal

func (m *PushResponse) Marshal() (dAtA []byte, err error)

func (*PushResponse) MarshalTo

func (m *PushResponse) MarshalTo(dAtA []byte) (int, error)

func (*PushResponse) MarshalToSizedBuffer

func (m *PushResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*PushResponse) ProtoMessage

func (*PushResponse) ProtoMessage()

func (*PushResponse) Reset

func (m *PushResponse) Reset()

func (*PushResponse) Size

func (m *PushResponse) Size() (n int)

func (*PushResponse) String

func (m *PushResponse) String() string

func (*PushResponse) Unmarshal

func (m *PushResponse) Unmarshal(dAtA []byte) error

func (*PushResponse) XXX_DiscardUnknown

func (m *PushResponse) XXX_DiscardUnknown()

func (*PushResponse) XXX_Marshal

func (m *PushResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PushResponse) XXX_Merge

func (m *PushResponse) XXX_Merge(src proto.Message)

func (*PushResponse) XXX_Size

func (m *PushResponse) XXX_Size() int

func (*PushResponse) XXX_Unmarshal

func (m *PushResponse) XXX_Unmarshal(b []byte) error

type Receipt

type Receipt struct {
	MessageId string `protobuf:"bytes,1,opt,name=message_id,proto3" json:"message_id,omitempty"`
}

func (*Receipt) Descriptor

func (*Receipt) Descriptor() ([]byte, []int)

func (*Receipt) GetMessageId

func (m *Receipt) GetMessageId() string

func (*Receipt) Marshal

func (m *Receipt) Marshal() (dAtA []byte, err error)

func (*Receipt) MarshalTo

func (m *Receipt) MarshalTo(dAtA []byte) (int, error)

func (*Receipt) MarshalToSizedBuffer

func (m *Receipt) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Receipt) ProtoMessage

func (*Receipt) ProtoMessage()

func (*Receipt) Reset

func (m *Receipt) Reset()

func (*Receipt) Size

func (m *Receipt) Size() (n int)

func (*Receipt) String

func (m *Receipt) String() string

func (*Receipt) Unmarshal

func (m *Receipt) Unmarshal(dAtA []byte) error

func (*Receipt) XXX_DiscardUnknown

func (m *Receipt) XXX_DiscardUnknown()

func (*Receipt) XXX_Marshal

func (m *Receipt) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Receipt) XXX_Merge

func (m *Receipt) XXX_Merge(src proto.Message)

func (*Receipt) XXX_Size

func (m *Receipt) XXX_Size() int

func (*Receipt) XXX_Unmarshal

func (m *Receipt) XXX_Unmarshal(b []byte) error

type ReceiptRequest

type ReceiptRequest struct {
	ReceiptSubscription string `protobuf:"bytes,1,opt,name=receipt_subscription,proto3" json:"receipt_subscription,omitempty"`
}

func (*ReceiptRequest) Descriptor

func (*ReceiptRequest) Descriptor() ([]byte, []int)

func (*ReceiptRequest) GetReceiptSubscription

func (m *ReceiptRequest) GetReceiptSubscription() string

func (*ReceiptRequest) Marshal

func (m *ReceiptRequest) Marshal() (dAtA []byte, err error)

func (*ReceiptRequest) MarshalTo

func (m *ReceiptRequest) MarshalTo(dAtA []byte) (int, error)

func (*ReceiptRequest) MarshalToSizedBuffer

func (m *ReceiptRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*ReceiptRequest) ProtoMessage

func (*ReceiptRequest) ProtoMessage()

func (*ReceiptRequest) Reset

func (m *ReceiptRequest) Reset()

func (*ReceiptRequest) Size

func (m *ReceiptRequest) Size() (n int)

func (*ReceiptRequest) String

func (m *ReceiptRequest) String() string

func (*ReceiptRequest) Unmarshal

func (m *ReceiptRequest) Unmarshal(dAtA []byte) error

func (*ReceiptRequest) XXX_DiscardUnknown

func (m *ReceiptRequest) XXX_DiscardUnknown()

func (*ReceiptRequest) XXX_Marshal

func (m *ReceiptRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ReceiptRequest) XXX_Merge

func (m *ReceiptRequest) XXX_Merge(src proto.Message)

func (*ReceiptRequest) XXX_Size

func (m *ReceiptRequest) XXX_Size() int

func (*ReceiptRequest) XXX_Unmarshal

func (m *ReceiptRequest) XXX_Unmarshal(b []byte) error

type Stream

type Stream struct {
	Reader *bufio.Reader

	// For UDS: based on associated creds.
	// For TLS: cert public key
	RemoteID string

	Writer *io.Writer
	// contains filtered or unexported fields
}

type SubscribeRequest

type SubscribeRequest struct {
	// A UA should group subscriptions in a set. First request from a
	// UA will not include a set - it is typically a subscription associated with
	// the UA itself.
	PushSet string `protobuf:"bytes,1,opt,name=push_set,proto3" json:"push_set,omitempty"`
	// Included as Crypto-Key: p256ecdsa parameter.
	// Corresponds to the applicationServerKey parameter in the PushSubscriptionOptions in
	// the W3C API
	SenderVapid string `protobuf:"bytes,2,opt,name=sender_vapid,proto3" json:"sender_vapid,omitempty"`
}

func (*SubscribeRequest) Descriptor

func (*SubscribeRequest) Descriptor() ([]byte, []int)

func (*SubscribeRequest) GetPushSet

func (m *SubscribeRequest) GetPushSet() string

func (*SubscribeRequest) GetSenderVapid

func (m *SubscribeRequest) GetSenderVapid() string

func (*SubscribeRequest) Marshal

func (m *SubscribeRequest) Marshal() (dAtA []byte, err error)

func (*SubscribeRequest) MarshalTo

func (m *SubscribeRequest) MarshalTo(dAtA []byte) (int, error)

func (*SubscribeRequest) MarshalToSizedBuffer

func (m *SubscribeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*SubscribeRequest) ProtoMessage

func (*SubscribeRequest) ProtoMessage()

func (*SubscribeRequest) Reset

func (m *SubscribeRequest) Reset()

func (*SubscribeRequest) Size

func (m *SubscribeRequest) Size() (n int)

func (*SubscribeRequest) String

func (m *SubscribeRequest) String() string

func (*SubscribeRequest) Unmarshal

func (m *SubscribeRequest) Unmarshal(dAtA []byte) error

func (*SubscribeRequest) XXX_DiscardUnknown

func (m *SubscribeRequest) XXX_DiscardUnknown()

func (*SubscribeRequest) XXX_Marshal

func (m *SubscribeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SubscribeRequest) XXX_Merge

func (m *SubscribeRequest) XXX_Merge(src proto.Message)

func (*SubscribeRequest) XXX_Size

func (m *SubscribeRequest) XXX_Size() int

func (*SubscribeRequest) XXX_Unmarshal

func (m *SubscribeRequest) XXX_Unmarshal(b []byte) error

type SubscribeResponse

type SubscribeResponse struct {
	// Returned as Link: rel="urn:ietf:params:push"
	// Spec examples use a full path ( /push/xxxx1 )
	// TODO: clarify if it can be a full URL
	Push string `protobuf:"bytes,1,opt,name=push,proto3" json:"push,omitempty"`
	// Optional response: it
	// returned as Link: rel=urn:ietf:params:push:set
	// Spec examples use a full path ( /subscription-set/xxxx2 ).
	// TODO: clarify it can be a full URL, like subscription
	PushSet string `protobuf:"bytes,2,opt,name=push_set,proto3" json:"push_set,omitempty"`
	// Push subscription resource. This is the full URL where the UA will use to
	// receive the messages, using the PUSH promise http2 frame.
	//
	//
	// Returned as Location header in the spec
	Location string `protobuf:"bytes,3,opt,name=location,proto3" json:"location,omitempty"`
}

Subscribe response includes the elements in the spec.

func (*SubscribeResponse) Descriptor

func (*SubscribeResponse) Descriptor() ([]byte, []int)

func (*SubscribeResponse) GetLocation

func (m *SubscribeResponse) GetLocation() string

func (*SubscribeResponse) GetPush

func (m *SubscribeResponse) GetPush() string

func (*SubscribeResponse) GetPushSet

func (m *SubscribeResponse) GetPushSet() string

func (*SubscribeResponse) Marshal

func (m *SubscribeResponse) Marshal() (dAtA []byte, err error)

func (*SubscribeResponse) MarshalTo

func (m *SubscribeResponse) MarshalTo(dAtA []byte) (int, error)

func (*SubscribeResponse) MarshalToSizedBuffer

func (m *SubscribeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*SubscribeResponse) ProtoMessage

func (*SubscribeResponse) ProtoMessage()

func (*SubscribeResponse) Reset

func (m *SubscribeResponse) Reset()

func (*SubscribeResponse) Size

func (m *SubscribeResponse) Size() (n int)

func (*SubscribeResponse) String

func (m *SubscribeResponse) String() string

func (*SubscribeResponse) Unmarshal

func (m *SubscribeResponse) Unmarshal(dAtA []byte) error

func (*SubscribeResponse) XXX_DiscardUnknown

func (m *SubscribeResponse) XXX_DiscardUnknown()

func (*SubscribeResponse) XXX_Marshal

func (m *SubscribeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SubscribeResponse) XXX_Merge

func (m *SubscribeResponse) XXX_Merge(src proto.Message)

func (*SubscribeResponse) XXX_Size

func (m *SubscribeResponse) XXX_Size() int

func (*SubscribeResponse) XXX_Unmarshal

func (m *SubscribeResponse) XXX_Unmarshal(b []byte) error

type UA

type UA struct {
	// URL of the subscribe for the push service
	PushService string
}

UA represents a "user agent" - or client using the webpush protocol

func (*UA) Subscribe

func (ua *UA) Subscribe() (sub *auth.Subscription, err error)

Create a subscription, using the Webpush standard protocol.

URL is "/subscribe", no header required ( but passing a VAPID or mtls), response in 'location' for read and Link for sub endpoint.

type Vapid

type Vapid struct {
	// json payload of VAPID ( without base64 encoding)
	// Can also be a proto message when used over other transports.
	Data []byte `protobuf:"bytes,7,opt,name=data,proto3" json:"data,omitempty"`
	// Public key of the signer, 64 bytes, EC256.
	// Included in 'k' parameter for HTTP.
	K []byte `protobuf:"bytes,4,opt,name=k,proto3" json:"k,omitempty"`
	// If empty, it is assumed to be the constant value {typ=JWT,alg=ES256}
	TType []byte `protobuf:"bytes,32,opt,name=t_type,proto3" json:"t_type,omitempty"`
	// If empty, signatureX and signatureY will be used, with the constant prefix
	// This reduces the size of the packet when in binary - verification is still over
	// JSON format
	TSignature []byte `protobuf:"bytes,33,opt,name=t_signature,proto3" json:"t_signature,omitempty"`
	SignatureX []byte `protobuf:"bytes,5,opt,name=signatureX,proto3" json:"signatureX,omitempty"`
	SignatureY []byte `protobuf:"bytes,6,opt,name=signatureY,proto3" json:"signatureY,omitempty"`
}

Vapid is the proto variant of a Webpush JWT.

For HTTP, included in Authorization header: Authorization: vapid t=B64url k=B64url

Decoded t is of form: { "typ": "JWT", "alg": "ES256" }

{ "crv":"P-256",

"kty":"EC",
"x":"DUfHPKLVFQzVvnCPGyfucbECzPDa7rWbXriLcysAjEc",
"y":"F6YK5h4SDYic-dRuU_RCPCfA5aq9ojSwk5Y2EmClBPs" }

func (*Vapid) Descriptor

func (*Vapid) Descriptor() ([]byte, []int)

func (*Vapid) GetData

func (m *Vapid) GetData() []byte

func (*Vapid) GetK

func (m *Vapid) GetK() []byte

func (*Vapid) GetSignatureX

func (m *Vapid) GetSignatureX() []byte

func (*Vapid) GetSignatureY

func (m *Vapid) GetSignatureY() []byte

func (*Vapid) GetTSignature

func (m *Vapid) GetTSignature() []byte

func (*Vapid) GetTType

func (m *Vapid) GetTType() []byte

func (*Vapid) Marshal

func (m *Vapid) Marshal() (dAtA []byte, err error)

func (*Vapid) MarshalTo

func (m *Vapid) MarshalTo(dAtA []byte) (int, error)

func (*Vapid) MarshalToSizedBuffer

func (m *Vapid) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Vapid) ProtoMessage

func (*Vapid) ProtoMessage()

func (*Vapid) Reset

func (m *Vapid) Reset()

func (*Vapid) Size

func (m *Vapid) Size() (n int)

func (*Vapid) String

func (m *Vapid) String() string

func (*Vapid) Unmarshal

func (m *Vapid) Unmarshal(dAtA []byte) error

func (*Vapid) XXX_DiscardUnknown

func (m *Vapid) XXX_DiscardUnknown()

func (*Vapid) XXX_Marshal

func (m *Vapid) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Vapid) XXX_Merge

func (m *Vapid) XXX_Merge(src proto.Message)

func (*Vapid) XXX_Size

func (m *Vapid) XXX_Size() int

func (*Vapid) XXX_Unmarshal

func (m *Vapid) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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