geph-official / geph2

(ARCHIVED) Geph (迷霧通) is a modular Internet censorship circumvention system designed specifically to deal with national filtering.
https://geph.io
GNU General Public License v3.0
1.19k stars 161 forks source link

use pkg iniflags to read options from a config file #24

Closed ElTopo closed 4 years ago

ElTopo commented 4 years ago

Currently geph-client uses flag to get options from command line, this exposes some credential info (such as username/password) to other users from the system with 'ps'/'top' commands. This pull-request tries to fix the issue by reading options from a config file (should be protected by permission 600) to avoid prying eyes.

iniflags pkg is from github.com/vharitonsky/iniflags.

The default config file is $HOME/.config/client.conf but can be overridden by -config=/path/to/cfgfile.

Several options are added by iniflags pkg: -allowMissingConfig Don't terminate the app if the ini file cannot be read. -allowUnknownFlags Don't terminate the app if ini file contains unknown flags. -config string Path to ini config for using in go flags. May be relative to the current executable path. -configUpdateInterval duration Update interval for re-reading config file set via -config flag. Zero disables config file re-reading. -dumpflags Dumps values for all flags defined in the app into stdout in ini-compatible syntax and terminates the app.

nullchinchilla commented 4 years ago

Does this allow using flags as usual? I would like geph-client to support passing parameters both by flag and by config file.

ElTopo commented 4 years ago

@nullchinchilla yes, the command options are still working, and if you have command options they are overriding the config file.

iniflags works like this: it tries to load options from the config file if it exists, then reads options from command line, so command line options override config file.