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

add arg -confdir #2148

Merged
merged 5 commits into from
Dec 31, 2019
Merged

add arg -confdir #2148

merged 5 commits into from
Dec 31, 2019

Conversation

vcptr
Copy link
Contributor

@vcptr vcptr commented Dec 31, 2019

A common way of reading multiple config file is to scan a directory and read config files inside by the order of their names. This PR make multiple config feature more practical by adding -confdir arg.

Adds

  • v2ray arg: -confdir - A dir with multiple json config
  • env v2ray.location.confdir or V2RAY_LOCATION_CONFDIR
  • more details logs about config during program start.

Examples

When use with multiple config, lines after <v2ctl message> will tell the order of how config file is processed.

$ ./v2ray -confdir ./vjson
V2Ray 4.22.0 (V2Fly, a community-driven edition of V2Ray.) Custom
A unified platform for anti-censorship.
2019/12/31 13:45:49 [Info] v2ray.com/core/common/platform/ctlcmd: <v2ctl message> 
v2ctl> Read config:  vjson/01dohipm.json
v2ctl> Read config:  vjson/02doh.json
v2ctl> Read config:  vjson/03out.json
v2ctl> [ vjson/03out.json ] updated outbound with tag:  proxy
2019/12/31 13:45:49 [Debug] v2ray.com/core/app/log: Logger started
...
2019/12/31 13:45:49 [Warning] v2ray.com/core: V2Ray 4.22.0 started

So as using env, logs how the config is speculated. (... Using confdir from env)

$ env V2RAY_LOCATION_CONFDIR=/home/ubuntu/vjson ./v2ray 
V2Ray 4.22.0 (V2Fly, a community-driven edition of V2Ray.) Custom
A unified platform for anti-censorship.
2019/12/31 13:48:02 Using confdir from env:  /home/ubuntu/vjson
2019/12/31 13:48:02 [Info] v2ray.com/core/common/platform/ctlcmd: <v2ctl message> 
v2ctl> Read config:  /home/ubuntu/vjson/01dohipm.json
v2ctl> Read config:  /home/ubuntu/vjson/02doh.json
v2ctl> Read config:  /home/ubuntu/vjson/03out.json
v2ctl> [ /home/ubuntu/vjson/03out.json ] updated outbound with tag:  proxy
2019/12/31 13:48:02 [Warning] v2ray.com/core: V2Ray 4.22.0 started

If there's problems in config file, the error message is easy to read

$ ./v2ray 
V2Ray 4.22.0 (V2Fly, a community-driven edition of V2Ray.) Custom
A unified platform for anti-censorship.
2019/12/31 14:00:29 Using default config:  /home/ubuntu/config.json
main: failed to read config files: [/home/ubuntu/config.json] > v2ray.com/core/main/json: failed to execute v2ctl to convert config file. > v2ray.com/core/common/platform/ctlcmd: failed to execute v2ctl: 
v2ctl> Read config:  /home/ubuntu/config.json
v2ctl> v2ray.com/core/infra/conf/serial: failed to read config file at line 15 char 5 > invalid character ',' looking for beginning of object key string > exit status 1

@kslr kslr merged commit bb441a6 into v2ray:master Dec 31, 2019
@kslr kslr mentioned this pull request Jan 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants