From 6648abdfcc23ca448434728ad600c2c44d16b903 Mon Sep 17 00:00:00 2001 From: yindaheng98 Date: Tue, 5 Apr 2022 17:03:57 +0800 Subject: [PATCH 1/2] Add `VmessIntoOutboundDetour` for v2ray json config file generation --- miniv2ray/v2ray.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/miniv2ray/v2ray.go b/miniv2ray/v2ray.go index 6040ae4..3b5b626 100644 --- a/miniv2ray/v2ray.go +++ b/miniv2ray/v2ray.go @@ -26,6 +26,15 @@ import ( func Vmess2Outbound(v *vmess.VmessLink, useMux, allowInsecure bool) (*core.OutboundHandlerConfig, error) { out := &conf.OutboundDetourConfig{} + detour, err := VmessIntoOutboundDetour(v, out, useMux, allowInsecure) + if err != nil { + return nil, err + } + return detour.Build() +} + +func VmessIntoOutboundDetour(v *vmess.VmessLink, template *conf.OutboundDetourConfig, useMux, allowInsecure bool) (*conf.OutboundDetourConfig, error) { + out := template out.Tag = "proxy" out.Protocol = "vmess" out.MuxSettings = &conf.MuxConfig{} @@ -105,7 +114,7 @@ func Vmess2Outbound(v *vmess.VmessLink, useMux, allowInsecure bool) (*core.Outbo ] }`, v.Add, v.Port, v.ID, v.Aid))) out.Settings = &oset - return out.Build() + return out, nil } func StartV2Ray(vm string, verbose, useMux, allowInsecure bool) (*core.Instance, error) { From 999e53279babe21647979be799da281369ed94ab Mon Sep 17 00:00:00 2001 From: yindaheng98 Date: Tue, 5 Apr 2022 17:14:57 +0800 Subject: [PATCH 2/2] function name fix --- miniv2ray/v2ray.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/miniv2ray/v2ray.go b/miniv2ray/v2ray.go index 3b5b626..84a34c9 100644 --- a/miniv2ray/v2ray.go +++ b/miniv2ray/v2ray.go @@ -25,15 +25,15 @@ import ( ) func Vmess2Outbound(v *vmess.VmessLink, useMux, allowInsecure bool) (*core.OutboundHandlerConfig, error) { - out := &conf.OutboundDetourConfig{} - detour, err := VmessIntoOutboundDetour(v, out, useMux, allowInsecure) + template := &conf.OutboundDetourConfig{} + detour, err := Vmess2OutboundDetour(v, useMux, allowInsecure, template) if err != nil { return nil, err } return detour.Build() } -func VmessIntoOutboundDetour(v *vmess.VmessLink, template *conf.OutboundDetourConfig, useMux, allowInsecure bool) (*conf.OutboundDetourConfig, error) { +func Vmess2OutboundDetour(v *vmess.VmessLink, useMux, allowInsecure bool, template *conf.OutboundDetourConfig) (*conf.OutboundDetourConfig, error) { out := template out.Tag = "proxy" out.Protocol = "vmess"