rikkix / v2gen

A powerful cross-platform CLI client for V2Ray subscription. 跨平台V2Ray命令行订阅管理客户端
MIT License
143 stars 29 forks source link

Could you please let v2gen can parse the vmess:// link directly? #2

Closed hongyi-zhao closed 5 years ago

hongyi-zhao commented 5 years ago

Hi,

I noticed that the v2gen can only support the subscribe url as the input, could you please let v2gen can parse the vmess:// link directly?

rikkix commented 5 years ago
./v2gen --vmess "vmess://xxxxxxxx"

or

./v2gen --vmess "vmess://xxxxxxxx; vmess://yyyyyyyy"
hongyi-zhao commented 5 years ago

Hi,

Thanks a lot for your quickly reply. I tried but failed as follows:

$ ./v2gen -vmess "vmess://[REDACTED]" panic: no available vmess found

goroutine 1 [running]: main.genFromVmessURIs() /home/werner/software/anti-gfw/socks5/v2ray/V2Gen.git/GenMethods.go:78 +0x96c main.main() /home/werner/software/anti-gfw/socks5/v2ray/V2Gen.git/main.go:50 +0x142

rikkix commented 5 years ago

Thank you for your feedback. As I have only used one V2Ray service provider, I cannot have more situations to test.

hongyi-zhao commented 5 years ago

Perhaps you can take a look on my case of the vmess link and find the reason of the issue:

$ ./v2gen -vmess "vmess://eyJhZGQiOiIxMDMuNDQuNjEuNjciLCJhaWQiOiIyMzMiLCJob3N0IjoiIiwiaWQiOiI0NTcxNDNjNy1kM2Y2LTRlZmItOTI3MS00YmNhNTY5NWYwNWYiLCJuZXQiOiJ0Y3AiLCJwYXRoIjoiIiwicG9ydCI6MjY3NzMsInBzIjoiU1NSVE9PTC5DT00iLCJ0bHMiOiIiLCJ0eXBlIjoibm9uZSIsInYiOiIyIn0=" panic: open /etc/v2ray/config.json: no such file or directory

goroutine 1 [running]: main.checkErr(...) /home/werner/software/anti-gfw/socks5/v2ray/V2Gen.git/main.go:64 main.genFromVmessURIs() /home/werner/software/anti-gfw/socks5/v2ray/V2Gen.git/GenMethods.go:90 +0x845 main.main() /home/werner/software/anti-gfw/socks5/v2ray/V2Gen.git/main.go:52 +0x12e

rikkix commented 5 years ago

Perhaps you can take a look on my case of the vmess link and find the reason of the issue:

$ ./v2gen -vmess "vmess://eyJhZGQiOiIxMDMuNDQuNjEuNjciLCJhaWQiOiIyMzMiLCJob3N0IjoiIiwiaWQiOiI0NTcxNDNjNy1kM2Y2LTRlZmItOTI3MS00YmNhNTY5NWYwNWYiLCJuZXQiOiJ0Y3AiLCJwYXRoIjoiIiwicG9ydCI6MjY3NzMsInBzIjoiU1NSVE9PTC5DT00iLCJ0bHMiOiIiLCJ0eXBlIjoibm9uZSIsInYiOiIyIn0=" panic: open /etc/v2ray/config.json: no such file or directory

goroutine 1 [running]: main.checkErr(...) /home/werner/software/anti-gfw/socks5/v2ray/V2Gen.git/main.go:64 main.genFromVmessURIs() /home/werner/software/anti-gfw/socks5/v2ray/V2Gen.git/GenMethods.go:90 +0x845 main.main() /home/werner/software/anti-gfw/socks5/v2ray/V2Gen.git/main.go:52 +0x12e

It will generate a new config file, the default path is /etc/v2ray/config.json.

Use sudo ./v2gen --vmess "vmess://xxxxxx" if you want to rewrite it directly

or use ./v2gen --vmess "vmess://xxxxxx" -p config.json to save to config.json

hongyi-zhao commented 5 years ago

After a further try, I can use the following command to generate the config file:


$ ./v2gen -vmess "vmess://eyJhZGQiOiIxMDMuNDQuNjEuNjciLCJhaWQiOiIyMzMiLCJob3N0IjoiIiwiaWQiOiI0NTcxNDNjNy1kM2Y2LTRlZmItOTI3MS00YmNhNTY5NWYwNWYiLCJuZXQiOiJ0Y3AiLCJwYXRoIjoiIiwicG9ydCI6MjY3NzMsInBzIjoiU1NSVE9PTC5DT00iLCJ0bHMiOiIiLCJ0eXBlIjoibm9uZSIsInYiOiIyIn0=" -p ./111.json The config file has been written to ./111.json

Do you want to preview the config?(y)es/(N)o: n

All is done! Please restart your V2Ray Service.

As you can see, here I must input y/n for confirm, could you please disable this so that it can be used in script conveniently?

Furthermore, when I try to use the above gernerated config file, I meet the following error:

$ v2ray-core.git/v2ray -config V2Gen.git/111.json V2Ray 4.20.0 (V2Fly, a community-driven edition of V2Ray.) Custom A unified platform for anti-censorship. main: failed to read config file: V2Gen.git/111.json > v2ray.com/core/main/json: failed to execute v2ctl to convert config file. > v2ray.com/core/common/platform/ctlcmd: failed to execute v2ctl: v2ray.com/core/infra/conf/command: failed to parse json config > v2ray.com/core/infra/conf/serial: failed to parse json config > v2ray.com/core/infra/conf: invalid field rule > v2ray.com/core/infra/conf: failed to parse domain rule: geosite:cn > v2ray.com/core/infra/conf: failed to load geosite: CN > v2ray.com/core/infra/conf: failed to open file: geosite.dat > open /home/werner/software/anti-gfw/socks5/v2ray/v2ray-core.git/geosite.dat: no such file or directory

exit status 255

rikkix commented 5 years ago
  1. To use in script, add parameter --silent

  2. It seems like that there is no v2ray/v2ray-core.git/geosite.dat file, you can try to redownload it from v2ray release page or disable China sites and ips directly connect settings, learn more at README.md file