From 97341693f313975bcdd5f586b522c336ac1578f5 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Sun, 22 Apr 2018 22:54:27 +0200 Subject: [PATCH] add an option to include JSON loader in v2ray binary. --- main/distro/all/all.go | 5 ++++- main/jsonem/jsonem.go | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 main/jsonem/jsonem.go diff --git a/main/distro/all/all.go b/main/distro/all/all.go index 9a402b09..0a70e6b5 100644 --- a/main/distro/all/all.go +++ b/main/distro/all/all.go @@ -47,8 +47,11 @@ import ( _ "v2ray.com/core/transport/internet/headers/utp" _ "v2ray.com/core/transport/internet/headers/wechat" - // JSON config format + // JSON config support. Choose only one from the two below. + // The following line loads JSON from v2ctl _ "v2ray.com/core/main/json" + // The following line loads JSON internally + // _ "v2ray.com/core/main/jsonem" // Load config from file or http(s) _ "v2ray.com/core/main/confloader/external" diff --git a/main/jsonem/jsonem.go b/main/jsonem/jsonem.go new file mode 100644 index 00000000..0ce814da --- /dev/null +++ b/main/jsonem/jsonem.go @@ -0,0 +1,15 @@ +package jsonem + +import ( + "v2ray.com/core" + "v2ray.com/core/common" + "v2ray.com/ext/tools/conf/serial" +) + +func init() { + common.Must(core.RegisterConfigLoader(&core.ConfigFormat{ + Name: "JSON", + Extension: []string{"json"}, + Loader: serial.LoadJSONConfig, + })) +}