Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GetCircuitId to edge.Conn. Fixes #524 #525

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Release 0.23.11

## What's New

* Add GetCircuitId to edge.Conn. Allows correlation with controller/router metrics. Requires support from controller.

# Release 0.23.4

## What's New
Expand Down
1 change: 1 addition & 0 deletions ziti/edge/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ type ServiceConn interface {
GetAppData() []byte
SourceIdentifier() string
TraceRoute(hops uint32, timeout time.Duration) (*TraceRouteResult, error)
GetCircuitId() string
}

type Conn interface {
Expand Down
1 change: 1 addition & 0 deletions ziti/edge/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const (
SupportsInspectHeader = 1023
SupportsBindSuccessHeader = 1024
ConnectionMarkerHeader = 1025
CircuitIdHeader = 1026

ErrorCodeInternal = 1
ErrorCodeInvalidApiSession = 2
Expand Down
11 changes: 10 additions & 1 deletion ziti/edge/network/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type edgeConn struct {
acceptCompleteHandler *newConnHandler
connType ConnType
marker string
circuitId string

crypto bool
keyPair *kx.KeyPair
Expand Down Expand Up @@ -251,6 +252,10 @@ func (conn *edgeConn) HandleMuxClose() error {
return nil
}

func (conn *edgeConn) GetCircuitId() string {
return conn.circuitId
}

func (conn *edgeConn) HandleClose(channel.Channel) {
logger := pfxlog.Logger().WithField("connId", conn.Id()).WithField("marker", conn.marker)
defer logger.Debug("received HandleClose from underlying channel, marking conn closed")
Expand Down Expand Up @@ -306,6 +311,7 @@ func (conn *edgeConn) Connect(session *rest_model.SessionDetail, options *edge.D
logger.Warn("connection is not end-to-end-encrypted")
}
}
conn.circuitId, _ = replyMsg.GetStringHeader(edge.CircuitIdHeader)
logger.Debug("connected")

return conn, nil
Expand Down Expand Up @@ -583,6 +589,7 @@ func (conn *edgeConn) newChildConnection(message *channel.Message) {

sourceIdentity, _ := message.GetStringHeader(edge.CallerIdHeader)
marker, _ := message.GetStringHeader(edge.ConnectionMarkerHeader)
circuitId, _ := message.GetStringHeader(edge.CircuitIdHeader)

edgeCh := &edgeConn{
MsgChannel: *edge.NewEdgeMsgChannel(conn.Channel, id),
Expand All @@ -593,13 +600,15 @@ func (conn *edgeConn) newChildConnection(message *channel.Message) {
appData: message.Headers[edge.AppDataHeader],
connType: ConnTypeDial,
marker: marker,
circuitId: circuitId,
}

newConnLogger := pfxlog.Logger().
WithField("marker", marker).
WithField("connId", id).
WithField("parentConnId", conn.Id()).
WithField("token", token)
WithField("token", token).
WithField("circuitId", token)

err := conn.msgMux.AddMsgSink(edgeCh) // duplicate errors only happen on the server side, since client controls ids
if err != nil {
Expand Down
Loading