Skip to content

Commit

Permalink
tweak: config: only print out the fields that are common across devices
Browse files Browse the repository at this point in the history
  • Loading branch information
Contextualist committed Sep 23, 2023
1 parent 6b0d92d commit f9b431c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const (
)

// Config defines the user-specific information for the transfer.
// In general, it needs to be consistent across all devices of a user.
type Config struct {
ID string `json:"id"`
PSK string `json:"psk"`
Expand All @@ -42,6 +41,16 @@ func (conf *Config) ApplyDefault() {
}
}

// Export returns a Config with only the fields that are common to all devices of a user.
func (conf *Config) Export() *Config {
return &Config{
ID: conf.ID,
PSK: conf.PSK,
Server: conf.Server,
UseIPv6: conf.UseIPv6,
}
}

var configFilename = filepath.Join(userConfigDir(), "acp", "config.json")

func Setup(confStr string) (err error) {
Expand Down Expand Up @@ -71,7 +80,7 @@ func Setup(confStr string) (err error) {
} else if err != nil {
return err
}
confBytes, _ := json.Marshal(&conf)
confBytes, _ := json.Marshal(conf.Export())
confStr = string(confBytes)
}
conf.ApplyDefault()
Expand Down

0 comments on commit f9b431c

Please sign in to comment.