Skip to content

Commit

Permalink
Add the channel id to the label
Browse files Browse the repository at this point in the history
  • Loading branch information
plorenz committed Dec 19, 2024
1 parent 98cffae commit e05804b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion classic_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (impl *classicImpl) Certificates() []*x509.Certificate {
}

func (impl *classicImpl) Label() string {
return fmt.Sprintf("u{%s}->i{%s}", impl.LogicalName(), impl.ConnectionId())
return fmt.Sprintf("u{%s}->i{%s/%s}", impl.LogicalName(), impl.id, impl.ConnectionId())
}

func (impl *classicImpl) Close() error {
Expand Down
2 changes: 0 additions & 2 deletions reconnecting_dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ func (dialer *reconnectingDialer) sendHello(impl *reconnectingImpl) error {

if id, ok := response.GetStringHeader(IdHeader); ok {
impl.id = &identity.TokenId{Token: id}
} else if certs := impl.Certificates(); len(certs) > 0 {
impl.id = &identity.TokenId{Token: certs[0].Subject.CommonName}
}

impl.headers.Store(response.Headers)
Expand Down
8 changes: 7 additions & 1 deletion reconnecting_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (impl *reconnectingImpl) Certificates() []*x509.Certificate {
}

func (impl *reconnectingImpl) Label() string {
return fmt.Sprintf("u{%s}->i{%s}", impl.LogicalName(), impl.ConnectionId())
return fmt.Sprintf("u{%s}->i{%s/%s}", impl.LogicalName(), impl.id.Token, impl.ConnectionId())
}

func (impl *reconnectingImpl) Close() error {
Expand All @@ -122,7 +122,13 @@ func (impl *reconnectingImpl) IsClosed() bool {
}

func newReconnectingImpl(peer transport.Conn, reconnectionHandler reconnectionHandler, timeout time.Duration) *reconnectingImpl {
id := &identity.TokenId{Token: "unknown"}
if certs := peer.PeerCertificates(); len(certs) > 0 {
id = &identity.TokenId{Token: certs[0].Subject.CommonName}
}

return &reconnectingImpl{
id: id,
peer: peer,
reconnectionHandler: reconnectionHandler,
readF: ReadV2,
Expand Down

0 comments on commit e05804b

Please sign in to comment.