mirror of
https://github.com/openziti/ziti.git
synced 2026-10-14 16:19:57 +00:00
Merge pull request #750 from openziti/fixes
More session -> circuit fixes. Fix patch on service edge router polic…
This commit is contained in:
@@ -96,7 +96,7 @@ func (self *createCircuitHandler) CreateCircuit(ctx *CreateCircuitRequestContext
|
||||
log := pfxlog.ContextLogger(self.ch.Label()).WithField("token", ctx.req.SessionToken)
|
||||
|
||||
response := &edge_ctrl_pb.CreateCircuitResponse{
|
||||
SessionId: circuitInfo.Id,
|
||||
CircuitId: circuitInfo.Id,
|
||||
Address: circuitInfo.Path.IngressId,
|
||||
PeerData: peerData,
|
||||
}
|
||||
|
||||
@@ -53,20 +53,14 @@ func (entity *ServiceEdgeRouterPolicy) SetValues(ctx *boltz.PersistContext) {
|
||||
ctx.Bucket.SetError(err)
|
||||
}
|
||||
|
||||
if !isSemanticValid(entity.Semantic) {
|
||||
if ctx.ProceedWithSet(FieldSemantic) && !isSemanticValid(entity.Semantic) {
|
||||
ctx.Bucket.SetError(errorz.NewFieldError("invalid semantic", FieldSemantic, entity.Semantic))
|
||||
return
|
||||
}
|
||||
|
||||
entity.SetBaseValues(ctx)
|
||||
ctx.SetRequiredString(FieldName, entity.Name)
|
||||
if ctx.ProceedWithSet(FieldSemantic) {
|
||||
if !isSemanticValid(entity.Semantic) {
|
||||
ctx.Bucket.SetError(errorz.NewFieldError("invalid semantic", FieldSemantic, entity.Semantic))
|
||||
return
|
||||
}
|
||||
ctx.SetRequiredString(FieldSemantic, entity.Semantic)
|
||||
}
|
||||
ctx.SetRequiredString(FieldSemantic, entity.Semantic)
|
||||
|
||||
serviceEdgeRouterPolicyStore := ctx.Store.(*serviceEdgeRouterPolicyStoreImpl)
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ func (d Decoder) Decode(msg *channel2.Message) ([]byte, bool) {
|
||||
request := &CreateCircuitResponse{}
|
||||
if err := proto.Unmarshal(msg.Body, request); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "Create Circuit Response")
|
||||
meta["sessionId"] = request.SessionId
|
||||
meta["circuitId"] = request.CircuitId
|
||||
meta["address"] = request.Address
|
||||
return meta.MarshalResult()
|
||||
} else {
|
||||
|
||||
@@ -1114,7 +1114,7 @@ type CreateCircuitResponse struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
SessionId string `protobuf:"bytes,1,opt,name=sessionId,proto3" json:"sessionId,omitempty"`
|
||||
CircuitId string `protobuf:"bytes,1,opt,name=circuitId,proto3" json:"circuitId,omitempty"`
|
||||
Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"`
|
||||
PeerData map[uint32][]byte `protobuf:"bytes,3,rep,name=peerData,proto3" json:"peerData,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
}
|
||||
@@ -1151,9 +1151,9 @@ func (*CreateCircuitResponse) Descriptor() ([]byte, []int) {
|
||||
return file_edge_ctrl_proto_rawDescGZIP(), []int{13}
|
||||
}
|
||||
|
||||
func (x *CreateCircuitResponse) GetSessionId() string {
|
||||
func (x *CreateCircuitResponse) GetCircuitId() string {
|
||||
if x != nil {
|
||||
return x.SessionId
|
||||
return x.CircuitId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@@ -2687,8 +2687,8 @@ var file_edge_ctrl_proto_rawDesc = []byte{
|
||||
0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76,
|
||||
0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xe0, 0x01, 0x0a, 0x15, 0x43, 0x72, 0x65,
|
||||
0x61, 0x74, 0x65, 0x43, 0x69, 0x72, 0x63, 0x75, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
|
||||
0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64,
|
||||
0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x69, 0x72, 0x63, 0x75, 0x69, 0x74, 0x49, 0x64, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x69, 0x72, 0x63, 0x75, 0x69, 0x74, 0x49, 0x64,
|
||||
0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x52, 0x0a, 0x08, 0x70, 0x65,
|
||||
0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x36, 0x2e, 0x7a,
|
||||
|
||||
@@ -137,7 +137,7 @@ message CreateCircuitRequest {
|
||||
}
|
||||
|
||||
message CreateCircuitResponse {
|
||||
string sessionId = 1;
|
||||
string circuitId = 1;
|
||||
string address = 2;
|
||||
map<uint32, bytes> peerData = 3;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ func newDialer(factory *Factory, options *Options) xgress.Dialer {
|
||||
return txd
|
||||
}
|
||||
|
||||
func (dialer *dialer) Dial(destination string, sessionId *identity.TokenId, address xgress.Address, bindHandler xgress.BindHandler, ctx logcontext.Context) (xt.PeerData, error) {
|
||||
func (dialer *dialer) Dial(destination string, circuitId *identity.TokenId, address xgress.Address, bindHandler xgress.BindHandler, ctx logcontext.Context) (xt.PeerData, error) {
|
||||
log := pfxlog.ChannelLogger(logcontext.EstablishPath).Wire(ctx).
|
||||
WithField("binding", "edge").
|
||||
WithField("destination", destination)
|
||||
@@ -84,19 +84,19 @@ func (dialer *dialer) Dial(destination string, sessionId *identity.TokenId, addr
|
||||
log = log.WithField("bindConnId", listenConn.Id())
|
||||
|
||||
callerId := ""
|
||||
if sessionId.Data != nil {
|
||||
if callerIdBytes, found := sessionId.Data[edge.CallerIdHeader]; found {
|
||||
if circuitId.Data != nil {
|
||||
if callerIdBytes, found := circuitId.Data[edge.CallerIdHeader]; found {
|
||||
callerId = string(callerIdBytes)
|
||||
}
|
||||
}
|
||||
|
||||
log.Debug("dialing sdk client hosting service")
|
||||
dialRequest := edge.NewDialMsg(listenConn.Id(), token, callerId)
|
||||
if pk, ok := sessionId.Data[edge.PublicKeyHeader]; ok {
|
||||
if pk, ok := circuitId.Data[edge.PublicKeyHeader]; ok {
|
||||
dialRequest.Headers[edge.PublicKeyHeader] = pk
|
||||
}
|
||||
|
||||
appData, hasAppData := sessionId.Data[edge.AppDataHeader]
|
||||
appData, hasAppData := circuitId.Data[edge.AppDataHeader]
|
||||
if hasAppData {
|
||||
dialRequest.Headers[edge.AppDataHeader] = appData
|
||||
}
|
||||
@@ -114,7 +114,7 @@ func (dialer *dialer) Dial(destination string, sessionId *identity.TokenId, addr
|
||||
|
||||
// On the terminator, which this is, this only starts the txer, which pulls data from the link
|
||||
// Since the opposing xgress doesn't start until this call returns, nothing should be coming this way yet
|
||||
x := xgress.NewXgress(sessionId, address, conn, xgress.Terminator, &dialer.options.Options)
|
||||
x := xgress.NewXgress(circuitId, address, conn, xgress.Terminator, &dialer.options.Options)
|
||||
bindHandler.HandleXgressBind(x)
|
||||
x.Start()
|
||||
|
||||
@@ -170,7 +170,7 @@ func (dialer *dialer) Dial(destination string, sessionId *identity.TokenId, addr
|
||||
return nil, errors.Wrapf(err, "failed to create edge xgress conn for token %v", token)
|
||||
}
|
||||
|
||||
x := xgress.NewXgress(sessionId, address, conn, xgress.Terminator, &dialer.options.Options)
|
||||
x := xgress.NewXgress(circuitId, address, conn, xgress.Terminator, &dialer.options.Options)
|
||||
bindHandler.HandleXgressBind(x)
|
||||
x.Start()
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ func (self *edgeClientConn) processConnect(req *channel2.Message, ch channel2.Ch
|
||||
return
|
||||
}
|
||||
|
||||
x := xgress.NewXgress(&identity.TokenId{Token: response.SessionId}, xgress.Address(response.Address), conn, xgress.Initiator, &self.listener.options.Options)
|
||||
x := xgress.NewXgress(&identity.TokenId{Token: response.CircuitId}, xgress.Address(response.Address), conn, xgress.Initiator, &self.listener.options.Options)
|
||||
self.listener.bindHandler.HandleXgressBind(x)
|
||||
|
||||
// send the state_connected before starting the xgress. That way we can't get a state_closed before we get state_connected
|
||||
|
||||
@@ -45,7 +45,7 @@ func newDialer(ctrl xgress.CtrlChannel, options *xgress.Options) (xgress.Dialer,
|
||||
return txd, nil
|
||||
}
|
||||
|
||||
func (txd *dialer) Dial(destination string, sessionId *identity.TokenId, address xgress.Address, bindHandler xgress.BindHandler, ctx logcontext.Context) (xt.PeerData, error) {
|
||||
func (txd *dialer) Dial(destination string, circuitId *identity.TokenId, address xgress.Address, bindHandler xgress.BindHandler, ctx logcontext.Context) (xt.PeerData, error) {
|
||||
log := pfxlog.ChannelLogger(logcontext.EstablishPath).Wire(ctx).
|
||||
WithField("binding", "edge_transport").
|
||||
WithField("destination", destination)
|
||||
@@ -56,16 +56,16 @@ func (txd *dialer) Dial(destination string, sessionId *identity.TokenId, address
|
||||
}
|
||||
|
||||
log.Debug("dialing")
|
||||
peer, err := txDestination.Dial("x/"+sessionId.Token, sessionId, txd.options.ConnectTimeout, nil)
|
||||
peer, err := txDestination.Dial("x/"+circuitId.Token, circuitId, txd.options.ConnectTimeout, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Infof("successful connection to %v from %v (s/%v)", destination, peer.Conn().LocalAddr(), sessionId.Token)
|
||||
log.Infof("successful connection to %v from %v (s/%v)", destination, peer.Conn().LocalAddr(), circuitId.Token)
|
||||
|
||||
xgConn := xgress_common.NewXgressConn(peer.Conn(), true)
|
||||
peerData := make(xt.PeerData, 1)
|
||||
if peerKey, ok := sessionId.Data[edge.PublicKeyHeader]; ok {
|
||||
if peerKey, ok := circuitId.Data[edge.PublicKeyHeader]; ok {
|
||||
if publicKey, err := xgConn.SetupServerCrypto(peerKey); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
@@ -73,7 +73,7 @@ func (txd *dialer) Dial(destination string, sessionId *identity.TokenId, address
|
||||
}
|
||||
}
|
||||
|
||||
x := xgress.NewXgress(sessionId, address, xgConn, xgress.Terminator, txd.options)
|
||||
x := xgress.NewXgress(circuitId, address, xgConn, xgress.Terminator, txd.options)
|
||||
bindHandler.HandleXgressBind(x)
|
||||
x.Start()
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ func (self *tunneler) IsTerminatorValid(_ string, destination string) bool {
|
||||
return found
|
||||
}
|
||||
|
||||
func (self *tunneler) Dial(destination string, sessionId *identity.TokenId, address xgress.Address, bindHandler xgress.BindHandler, ctx logcontext.Context) (xt.PeerData, error) {
|
||||
func (self *tunneler) Dial(destination string, circuitId *identity.TokenId, address xgress.Address, bindHandler xgress.BindHandler, ctx logcontext.Context) (xt.PeerData, error) {
|
||||
log := pfxlog.ChannelLogger(logcontext.EstablishPath).Wire(ctx).
|
||||
WithField("binding", "edge").
|
||||
WithField("destination", destination)
|
||||
@@ -44,7 +44,7 @@ func (self *tunneler) Dial(destination string, sessionId *identity.TokenId, addr
|
||||
}
|
||||
terminator := val.(*tunnelTerminator)
|
||||
|
||||
options, err := tunnel.AppDataToMap(sessionId.Data[edge.AppDataHeader])
|
||||
options, err := tunnel.AppDataToMap(circuitId.Data[edge.AppDataHeader])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -58,7 +58,7 @@ func (self *tunneler) Dial(destination string, sessionId *identity.TokenId, addr
|
||||
|
||||
xgConn := xgress_common.NewXgressConn(conn, halfClose)
|
||||
peerData := make(xt.PeerData, 1)
|
||||
if peerKey, ok := sessionId.Data[edge.PublicKeyHeader]; ok {
|
||||
if peerKey, ok := circuitId.Data[edge.PublicKeyHeader]; ok {
|
||||
if publicKey, err := xgConn.SetupServerCrypto(peerKey); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
@@ -66,7 +66,7 @@ func (self *tunneler) Dial(destination string, sessionId *identity.TokenId, addr
|
||||
}
|
||||
}
|
||||
|
||||
x := xgress.NewXgress(sessionId, address, xgConn, xgress.Terminator, self.dialOptions.Options)
|
||||
x := xgress.NewXgress(circuitId, address, xgConn, xgress.Terminator, self.dialOptions.Options)
|
||||
bindHandler.HandleXgressBind(x)
|
||||
x.Start()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user