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

caddyhttp: Fix listener wrapper regression from #6573 #6599

Merged
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
8 changes: 4 additions & 4 deletions listeners.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,14 @@ func (na NetworkAddress) listen(ctx context.Context, portOffset uint, config net
}
}

if ln == nil {
return nil, fmt.Errorf("unsupported network type: %s", na.Network)
}

if err != nil {
return nil, err
}

if ln == nil {
return nil, fmt.Errorf("unsupported network type: %s", na.Network)
}

if IsUnixNetwork(na.Network) {
isAbstractUnixSocket := strings.HasPrefix(address, "@")
if !isAbstractUnixSocket {
Expand Down
10 changes: 5 additions & 5 deletions modules/caddyhttp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,11 +535,6 @@ func (app *App) Start() error {
return fmt.Errorf("network '%s' cannot handle HTTP/1 or HTTP/2 connections", listenAddr.Network)
}

if useTLS {
// create TLS listener - this enables and terminates TLS
ln = tls.NewListener(ln, tlsCfg)
}

// wrap listener before TLS (up to the TLS placeholder wrapper)
var lnWrapperIdx int
for i, lnWrapper := range srv.listenerWrappers {
Expand All @@ -550,6 +545,11 @@ func (app *App) Start() error {
ln = lnWrapper.WrapListener(ln)
}

if useTLS {
// create TLS listener - this enables and terminates TLS
ln = tls.NewListener(ln, tlsCfg)
}

// finish wrapping listener where we left off before TLS
for i := lnWrapperIdx; i < len(srv.listenerWrappers); i++ {
ln = srv.listenerWrappers[i].WrapListener(ln)
Expand Down
Loading