mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-24 09:31:30 +00:00
Fix http2 transport close
This commit is contained in:
parent
2012c0ca1e
commit
19a35ec6a4
|
@ -12,6 +12,7 @@ import (
|
||||||
"github.com/sagernet/sing-box/adapter"
|
"github.com/sagernet/sing-box/adapter"
|
||||||
"github.com/sagernet/sing-box/common/tls"
|
"github.com/sagernet/sing-box/common/tls"
|
||||||
"github.com/sagernet/sing-box/option"
|
"github.com/sagernet/sing-box/option"
|
||||||
|
"github.com/sagernet/sing-box/transport/v2rayhttp"
|
||||||
M "github.com/sagernet/sing/common/metadata"
|
M "github.com/sagernet/sing/common/metadata"
|
||||||
N "github.com/sagernet/sing/common/network"
|
N "github.com/sagernet/sing/common/network"
|
||||||
|
|
||||||
|
@ -93,3 +94,8 @@ func (c *Client) DialContext(ctx context.Context) (net.Conn, error) {
|
||||||
}()
|
}()
|
||||||
return conn, nil
|
return conn, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Client) Close() error {
|
||||||
|
v2rayhttp.CloseIdleConnections(c.transport)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -167,3 +167,8 @@ func (c *Client) dialHTTP2(ctx context.Context) (net.Conn, error) {
|
||||||
}()
|
}()
|
||||||
return conn, nil
|
return conn, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Client) Close() error {
|
||||||
|
CloseIdleConnections(c.transport)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
13
transport/v2rayhttp/pool.go
Normal file
13
transport/v2rayhttp/pool.go
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
package v2rayhttp
|
||||||
|
|
||||||
|
import "net/http"
|
||||||
|
|
||||||
|
type ConnectionPool interface {
|
||||||
|
CloseIdleConnections()
|
||||||
|
}
|
||||||
|
|
||||||
|
func CloseIdleConnections(transport http.RoundTripper) {
|
||||||
|
if connectionPool, ok := transport.(ConnectionPool); ok {
|
||||||
|
connectionPool.CloseIdleConnections()
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue