forked from Silverfish/proton-bridge
fix: ensure doh connections are closed when it is disabled
This commit is contained in:
@ -198,6 +198,10 @@ func (c *client) clearKeys() {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *client) CloseConnections() {
|
||||
c.hc.CloseIdleConnections()
|
||||
}
|
||||
|
||||
// Do makes an API request. It does not check for HTTP status code errors.
|
||||
func (c *client) Do(req *http.Request, retryUnauthorized bool) (res *http.Response, err error) {
|
||||
// Copy the request body in case we need to retry it.
|
||||
|
||||
@ -33,6 +33,7 @@ type Client interface {
|
||||
Logout()
|
||||
DeleteAuth() error
|
||||
IsConnected() bool
|
||||
CloseConnections()
|
||||
ClearData()
|
||||
|
||||
CurrentUser() (*User, error)
|
||||
|
||||
@ -230,6 +230,10 @@ func (cm *ClientManager) DisallowProxy() {
|
||||
|
||||
cm.allowProxy = false
|
||||
cm.host = rootURL
|
||||
|
||||
for _, client := range cm.clients {
|
||||
client.CloseConnections()
|
||||
}
|
||||
}
|
||||
|
||||
// IsProxyEnabled returns whether we are currently proxying requests.
|
||||
|
||||
@ -137,6 +137,18 @@ func (mr *MockClientMockRecorder) ClearData() *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ClearData", reflect.TypeOf((*MockClient)(nil).ClearData))
|
||||
}
|
||||
|
||||
// CloseConnections mocks base method
|
||||
func (m *MockClient) CloseConnections() {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "CloseConnections")
|
||||
}
|
||||
|
||||
// CloseConnections indicates an expected call of CloseConnections
|
||||
func (mr *MockClientMockRecorder) CloseConnections() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CloseConnections", reflect.TypeOf((*MockClient)(nil).CloseConnections))
|
||||
}
|
||||
|
||||
// CountMessages mocks base method
|
||||
func (m *MockClient) CountMessages(arg0 string) ([]*pmapi.MessagesCount, error) {
|
||||
m.ctrl.T.Helper()
|
||||
|
||||
Reference in New Issue
Block a user