Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: enable limiting connections to one server #2970

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading