Skip to content

Commit

Permalink
fix!: refer DNS from mobile config
Browse files Browse the repository at this point in the history
  • Loading branch information
siddarthkay committed Apr 18, 2024
1 parent c70badb commit 3255da8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
4 changes: 4 additions & 0 deletions api/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"io/ioutil"
"math/rand"
"net"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -870,6 +871,9 @@ func TestLoginAccount(t *testing.T) {
require.NoError(t, err)
waitForLogin(c)

preferGo := net.DefaultResolver.PreferGo
require.Equal(t, preferGo, false)

require.Equal(t, nameserver, b.config.WakuV2Config.Nameserver)
}

Expand Down
19 changes: 19 additions & 0 deletions api/geth_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"math/big"
"net"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -622,6 +623,23 @@ func (b *GethStatusBackend) loginAccount(request *requests.Login) error {

defaultCfg.WalletConfig = buildWalletConfig(&request.WalletSecretsConfig)

var dialer net.Dialer
// we have to override DNS manually because of https://github.com/status-im/status-mobile/issues/19581
bootstrapDNS := fmt.Sprintf("%s:53", request.WakuV2Nameserver)
// should have been just
//bootstrapDNS := "8.8.8.8:53"

net.DefaultResolver = &net.Resolver{
PreferGo: false,
Dial: func(context context.Context, _, _ string) (net.Conn, error) {
conn, err := dialer.DialContext(context, "udp", bootstrapDNS)
if err != nil {
return nil, err
}
return conn, nil
},
}

err = b.UpdateNodeConfigFleet(acc, password, defaultCfg)
if err != nil {
return err
Expand Down Expand Up @@ -1445,6 +1463,7 @@ func (b *GethStatusBackend) generateOrImportAccount(mnemonic string, customizati
}

subAccounts := []*accounts.Account{walletAccount, chatAccount}

err = b.StartNodeWithAccountAndInitialConfig(account, request.Password, *settings, nodeConfig, subAccounts)
if err != nil {
b.log.Error("start node", err)
Expand Down
14 changes: 0 additions & 14 deletions protocol/messenger_mailserver_cycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"math"
"math/big"
"net"
"runtime"
"sort"
"strings"
Expand Down Expand Up @@ -220,19 +219,6 @@ type SortedMailserver struct {
}

func (m *Messenger) findNewMailserver() error {
// we have to override DNS manually because of https://github.com/status-im/status-mobile/issues/19581
const bootstrapDNS = "8.8.8.8:53"
var dialer net.Dialer
net.DefaultResolver = &net.Resolver{
PreferGo: false,
Dial: func(context context.Context, _, _ string) (net.Conn, error) {
conn, err := dialer.DialContext(context, "udp", bootstrapDNS)
if err != nil {
return nil, err
}
return conn, nil
},
}
pinnedMailserver, err := m.getPinnedMailserver()
if err != nil {
m.logger.Error("Could not obtain the pinned mailserver", zap.Error(err))
Expand Down

0 comments on commit 3255da8

Please sign in to comment.