add app id and client id

This commit is contained in:
AJ ONeal 2020-05-27 03:56:55 -06:00
parent 95c9c9e9db
commit f2975c9a4d
4 changed files with 20 additions and 1 deletions

1
go.mod
View File

@ -5,6 +5,7 @@ go 1.14
require (
git.rootprojects.org/root/go-gitver v1.1.3
github.com/caddyserver/certmagic v0.10.12
github.com/denisbrodbeck/machineid v1.0.1
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/go-acme/lego/v3 v3.7.0
github.com/go-chi/chi v4.1.1+incompatible

2
go.sum
View File

@ -74,6 +74,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:ma
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/denisbrodbeck/machineid v1.0.1 h1:geKr9qtkB876mXguW2X6TU4ZynleN6ezuMSRhl4D7AQ=
github.com/denisbrodbeck/machineid v1.0.1/go.mod h1:dJUwb7PTidGDeYyUBmXZ2GphQBbjJCrnectwCyxcUSI=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8=

View File

@ -4,6 +4,8 @@ package main
import (
"context"
"encoding/base64"
"encoding/hex"
"flag"
"fmt"
"log"
@ -17,6 +19,7 @@ import (
dns01 "git.coolaj86.com/coolaj86/go-telebitd/mplexer/dns01"
"github.com/caddyserver/certmagic"
"github.com/denisbrodbeck/machineid"
jwt "github.com/dgrijalva/jwt-go"
"github.com/go-acme/lego/v3/challenge"
"github.com/go-acme/lego/v3/providers/dns/duckdns"
@ -46,6 +49,7 @@ func main() {
var forwards []Forward
// TODO replace the websocket connection with a mock server
appID := flag.String("app-id", "telebit.io", "a unique identifier for a deploy target environment")
email := flag.String("acme-email", "", "email to use for Let's Encrypt / ACME registration")
certpath := flag.String("acme-storage", "./acme.d/", "path to ACME storage directory")
acmeAgree := flag.Bool("acme-agree", false, "agree to the terms of the ACME service provider (required)")
@ -60,9 +64,17 @@ func main() {
locals := flag.String("locals", "", "a list of <from-domain>:<to-port>")
flag.Parse()
muid, err := machineid.ProtectedID(*appID)
if nil != err {
fmt.Fprintf(os.Stderr, "unauthorized device")
os.Exit(1)
}
muidb, err := hex.DecodeString(muid)
muid = base64.RawURLEncoding.EncodeToString(muidb)
if len(os.Args) >= 2 {
if "version" == os.Args[1] {
fmt.Printf("telebit %s %s %s", GitVersion, GitRev, GitTimestamp)
fmt.Printf("telebit %s %s %s %s", GitVersion, GitRev[:7], GitTimestamp, muid[:24])
os.Exit(0)
}
}

4
vendor/modules.txt vendored
View File

@ -9,6 +9,9 @@ github.com/caddyserver/certmagic
github.com/cenkalti/backoff/v4
# github.com/davecgh/go-spew v1.1.1
github.com/davecgh/go-spew/spew
# github.com/denisbrodbeck/machineid v1.0.1
## explicit
github.com/denisbrodbeck/machineid
# github.com/dgrijalva/jwt-go v3.2.0+incompatible
## explicit
github.com/dgrijalva/jwt-go
@ -73,6 +76,7 @@ golang.org/x/net/ipv6
# golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527
golang.org/x/sys/unix
golang.org/x/sys/windows
golang.org/x/sys/windows/registry
# golang.org/x/text v0.3.2
golang.org/x/text/secure/bidirule
golang.org/x/text/transform