Fix ordering in cleanup function

This commit is contained in:
Quentin McGaw
2026-06-09 14:07:05 +00:00
parent b5366b9e44
commit 29186feccc
+4 -4
View File
@@ -45,16 +45,16 @@ func (c *Client) OpenHTTPS(ctx context.Context, destinationTLSName string, desti
cleanup = func() error {
var errs []error
httpClient.CloseIdleConnections()
err = connection.Close()
if err != nil && !errors.Is(err, net.ErrClosed) {
errs = append(errs, fmt.Errorf("closing connection: %w", err))
}
const remove = true
err := c.firewall.AcceptOutputFromIPPortToIPPort(context.Background(), "tcp", c.outboundInterface,
sourceAddrPort, destinationAddrPort, remove)
if err != nil {
errs = append(errs, fmt.Errorf("removing output traffic rule: %w", err))
}
err = connection.Close()
if err != nil && !errors.Is(err, net.ErrClosed) {
errs = append(errs, fmt.Errorf("closing connection: %w", err))
}
if len(errs) > 0 {
return errors.Join(errs...)
}