This commit is contained in:
Michael Quigley
2020-07-31 13:02:00 -04:00
parent ae78fa17f3
commit c4ca9cbe71
2 changed files with 10 additions and 8 deletions
+9 -8
View File
@@ -19,6 +19,7 @@ package xgress_edge
import (
"fmt"
"github.com/michaelquigley/pfxlog"
"github.com/openziti/fabric/controller/xt"
"github.com/openziti/fabric/router/xgress"
"github.com/openziti/foundation/identity/identity"
"github.com/openziti/sdk-golang/ziti/edge"
@@ -57,15 +58,15 @@ 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) error {
func (dialer *dialer) Dial(destination string, sessionId *identity.TokenId, address xgress.Address, bindHandler xgress.BindHandler) (xt.PeerData, error) {
log := pfxlog.Logger().WithField("token", sessionId.Token)
destParts := strings.Split(destination, ":")
if len(destParts) != 2 {
return fmt.Errorf("destination '%v' format is incorrect", destination)
return nil, fmt.Errorf("destination '%v' format is incorrect", destination)
}
if destParts[0] != "hosted" {
return fmt.Errorf("unsupported destination type: '%v'", destParts[0])
return nil, fmt.Errorf("unsupported destination type: '%v'", destParts[0])
}
token := destParts[1]
@@ -73,7 +74,7 @@ func (dialer *dialer) Dial(destination string, sessionId *identity.TokenId, addr
log.Debugf("looking up hosted service conn for token %v", token)
listenConn, found := dialer.factory.hostedServices.Get(token)
if !found {
return fmt.Errorf("host for token '%v' not found", token)
return nil, fmt.Errorf("host for token '%v' not found", token)
}
log.Debug("dialing sdk client hosting service")
@@ -82,16 +83,16 @@ func (dialer *dialer) Dial(destination string, sessionId *identity.TokenId, addr
reply, err := listenConn.SendAndWaitWithTimeout(dialRequest, 5*time.Second)
if err != nil {
return err
return nil, err
}
result, err := edge.UnmarshalDialResult(reply)
if err != nil {
return err
return nil, err
}
if !result.Success {
return fmt.Errorf("failed to establish connection with token %v. error: (%v)", token, result.Message)
return nil, fmt.Errorf("failed to establish connection with token %v. error: (%v)", token, result.Message)
}
conn := listenConn.newSink(result.NewConnId, dialer.options)
@@ -101,5 +102,5 @@ func (dialer *dialer) Dial(destination string, sessionId *identity.TokenId, addr
start := edge.NewStateConnectedMsg(result.ConnId)
start.ReplyTo(reply)
return listenConn.SendState(start)
return nil, listenConn.SendState(start)
}
+1
View File
@@ -314,6 +314,7 @@ github.com/mdlayher/netlink v1.1.0/go.mod h1:H4WCitaheIsdF9yOYu8CFmCgQthAPIWZmcK
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/michaelquigley/dilithium v0.0.0-20200728175145-5d48f61b629a/go.mod h1:mOijOzcP3JRsEXNuIQ89yosTd0Xzjksvon2LW3yGYno=
github.com/michaelquigley/dilithium v0.2.0/go.mod h1:MIqCw2+ObUwmS7G+8N8hWiwNMjItUEBzeTlipmiZqOw=
github.com/michaelquigley/pfxlog v0.0.0-20190813191113-2be43bd0dccc h1:PQrqw9XKYcPRI9rKwoGZucMjWvfZpyfb5j8Lc13j8YY=
github.com/michaelquigley/pfxlog v0.0.0-20190813191113-2be43bd0dccc/go.mod h1:Z0K0l/NScHvLeGoy4SZTps+ZxGv85ql4AvZqTqOxBY8=
github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4=