From fbfcc7698331ad0c077f7a2bd10fb48669576a3d Mon Sep 17 00:00:00 2001 From: Eugene K Date: Wed, 26 Feb 2020 08:07:22 -0500 Subject: [PATCH] checkpoint --- controller/model/service_model.go | 2 ++ controller/persistence/edge_service_store_test.go | 3 +++ gateway/xgress_edge/dialer.go | 5 +++-- gateway/xgress_edge/listener.go | 7 +++++-- go.mod | 7 ++++--- go.sum | 3 +++ 6 files changed, 20 insertions(+), 7 deletions(-) diff --git a/controller/model/service_model.go b/controller/model/service_model.go index 8ceaaec6c..39936c784 100644 --- a/controller/model/service_model.go +++ b/controller/model/service_model.go @@ -34,6 +34,8 @@ type Service struct { Name string `json:"name"` EgressRouter string `json:"egressRouter"` EndpointAddress string `json:"endpointAddress"` + PublicKey []byte `json:"publicKey"` + EdgeRouterRoles []string `json:"edgeRouterRoles"` RoleAttributes []string `json:"roleAttributes"` Configs []string `json:"configs"` } diff --git a/controller/persistence/edge_service_store_test.go b/controller/persistence/edge_service_store_test.go index 5241b9ccb..1e6eaa190 100644 --- a/controller/persistence/edge_service_store_test.go +++ b/controller/persistence/edge_service_store_test.go @@ -17,6 +17,7 @@ package persistence import ( + "crypto/rand" "fmt" "testing" "time" @@ -229,6 +230,8 @@ func (ctx *TestContext) testUpdateServices(_ *testing.T) { service.Binding = uuid.New().String() service.EndpointAddress = uuid.New().String() service.Egress = uuid.New().String() + service.PubKey = make([]byte, 32) + rand.Read(service.PubKey) service.UpdatedAt = earlier service.CreatedAt = now service.Tags = tags diff --git a/gateway/xgress_edge/dialer.go b/gateway/xgress_edge/dialer.go index 72d77c9eb..c7fc2bd03 100644 --- a/gateway/xgress_edge/dialer.go +++ b/gateway/xgress_edge/dialer.go @@ -51,8 +51,9 @@ func (dialer *dialer) Dial(destination string, sessionId *identity.TokenId, addr } token := destParts[1] - - log.Debug("looking up hosted service conn") + log.Error("key", string(sessionId.Data[0xED6E])) + + log.Debug("looking up hosted service conn", len(sessionId.Data)) listenConn, found := dialer.factory.hostedServices.Get(token) if !found { return fmt.Errorf("host for token '%v' not found", token) diff --git a/gateway/xgress_edge/listener.go b/gateway/xgress_edge/listener.go index 7668e424d..9d1eebc43 100644 --- a/gateway/xgress_edge/listener.go +++ b/gateway/xgress_edge/listener.go @@ -152,7 +152,9 @@ func (proxy *ingressProxy) processConnect(req *channel2.Message, ch channel2.Cha // fabric connect log.Debug("dialing fabric") - sessionInfo, err := xgress.GetSession(proxy.listener.factory, ns.Token, ns.Service.Id) + hints := make(map[uint32][]byte) + hints[0xED6E] = []byte("this be the key") + sessionInfo, err := xgress.GetSession(proxy.listener.factory, ns.Token, ns.Service.Id, hints) if err != nil { log.Warn("failed to dial fabric ", err) proxy.sendStateClosedReply(err.Error(), req) @@ -173,6 +175,7 @@ func (proxy *ingressProxy) processConnect(req *channel2.Message, ch channel2.Cha func (proxy *ingressProxy) processBind(req *channel2.Message, ch channel2.Channel) { token := string(req.Body) + pubKey := req.Headers[edge.PublicKeyHeader] log := pfxlog.ContextLogger(ch.Label()).WithField("sessionId", token).WithFields(edge.GetLoggerFields(req)) connId, found := req.GetUint32Header(edge.ConnIdHeader) if !found { @@ -199,7 +202,7 @@ func (proxy *ingressProxy) processBind(req *channel2.Message, ch channel2.Channe } log.Debug("binding service") - if err := xgress.BindService(proxy.listener.factory, token, ns.Service.Id); err != nil { + if err := xgress.BindService(proxy.listener.factory, token, ns.Service.Id, pubKey); err != nil { proxy.sendStateClosedReply(err.Error(), req) return } diff --git a/go.mod b/go.mod index ef5c9a100..20b8735df 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,9 @@ module github.com/netfoundry/ziti-edge go 1.13 // replace github.com/netfoundry/ziti-foundation => ../ziti-foundation -// replace github.com/netfoundry/ziti-fabric => ../ziti-fabric -// replace github.com/netfoundry/ziti-sdk-golang => ../ziti-sdk-golang +replace github.com/netfoundry/ziti-fabric => ../ziti-fabric + +replace github.com/netfoundry/ziti-sdk-golang => ../ziti-sdk-golang require ( github.com/Jeffail/gabs v1.4.0 @@ -44,7 +45,7 @@ require ( github.com/stretchr/testify v1.3.0 github.com/xeipuuv/gojsonschema v1.2.0 go.etcd.io/bbolt v1.3.3 - golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708 + golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72 golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9 gopkg.in/Masterminds/squirrel.v1 v1.0.0-20170825200431-a6b93000bd21 gopkg.in/oleiade/reflections.v1 v1.0.0 diff --git a/go.sum b/go.sum index 7b1d8e16d..a756e1cd7 100644 --- a/go.sum +++ b/go.sum @@ -169,8 +169,10 @@ github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrk github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/netfoundry/secretstream v0.1.1/go.mod h1:uasYkYSp0MmNSlKOWJ2sVzxPms8e58TS4ENq4yro86k= github.com/netfoundry/ziti-fabric v0.9.3 h1:qmBRJCYWJxMBFyiTNQfLKzHumcg+NLa/ONrQYyFhajY= github.com/netfoundry/ziti-fabric v0.9.3/go.mod h1:FLh8+4Qma4iC73iKYpWEbOgtVgYdwxxn/Pm0/NDcqd8= +github.com/netfoundry/ziti-foundation v0.6.0/go.mod h1:27kvN9RZk7cpt2xba6owuXktNphq5hPK62CAiKnIS10= github.com/netfoundry/ziti-foundation v0.6.1/go.mod h1:27kvN9RZk7cpt2xba6owuXktNphq5hPK62CAiKnIS10= github.com/netfoundry/ziti-foundation v0.6.5 h1:csIX4eMBM8p/UvoDioBByGpqOAxA3Wn2dOPY1xaGLSE= github.com/netfoundry/ziti-foundation v0.6.5/go.mod h1:D2kU4O23O3Ll+v34tidLYr/jNhigiHM0Mz8fKuIJu7E= @@ -251,6 +253,7 @@ golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708 h1:pXVtWnwHkrWD9ru3sDxY/qFK/bfc0egRovX91EjWjf4= golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=