[relay] Refactor initial Relay connection (#2800)

Can support firewalls with restricted WS rules

allow to run engine without Relay servers
keep up to date Relay address changes
This commit is contained in:
Zoltan Papp
2024-11-22 18:12:34 +01:00
committed by GitHub
parent 9db1932664
commit 2a5cb16494
10 changed files with 211 additions and 96 deletions

View File

@ -7,16 +7,19 @@ import (
)
func TestServerPicker_UnavailableServers(t *testing.T) {
connectionTimeout = 5 * time.Second
sp := ServerPicker{
TokenStore: nil,
PeerID: "test",
}
sp.ServerURLs.Store([]string{"rel://dummy1", "rel://dummy2"})
ctx, cancel := context.WithTimeout(context.Background(), connectionTimeout+1)
defer cancel()
go func() {
_, err := sp.PickServer(ctx, []string{"rel://dummy1", "rel://dummy2"})
_, err := sp.PickServer(ctx)
if err == nil {
t.Error(err)
}