@@ -25,16 +25,16 @@ type ClientContextInjector struct {
2525 inboundRule * boundsRule
2626 outboundRule * boundsRule
2727 logger log.ContextLogger
28- info ClientInfo
28+ getInfo GetClientInfoFn
2929}
3030
3131// NewClientContextInjector creates a tracker for injecting client info.
32- func NewClientContextInjector (info ClientInfo , bounds MatchBounds , logger log.ContextLogger ) * ClientContextInjector {
32+ func NewClientContextInjector (fn GetClientInfoFn , bounds MatchBounds , logger log.ContextLogger ) * ClientContextInjector {
3333 return & ClientContextInjector {
3434 inboundRule : newBoundsRule (bounds .Inbound ),
3535 outboundRule : newBoundsRule (bounds .Outbound ),
3636 logger : logger ,
37- info : info ,
37+ getInfo : fn ,
3838 }
3939}
4040
@@ -49,7 +49,8 @@ func (t *ClientContextInjector) RoutedConnection(
4949 if ! t .inboundRule .match (metadata .Inbound ) || ! t .outboundRule .match (matchOutbound .Tag ()) {
5050 return conn
5151 }
52- return newWriteConn (conn , & t .info )
52+ info := t .getInfo ()
53+ return newWriteConn (conn , & info )
5354}
5455
5556// RoutedPacketConnection wraps the packet connection for writing client info.
@@ -63,7 +64,8 @@ func (t *ClientContextInjector) RoutedPacketConnection(
6364 if ! t .inboundRule .match (metadata .Inbound ) || ! t .outboundRule .match (matchOutbound .Tag ()) {
6465 return conn
6566 }
66- return newWritePacketConn (conn , metadata , & t .info )
67+ info := t .getInfo ()
68+ return newWritePacketConn (conn , metadata , & info )
6769}
6870
6971func (t * ClientContextInjector ) UpdateBounds (bounds MatchBounds ) {
0 commit comments