Skip to content

Commit

Permalink
Merge pull request #149 from openziti/add-header-f
Browse files Browse the repository at this point in the history
Allow getting listener headers from a func
  • Loading branch information
plorenz authored Nov 14, 2024
2 parents 59ba725 + d46009f commit 1cee3ba
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions classic_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type classicListener struct {
connectOptions ConnectOptions
tcfg transport.Configuration
headers map[int32][]byte
headersF func() map[int32][]byte
closed atomic.Bool
listenerPool goroutines.Pool
messageStrategy MessageStrategy
Expand All @@ -55,6 +56,7 @@ func DefaultListenerConfig() ListenerConfig {
type ListenerConfig struct {
ConnectOptions
Headers map[int32][]byte
HeadersF func() map[int32][]byte
TransportConfig transport.Configuration
PoolConfigurator func(config *goroutines.PoolConfig)
ConnectionHandlers []ConnectionHandler
Expand Down Expand Up @@ -105,6 +107,7 @@ func newClassicListener(identity *identity.TokenId, endpoint transport.Address,
connectOptions: config.ConnectOptions,
tcfg: config.TransportConfig,
headers: config.Headers,
headersF: config.HeadersF,
closed: atomic.Bool{},
listenerPool: pool,
messageStrategy: config.MessageStrategy,
Expand Down Expand Up @@ -260,6 +263,12 @@ func (self *classicListener) ackHello(impl classicUnderlay, request *Message, su
response.Headers[key] = val
}

if self.headersF != nil {
for key, val := range self.headersF() {
response.Headers[key] = val
}
}

response.PutStringHeader(ConnectionIdHeader, impl.ConnectionId())
if self.identity != nil {
response.PutStringHeader(IdHeader, self.identity.Token)
Expand Down

0 comments on commit 1cee3ba

Please sign in to comment.