ans

package
v1.0.7 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OidPushDevelop    = asn1.ObjectIdentifier([]int{1, 2, 840, 113635, 100, 6, 3, 1})
	OidPushProduction = asn1.ObjectIdentifier([]int{1, 2, 840, 113635, 100, 6, 3, 2})
	OidVoIPTopics     = asn1.ObjectIdentifier([]int{1, 2, 840, 113635, 100, 6, 3, 6})
	OidVoIP           = asn1.ObjectIdentifier([]int{1, 2, 840, 113635, 100, 6, 3, 5})
)

oid info: https://images.apple.com/certificateauthority/pdf/Apple_WWDR_CPS_v1.20.pdf https://github.com/SilentCircle/apns_tools/blob/master/FakeAppleWWDRCA.cfg

Functions

func CheckVoIPTopicByCert

func CheckVoIPTopicByCert(topic string, cert *tls.Certificate) error

func ExistOID

func ExistOID(cert *tls.Certificate, oid asn1.ObjectIdentifier) (bool, error)

func GetOIDValue

func GetOIDValue(cert *tls.Certificate, oid asn1.ObjectIdentifier) ([][]byte, error)

func GetTopics

func GetTopics(src []byte) ([]string, error)

GetTopics returns topics from certificate extension value Binary data format: <block start=0x30> <block size=0xD> <value start=0xc> <value size=0x2> <value byte 1> <value byte 2> <block start=0x30> <block size=0x3> <value start=0xc> <value size=0x1> <value byte 1> <value start=0xc> <value size=0x2> <value byte 1> <value byte 2>

Types

type Client

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

func New

func New(certTLS *tls.Certificate, isSandbox bool, retries int, timeout time.Duration) (*Client, error)

func NewFromPem

func NewFromPem(pemData []byte, isSandbox bool, retries int, timeout time.Duration) (*Client, error)

func (*Client) Certificate

func (c *Client) Certificate() tls.Certificate

func (*Client) Sandbox

func (c *Client) Sandbox() bool

func (*Client) Send

func (c *Client) Send(ctx context.Context, message *Request) (retval *Response, err error)

func (*Client) SupportsVoIP

func (c *Client) SupportsVoIP() bool

type Request

type Request struct {
	Token   string        `json:"token,omitempty"`
	Headers RequestHeader `json:"headers,omitempty"`

	// Payload format:
	// https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/PayloadKeyReference.html#//apple_ref/doc/uid/TP40008194-CH17-SW1
	Payload json.RawMessage `json:"payload,omitempty"`
}

func (Request) MarshalEasyJSON

func (v Request) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Request) MarshalJSON

func (v Request) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Request) SetToken

func (r *Request) SetToken(token string)

func (*Request) ShouldIgnore added in v1.0.2

func (r *Request) ShouldIgnore() bool

func (*Request) UnmarshalEasyJSON

func (v *Request) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Request) UnmarshalJSON

func (v *Request) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type RequestHeader

type RequestHeader struct {
	ID         string    `json:"id,omitempty"`
	Expiration time.Time `json:"expiration,omitempty"`
	Priority   int       `json:"priority,omitempty"`
	Topic      string    `json:"topic,omitempty"`
	CollapseID string    `json:"collapse-id,omitempty"`
}

RequestHeader format: Table 8-2 APNs request headers - https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html#//apple_ref/doc/uid/TP40008194-CH11-SW1

func (RequestHeader) MarshalEasyJSON

func (v RequestHeader) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (RequestHeader) MarshalJSON

func (v RequestHeader) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*RequestHeader) UnmarshalEasyJSON

func (v *RequestHeader) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*RequestHeader) UnmarshalJSON

func (v *RequestHeader) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Response

type Response struct {
	ID         string       `json:"id"`
	StatusCode int          `json:"status_code"`
	Body       ResponseBody `json:"body"`
}

Response format Table 8-3 APNs response headers, Table 8-5 APNs JSON data keys - https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html#//apple_ref/doc/uid/TP40008194-CH11-SW1

func NewResponse

func NewResponse(id string, statusCode int) *Response

func (Response) MarshalEasyJSON

func (v Response) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Response) MarshalJSON

func (v Response) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Response) UnmarshalEasyJSON

func (v *Response) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Response) UnmarshalJSON

func (v *Response) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type ResponseBody

type ResponseBody struct {
	Reason    string `json:"reason"`
	Timestamp int64  `json:"timestamp"`
}

Table 8-5APNs JSON data keys https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html#//apple_ref/doc/uid/TP40008194-CH11-SW1

func (*ResponseBody) GetTimestamp

func (r *ResponseBody) GetTimestamp() time.Time

func (ResponseBody) MarshalEasyJSON

func (v ResponseBody) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ResponseBody) MarshalJSON

func (v ResponseBody) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*ResponseBody) UnmarshalEasyJSON

func (v *ResponseBody) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ResponseBody) UnmarshalJSON

func (v *ResponseBody) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

Jump to

Keyboard shortcuts

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