From d0910ed07e948f65bf8502164c43b84dfc92e326 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 3 Jun 2020 02:00:38 -0600 Subject: [PATCH] file reorganization --- cmd/telebit-relay/telebit-relay.go | 17 ++++++++--------- mplexer/mgmt-prereg.sh | 1 - relay/mplexy/mplexy.go | 3 ++- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/cmd/telebit-relay/telebit-relay.go b/cmd/telebit-relay/telebit-relay.go index e434266..88297d2 100644 --- a/cmd/telebit-relay/telebit-relay.go +++ b/cmd/telebit-relay/telebit-relay.go @@ -20,7 +20,6 @@ import ( "git.coolaj86.com/coolaj86/go-telebitd/mplexer/dns01" "git.coolaj86.com/coolaj86/go-telebitd/relay" "git.coolaj86.com/coolaj86/go-telebitd/relay/api" - "git.coolaj86.com/coolaj86/go-telebitd/relay/mplexy" //jwt "github.com/dgrijalva/jwt-go" "github.com/caddyserver/certmagic" @@ -245,7 +244,7 @@ func main() { }, } - authorizer := func(r *http.Request) (*mplexy.Authz, error) { + authorizer := func(r *http.Request) (*telebit.Grants, error) { // do we have a valid wss_client? var tokenString string @@ -272,15 +271,15 @@ func main() { */ /* - domains := []string{} - for _, name := range tok.Claims.(jwt.MapClaims)["domains"].([]interface{}) { - domains = append(domains, name.(string)) + domains := []string{} + for _, name := range tok.Claims.(jwt.MapClaims)["domains"].([]interface{}) { + domains = append(domains, name.(string)) + } + authz := &mplexy.Authz{ + Domains: grants.Domains, } */ - authz := &mplexy.Authz{ - Domains: grants.Domains, - } - return authz, err + return grants, err /* tokenString := r.URL.Query().Get("access_token") diff --git a/mplexer/mgmt-prereg.sh b/mplexer/mgmt-prereg.sh index 5d946be..cbd1ea0 100644 --- a/mplexer/mgmt-prereg.sh +++ b/mplexer/mgmt-prereg.sh @@ -2,7 +2,6 @@ TOKEN=$(go run cmd/signjwt/*.go) echo "TOKEN: $TOKEN" my_shared="k7nsLSwNKbOeBhDFpbhwGHv" -my_domain="duckdns.org" my_client="rooted" curl -X POST http://roottest.duckdns.org:3010/api/devices \ -H "Authorization: Bearer ${TOKEN}" \ diff --git a/relay/mplexy/mplexy.go b/relay/mplexy/mplexy.go index db577d5..6d0f175 100644 --- a/relay/mplexy/mplexy.go +++ b/relay/mplexy/mplexy.go @@ -7,6 +7,7 @@ import ( "net/http" "git.coolaj86.com/coolaj86/go-telebitd/log" + telebit "git.coolaj86.com/coolaj86/go-telebitd/mplexer" "git.coolaj86.com/coolaj86/go-telebitd/relay/api" ) @@ -34,7 +35,7 @@ type Authz struct { } // Authorizer is called when a new client connects and we need to know something about it -type Authorizer func(*http.Request) (*Authz, error) +type Authorizer func(*http.Request) (*telebit.Grants, error) const ( listenerAdded ListenerRegistrationStatus = iota