Add ability to disable federation (#1604)
* Allow disabling federation * Don't start federation queues if disabled * Fix for Go 1.13
This commit is contained in:
parent
b4c3692dcc
commit
bdf6490375
6 changed files with 88 additions and 23 deletions
32
internal/setup/federation.go
Normal file
32
internal/setup/federation.go
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package setup
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// noOpHTTPTransport is used to disable federation.
|
||||
var noOpHTTPTransport = &http.Transport{
|
||||
Dial: func(_, _ string) (net.Conn, error) {
|
||||
return nil, fmt.Errorf("federation prohibited by configuration")
|
||||
},
|
||||
DialContext: func(_ context.Context, _, _ string) (net.Conn, error) {
|
||||
return nil, fmt.Errorf("federation prohibited by configuration")
|
||||
},
|
||||
DialTLS: func(_, _ string) (net.Conn, error) {
|
||||
return nil, fmt.Errorf("federation prohibited by configuration")
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
noOpHTTPTransport.RegisterProtocol("matrix", &noOpHTTPRoundTripper{})
|
||||
}
|
||||
|
||||
type noOpHTTPRoundTripper struct {
|
||||
}
|
||||
|
||||
func (y *noOpHTTPRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
return nil, fmt.Errorf("federation prohibited by configuration")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue