Skip to content

Commit

Permalink
integrate with equinox.
Browse files Browse the repository at this point in the history
  • Loading branch information
inconshreveable committed May 16, 2014
1 parent e90fe9f commit f22ce57
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/ngrok/client/update_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package client

import (
"fmt"
update "github.com/inconshreveable/go-update"
"github.com/inconshreveable/go-update/check"
"ngrok/client/mvc"
Expand All @@ -12,34 +11,35 @@ import (
"time"
)

const appId = ""
const (
appId = "ap_pJSFC5wQYkAyI0FIVwKYs9h1hW"
updateEndpoint = "https://api.equinox.io/1/Updates"
)

var publicKey []byte = []byte(
`-----BEGIN PUBLIC KEY-----
const publicKey = `-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0Gx8r9no1QBtCruJW2tu
082MJJ5ZA7k803GisR2c6WglPOD1b/+kUg+dx5Y0TKXz+uNlR3GrCxLh8WkoA95M
T38CQldIjoVN/bWP6jzFxL+6BRoKy5L1TcaIf3xb9B8OhwEq60cvFy7BBrLKEHJN
ua/D1S5axgNOAJ8tQ2w8gISICd84ng+U9tNMqIcEjUN89h3Z4zablfNIfVkbqbSR
fnkR9boUaMr6S1w8OeInjWdiab9sUr87GmEo/3tVxrHVCzHB8pzzoZceCkjgI551
d/hHfAl567YhlkQMNz8dawxBjQwCHHekgC8gAvTO7kmXkAm6YAbpa9kjwgnorPEP
ywIDAQAB
-----END PUBLIC KEY-----`)
var up *update.Update
var updateEndpoint = fmt.Sprintf("http://localhost:8889/1/Applications/%s/Update", appId)
-----END PUBLIC KEY-----`

func init() {
var err error
up, err = update.New().VerifySignatureWithPEM(publicKey)
func autoUpdate(s mvc.State, token string) {
up, err := update.New().VerifySignatureWithPEM([]byte(publicKey))
if err != nil {
panic(err)
log.Error("Failed to create update with signature: %v", err)
return
}

if err := up.CanUpdate(); err != nil {
log.Error("Can't update: insufficient permissions: %v", err)
}
}

func autoUpdate(s mvc.State, token string) {
update := func() (tryAgain bool) {
log.Info("Checking for update")
params := check.Params{
Version: 1,
AppId: appId,
AppVersion: version.MajorMinor(),
UserId: token,
Expand Down

0 comments on commit f22ce57

Please sign in to comment.