Skip to content

Commit

Permalink
enable limiting connections to one server (#2970)
Browse files Browse the repository at this point in the history
  • Loading branch information
buck54321 authored Sep 20, 2024
1 parent 903238d commit 3e04950
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions client/app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ type CoreConfig struct {
// Net is a derivative field set by ResolveConfig.
Net dex.Network

TheOneHost string `long:"onehost" description:"Only connect with this server."`

NoAutoWalletLock bool `long:"no-wallet-lock" description:"Disable locking of wallets on shutdown or logout. Use this if you want your external wallets to stay unlocked after closing the DEX app."`
NoAutoDBBackup bool `long:"no-db-backup" description:"Disable creation of a database backup on shutdown."`
UnlockCoinsOnLogin bool `long:"release-wallet-coins" description:"On login or wallet creation, instruct the wallet to release any coins that it may have locked."`
Expand Down Expand Up @@ -213,6 +215,7 @@ func (cfg *Config) Core(log dex.Logger) *core.Config {
NoAutoWalletLock: cfg.NoAutoWalletLock,
NoAutoDBBackup: cfg.NoAutoDBBackup,
ExtensionModeFile: cfg.ExtensionModeFile,
TheOneHost: cfg.TheOneHost,
}
}

Expand Down
7 changes: 7 additions & 0 deletions client/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -1433,6 +1433,8 @@ type Config struct {
// for running core in extension mode, which gives the caller options for
// e.g. limiting the ability to configure wallets.
ExtensionModeFile string

TheOneHost string
}

// locale is data associated with the currently selected language.
Expand Down Expand Up @@ -7174,6 +7176,11 @@ func (c *Core) connectAccount(acct *db.AccountInfo) (connected bool) {
return
}

if c.cfg.TheOneHost != "" && c.cfg.TheOneHost != host {
c.log.Infof("Running with --onehost = %q.", c.cfg.TheOneHost)
return false
}

var connectFlag connectDEXFlag
if acct.ViewOnly() {
connectFlag |= connectDEXFlagViewOnly
Expand Down

0 comments on commit 3e04950

Please sign in to comment.