From f54936467101bb08bbdf7f3d9c341134c06b83c3 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Wed, 16 Dec 2015 15:49:04 -0500 Subject: Updating go dependancies --- .../src/github.com/anachronistic/apns/feedback.go | 102 --------------------- 1 file changed, 102 deletions(-) delete mode 100644 Godeps/_workspace/src/github.com/anachronistic/apns/feedback.go (limited to 'Godeps/_workspace/src/github.com/anachronistic/apns/feedback.go') diff --git a/Godeps/_workspace/src/github.com/anachronistic/apns/feedback.go b/Godeps/_workspace/src/github.com/anachronistic/apns/feedback.go deleted file mode 100644 index 32e7f0f15..000000000 --- a/Godeps/_workspace/src/github.com/anachronistic/apns/feedback.go +++ /dev/null @@ -1,102 +0,0 @@ -package apns - -import ( - "bytes" - "crypto/tls" - "encoding/binary" - "encoding/hex" - "errors" - "net" - "strings" - "time" -) - -// Wait at most this many seconds for feedback data from Apple. -const FeedbackTimeoutSeconds = 5 - -// FeedbackChannel will receive individual responses from Apple. -var FeedbackChannel = make(chan (*FeedbackResponse)) - -// If there's nothing to read, ShutdownChannel gets a true. -var ShutdownChannel = make(chan bool) - -// FeedbackResponse represents a device token that Apple has -// indicated should not be sent to in the future. -type FeedbackResponse struct { - Timestamp uint32 - DeviceToken string -} - -// NewFeedbackResponse creates and returns a FeedbackResponse structure. -func NewFeedbackResponse() (resp *FeedbackResponse) { - resp = new(FeedbackResponse) - return -} - -// ListenForFeedback connects to the Apple Feedback Service -// and checks for device tokens. -// -// Feedback consists of device tokens that should -// not be sent to in the future; Apple *does* monitor that -// you respect this so you should be checking it ;) -func (client *Client) ListenForFeedback() (err error) { - var cert tls.Certificate - - if len(client.CertificateBase64) == 0 && len(client.KeyBase64) == 0 { - // The user did not specify raw block contents, so check the filesystem. - cert, err = tls.LoadX509KeyPair(client.CertificateFile, client.KeyFile) - } else { - // The user provided the raw block contents, so use that. - cert, err = tls.X509KeyPair([]byte(client.CertificateBase64), []byte(client.KeyBase64)) - } - - if err != nil { - return err - } - - gatewayParts := strings.Split(client.Gateway, ":") - conf := &tls.Config{ - Certificates: []tls.Certificate{cert}, - ServerName: gatewayParts[0], - } - - conn, err := net.Dial("tcp", client.Gateway) - if err != nil { - return err - } - defer conn.Close() - conn.SetReadDeadline(time.Now().Add(FeedbackTimeoutSeconds * time.Second)) - - tlsConn := tls.Client(conn, conf) - err = tlsConn.Handshake() - if err != nil { - return err - } - - var tokenLength uint16 - buffer := make([]byte, 38, 38) - deviceToken := make([]byte, 32, 32) - - for { - _, err := tlsConn.Read(buffer) - if err != nil { - ShutdownChannel <- true - break - } - - resp := NewFeedbackResponse() - - r := bytes.NewReader(buffer) - binary.Read(r, binary.BigEndian, &resp.Timestamp) - binary.Read(r, binary.BigEndian, &tokenLength) - binary.Read(r, binary.BigEndian, &deviceToken) - if tokenLength != 32 { - return errors.New("token length should be equal to 32, but isn't") - } - resp.DeviceToken = hex.EncodeToString(deviceToken) - - FeedbackChannel <- resp - } - - return nil -} -- cgit v1.2.3-1-g7c22