mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-04 16:37:12 -05:00
v5: Remove v2ctl & wv2ray (#488)
* remove v2ctl, wv2ray * remove v2ctl, wv2ray build scripts * remove infra/control/main * remove !confonly flag * remove ctlcmd package * remove Confgi.Override func * move commands package into main
This commit is contained in:
parent
9367e9b1f2
commit
7c1ab06206
10
.github/workflows/release.yml
vendored
10
.github/workflows/release.yml
vendored
@ -102,16 +102,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
mkdir -p build_assets
|
mkdir -p build_assets
|
||||||
go build -v -o build_assets/v2ray -trimpath -ldflags "-s -w -buildid=" ./main
|
go build -v -o build_assets/v2ray -trimpath -ldflags "-s -w -buildid=" ./main
|
||||||
go build -v -o build_assets/v2ctl -trimpath -ldflags "-s -w -buildid=" -tags confonly ./infra/control/main
|
|
||||||
|
|
||||||
- name: Build Windows wv2ray
|
|
||||||
if: matrix.goos == 'windows'
|
|
||||||
run: |
|
|
||||||
echo "::warning ::wv2ray.exe will be removed in v5"
|
|
||||||
go build -v -o build_assets/wv2ray.exe -trimpath -ldflags "-s -w -H windowsgui -buildid=" ./main
|
|
||||||
cd ./build_assets || exit 1
|
|
||||||
mv v2ray v2ray.exe
|
|
||||||
mv v2ctl v2ctl.exe
|
|
||||||
|
|
||||||
- name: Prepare package
|
- name: Prepare package
|
||||||
run: cp -v ./release/config/*.* ./build_assets
|
run: cp -v ./release/config/*.* ./build_assets
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package commander
|
package commander
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate go run v2ray.com/core/common/errors/errorgen
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package commander
|
package commander
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package commander
|
package commander
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package dispatcher
|
package dispatcher
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate go run v2ray.com/core/common/errors/errorgen
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package dispatcher
|
package dispatcher
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate go run v2ray.com/core/common/errors/errorgen
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package dispatcher
|
package dispatcher
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package dispatcher
|
package dispatcher
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package dns
|
package dns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package dns
|
package dns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package dns
|
package dns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package dns
|
package dns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package dns
|
package dns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package dns
|
package dns
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate go run v2ray.com/core/common/errors/errorgen
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package dns
|
package dns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package command
|
package command
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate go run v2ray.com/core/common/errors/errorgen
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package log
|
package log
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate go run v2ray.com/core/common/errors/errorgen
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package log
|
package log
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package command
|
package command
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package reverse
|
package reverse
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package reverse
|
package reverse
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package reverse
|
package reverse
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package reverse
|
package reverse
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate go run v2ray.com/core/common/errors/errorgen
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package router
|
package router
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package command
|
package command
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate go run v2ray.com/core/common/errors/errorgen
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package router
|
package router
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package router
|
package router
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package router
|
package router
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package router
|
package router
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate go run v2ray.com/core/common/errors/errorgen
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package stats
|
package stats
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package command
|
package command
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate go run v2ray.com/core/common/errors/errorgen
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package stats
|
package stats
|
||||||
|
|
||||||
import "sync/atomic"
|
import "sync/atomic"
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package stats
|
package stats
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate go run v2ray.com/core/common/errors/errorgen
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package net
|
package net
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
// +build !windows
|
|
||||||
|
|
||||||
package ctlcmd
|
|
||||||
|
|
||||||
import "syscall"
|
|
||||||
|
|
||||||
func getSysProcAttr() *syscall.SysProcAttr {
|
|
||||||
return nil
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
// +build windows
|
|
||||||
|
|
||||||
package ctlcmd
|
|
||||||
|
|
||||||
import "syscall"
|
|
||||||
|
|
||||||
func getSysProcAttr() *syscall.SysProcAttr {
|
|
||||||
return &syscall.SysProcAttr{
|
|
||||||
HideWindow: true,
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
package ctlcmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io"
|
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"v2ray.com/core/common/buf"
|
|
||||||
"v2ray.com/core/common/platform"
|
|
||||||
)
|
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
|
||||||
|
|
||||||
func Run(args []string, input io.Reader) (buf.MultiBuffer, error) {
|
|
||||||
v2ctl := platform.GetToolLocation("v2ctl")
|
|
||||||
if _, err := os.Stat(v2ctl); err != nil {
|
|
||||||
return nil, newError("v2ctl doesn't exist").Base(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
var errBuffer buf.MultiBufferContainer
|
|
||||||
var outBuffer buf.MultiBufferContainer
|
|
||||||
|
|
||||||
cmd := exec.Command(v2ctl, args...)
|
|
||||||
cmd.Stderr = &errBuffer
|
|
||||||
cmd.Stdout = &outBuffer
|
|
||||||
cmd.SysProcAttr = getSysProcAttr()
|
|
||||||
if input != nil {
|
|
||||||
cmd.Stdin = input
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := cmd.Start(); err != nil {
|
|
||||||
return nil, newError("failed to start v2ctl").Base(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := cmd.Wait(); err != nil {
|
|
||||||
msg := "failed to execute v2ctl"
|
|
||||||
if errBuffer.Len() > 0 {
|
|
||||||
msg += ": \n" + strings.TrimSpace(errBuffer.MultiBuffer.String())
|
|
||||||
}
|
|
||||||
return nil, newError(msg).Base(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// log stderr, info message
|
|
||||||
if !errBuffer.IsEmpty() {
|
|
||||||
newError("<v2ctl message> \n", strings.TrimSpace(errBuffer.MultiBuffer.String())).AtInfo().WriteToLog()
|
|
||||||
}
|
|
||||||
|
|
||||||
return outBuffer.MultiBuffer, nil
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
package ctlcmd
|
|
||||||
|
|
||||||
import "v2ray.com/core/common/errors"
|
|
||||||
|
|
||||||
type errPathObjHolder struct{}
|
|
||||||
|
|
||||||
func newError(values ...interface{}) *errors.Error {
|
|
||||||
return errors.New(values...).WithPathObj(errPathObjHolder{})
|
|
||||||
}
|
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@ package conf
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"v2ray.com/core"
|
"v2ray.com/core"
|
||||||
@ -35,8 +33,6 @@ var (
|
|||||||
"trojan": func() interface{} { return new(TrojanClientConfig) },
|
"trojan": func() interface{} { return new(TrojanClientConfig) },
|
||||||
"dns": func() interface{} { return new(DNSOutboundConfig) },
|
"dns": func() interface{} { return new(DNSOutboundConfig) },
|
||||||
}, "protocol", "settings")
|
}, "protocol", "settings")
|
||||||
|
|
||||||
ctllog = log.New(os.Stderr, "v2ctl> ", 0)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func toProtocolList(s []string) ([]proxyman.KnownProtocols, error) {
|
func toProtocolList(s []string) ([]proxyman.KnownProtocols, error) {
|
||||||
@ -368,86 +364,6 @@ func (c *Config) findOutboundTag(tag string) int {
|
|||||||
return found
|
return found
|
||||||
}
|
}
|
||||||
|
|
||||||
// Override method accepts another Config overrides the current attribute
|
|
||||||
func (c *Config) Override(o *Config, fn string) {
|
|
||||||
// only process the non-deprecated members
|
|
||||||
|
|
||||||
if o.LogConfig != nil {
|
|
||||||
c.LogConfig = o.LogConfig
|
|
||||||
}
|
|
||||||
if o.RouterConfig != nil {
|
|
||||||
c.RouterConfig = o.RouterConfig
|
|
||||||
}
|
|
||||||
if o.DNSConfig != nil {
|
|
||||||
c.DNSConfig = o.DNSConfig
|
|
||||||
}
|
|
||||||
if o.Transport != nil {
|
|
||||||
c.Transport = o.Transport
|
|
||||||
}
|
|
||||||
if o.Policy != nil {
|
|
||||||
c.Policy = o.Policy
|
|
||||||
}
|
|
||||||
if o.API != nil {
|
|
||||||
c.API = o.API
|
|
||||||
}
|
|
||||||
if o.Stats != nil {
|
|
||||||
c.Stats = o.Stats
|
|
||||||
}
|
|
||||||
if o.Reverse != nil {
|
|
||||||
c.Reverse = o.Reverse
|
|
||||||
}
|
|
||||||
|
|
||||||
// deprecated attrs... keep them for now
|
|
||||||
if o.InboundConfig != nil {
|
|
||||||
c.InboundConfig = o.InboundConfig
|
|
||||||
}
|
|
||||||
if o.OutboundConfig != nil {
|
|
||||||
c.OutboundConfig = o.OutboundConfig
|
|
||||||
}
|
|
||||||
if o.InboundDetours != nil {
|
|
||||||
c.InboundDetours = o.InboundDetours
|
|
||||||
}
|
|
||||||
if o.OutboundDetours != nil {
|
|
||||||
c.OutboundDetours = o.OutboundDetours
|
|
||||||
}
|
|
||||||
// deprecated attrs
|
|
||||||
|
|
||||||
// update the Inbound in slice if the only one in overide config has same tag
|
|
||||||
if len(o.InboundConfigs) > 0 {
|
|
||||||
if len(c.InboundConfigs) > 0 && len(o.InboundConfigs) == 1 {
|
|
||||||
if idx := c.findInboundTag(o.InboundConfigs[0].Tag); idx > -1 {
|
|
||||||
c.InboundConfigs[idx] = o.InboundConfigs[0]
|
|
||||||
ctllog.Println("[", fn, "] updated inbound with tag: ", o.InboundConfigs[0].Tag)
|
|
||||||
} else {
|
|
||||||
c.InboundConfigs = append(c.InboundConfigs, o.InboundConfigs[0])
|
|
||||||
ctllog.Println("[", fn, "] appended inbound with tag: ", o.InboundConfigs[0].Tag)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
c.InboundConfigs = o.InboundConfigs
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// update the Outbound in slice if the only one in overide config has same tag
|
|
||||||
if len(o.OutboundConfigs) > 0 {
|
|
||||||
if len(c.OutboundConfigs) > 0 && len(o.OutboundConfigs) == 1 {
|
|
||||||
if idx := c.findOutboundTag(o.OutboundConfigs[0].Tag); idx > -1 {
|
|
||||||
c.OutboundConfigs[idx] = o.OutboundConfigs[0]
|
|
||||||
ctllog.Println("[", fn, "] updated outbound with tag: ", o.OutboundConfigs[0].Tag)
|
|
||||||
} else {
|
|
||||||
if strings.Contains(strings.ToLower(fn), "tail") {
|
|
||||||
c.OutboundConfigs = append(c.OutboundConfigs, o.OutboundConfigs[0])
|
|
||||||
ctllog.Println("[", fn, "] appended outbound with tag: ", o.OutboundConfigs[0].Tag)
|
|
||||||
} else {
|
|
||||||
c.OutboundConfigs = append(o.OutboundConfigs, c.OutboundConfigs...)
|
|
||||||
ctllog.Println("[", fn, "] prepended outbound with tag: ", o.OutboundConfigs[0].Tag)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
c.OutboundConfigs = o.OutboundConfigs
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func applyTransportConfig(s *StreamConfig, t *TransportConfig) {
|
func applyTransportConfig(s *StreamConfig, t *TransportConfig) {
|
||||||
if s.TCPSettings == nil {
|
if s.TCPSettings == nil {
|
||||||
s.TCPSettings = t.TCPConfig
|
s.TCPSettings = t.TCPConfig
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
"github.com/google/go-cmp/cmp"
|
|
||||||
"v2ray.com/core"
|
"v2ray.com/core"
|
||||||
"v2ray.com/core/app/dispatcher"
|
"v2ray.com/core/app/dispatcher"
|
||||||
"v2ray.com/core/app/log"
|
"v2ray.com/core/app/log"
|
||||||
@ -370,80 +369,3 @@ func TestMuxConfig_Build(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestConfig_Override(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
orig *Config
|
|
||||||
over *Config
|
|
||||||
fn string
|
|
||||||
want *Config
|
|
||||||
}{
|
|
||||||
{"combine/empty",
|
|
||||||
&Config{},
|
|
||||||
&Config{
|
|
||||||
LogConfig: &LogConfig{},
|
|
||||||
RouterConfig: &RouterConfig{},
|
|
||||||
DNSConfig: &DNSConfig{},
|
|
||||||
Transport: &TransportConfig{},
|
|
||||||
Policy: &PolicyConfig{},
|
|
||||||
API: &APIConfig{},
|
|
||||||
Stats: &StatsConfig{},
|
|
||||||
Reverse: &ReverseConfig{},
|
|
||||||
},
|
|
||||||
"",
|
|
||||||
&Config{
|
|
||||||
LogConfig: &LogConfig{},
|
|
||||||
RouterConfig: &RouterConfig{},
|
|
||||||
DNSConfig: &DNSConfig{},
|
|
||||||
Transport: &TransportConfig{},
|
|
||||||
Policy: &PolicyConfig{},
|
|
||||||
API: &APIConfig{},
|
|
||||||
Stats: &StatsConfig{},
|
|
||||||
Reverse: &ReverseConfig{},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{"combine/newattr",
|
|
||||||
&Config{InboundConfigs: []InboundDetourConfig{{Tag: "old"}}},
|
|
||||||
&Config{LogConfig: &LogConfig{}}, "",
|
|
||||||
&Config{LogConfig: &LogConfig{}, InboundConfigs: []InboundDetourConfig{{Tag: "old"}}}},
|
|
||||||
{"replace/inbounds",
|
|
||||||
&Config{InboundConfigs: []InboundDetourConfig{{Tag: "pos0"}, {Protocol: "vmess", Tag: "pos1"}}},
|
|
||||||
&Config{InboundConfigs: []InboundDetourConfig{{Tag: "pos1", Protocol: "kcp"}}},
|
|
||||||
"",
|
|
||||||
&Config{InboundConfigs: []InboundDetourConfig{{Tag: "pos0"}, {Tag: "pos1", Protocol: "kcp"}}}},
|
|
||||||
{"replace/inbounds-replaceall",
|
|
||||||
&Config{InboundConfigs: []InboundDetourConfig{{Tag: "pos0"}, {Protocol: "vmess", Tag: "pos1"}}},
|
|
||||||
&Config{InboundConfigs: []InboundDetourConfig{{Tag: "pos1", Protocol: "kcp"}, {Tag: "pos2", Protocol: "kcp"}}},
|
|
||||||
"",
|
|
||||||
&Config{InboundConfigs: []InboundDetourConfig{{Tag: "pos1", Protocol: "kcp"}, {Tag: "pos2", Protocol: "kcp"}}}},
|
|
||||||
{"replace/notag-append",
|
|
||||||
&Config{InboundConfigs: []InboundDetourConfig{{}, {Protocol: "vmess"}}},
|
|
||||||
&Config{InboundConfigs: []InboundDetourConfig{{Tag: "pos1", Protocol: "kcp"}}},
|
|
||||||
"",
|
|
||||||
&Config{InboundConfigs: []InboundDetourConfig{{}, {Protocol: "vmess"}, {Tag: "pos1", Protocol: "kcp"}}}},
|
|
||||||
{"replace/outbounds",
|
|
||||||
&Config{OutboundConfigs: []OutboundDetourConfig{{Tag: "pos0"}, {Protocol: "vmess", Tag: "pos1"}}},
|
|
||||||
&Config{OutboundConfigs: []OutboundDetourConfig{{Tag: "pos1", Protocol: "kcp"}}},
|
|
||||||
"",
|
|
||||||
&Config{OutboundConfigs: []OutboundDetourConfig{{Tag: "pos0"}, {Tag: "pos1", Protocol: "kcp"}}}},
|
|
||||||
{"replace/outbounds-prepend",
|
|
||||||
&Config{OutboundConfigs: []OutboundDetourConfig{{Tag: "pos0"}, {Protocol: "vmess", Tag: "pos1"}}},
|
|
||||||
&Config{OutboundConfigs: []OutboundDetourConfig{{Tag: "pos1", Protocol: "kcp"}, {Tag: "pos2", Protocol: "kcp"}}},
|
|
||||||
"config.json",
|
|
||||||
&Config{OutboundConfigs: []OutboundDetourConfig{{Tag: "pos1", Protocol: "kcp"}, {Tag: "pos2", Protocol: "kcp"}}}},
|
|
||||||
{"replace/outbounds-append",
|
|
||||||
&Config{OutboundConfigs: []OutboundDetourConfig{{Tag: "pos0"}, {Protocol: "vmess", Tag: "pos1"}}},
|
|
||||||
&Config{OutboundConfigs: []OutboundDetourConfig{{Tag: "pos2", Protocol: "kcp"}}},
|
|
||||||
"config_tail.json",
|
|
||||||
&Config{OutboundConfigs: []OutboundDetourConfig{{Tag: "pos0"}, {Protocol: "vmess", Tag: "pos1"}, {Tag: "pos2", Protocol: "kcp"}}}},
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
tt.orig.Override(tt.over, tt.fn)
|
|
||||||
if r := cmp.Diff(tt.orig, tt.want); r != "" {
|
|
||||||
t.Error(r)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
_ "v2ray.com/core/commands/all"
|
|
||||||
"v2ray.com/core/commands/base"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
base.RootCommand.Long = "A tool set for V2Ray."
|
|
||||||
base.Execute()
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"v2ray.com/core/commands/base"
|
"v2ray.com/core/main/commands/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CmdAPI calls an API in an V2Ray process
|
// CmdAPI calls an API in an V2Ray process
|
@ -4,10 +4,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
handlerService "v2ray.com/core/app/proxyman/command"
|
handlerService "v2ray.com/core/app/proxyman/command"
|
||||||
"v2ray.com/core/commands/base"
|
|
||||||
"v2ray.com/core/common/cmdarg"
|
"v2ray.com/core/common/cmdarg"
|
||||||
"v2ray.com/core/infra/conf"
|
"v2ray.com/core/infra/conf"
|
||||||
"v2ray.com/core/infra/conf/serial"
|
"v2ray.com/core/infra/conf/serial"
|
||||||
|
"v2ray.com/core/main/commands/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cmdAddInbounds = &base.Command{
|
var cmdAddInbounds = &base.Command{
|
@ -4,9 +4,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
handlerService "v2ray.com/core/app/proxyman/command"
|
handlerService "v2ray.com/core/app/proxyman/command"
|
||||||
"v2ray.com/core/commands/base"
|
|
||||||
"v2ray.com/core/common/cmdarg"
|
"v2ray.com/core/common/cmdarg"
|
||||||
"v2ray.com/core/infra/conf/serial"
|
"v2ray.com/core/infra/conf/serial"
|
||||||
|
"v2ray.com/core/main/commands/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cmdRemoveInbounds = &base.Command{
|
var cmdRemoveInbounds = &base.Command{
|
@ -2,7 +2,7 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
logService "v2ray.com/core/app/log/command"
|
logService "v2ray.com/core/app/log/command"
|
||||||
"v2ray.com/core/commands/base"
|
"v2ray.com/core/main/commands/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cmdRestartLogger = &base.Command{
|
var cmdRestartLogger = &base.Command{
|
@ -4,10 +4,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
handlerService "v2ray.com/core/app/proxyman/command"
|
handlerService "v2ray.com/core/app/proxyman/command"
|
||||||
"v2ray.com/core/commands/base"
|
|
||||||
"v2ray.com/core/common/cmdarg"
|
"v2ray.com/core/common/cmdarg"
|
||||||
"v2ray.com/core/infra/conf"
|
"v2ray.com/core/infra/conf"
|
||||||
"v2ray.com/core/infra/conf/serial"
|
"v2ray.com/core/infra/conf/serial"
|
||||||
|
"v2ray.com/core/main/commands/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cmdAddOutbounds = &base.Command{
|
var cmdAddOutbounds = &base.Command{
|
@ -4,9 +4,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
handlerService "v2ray.com/core/app/proxyman/command"
|
handlerService "v2ray.com/core/app/proxyman/command"
|
||||||
"v2ray.com/core/commands/base"
|
|
||||||
"v2ray.com/core/common/cmdarg"
|
"v2ray.com/core/common/cmdarg"
|
||||||
"v2ray.com/core/infra/conf/serial"
|
"v2ray.com/core/infra/conf/serial"
|
||||||
|
"v2ray.com/core/main/commands/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cmdRemoveOutbounds = &base.Command{
|
var cmdRemoveOutbounds = &base.Command{
|
@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
"v2ray.com/core/commands/base"
|
"v2ray.com/core/main/commands/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
type serviceHandler func(ctx context.Context, conn *grpc.ClientConn, cmd *base.Command, args []string) string
|
type serviceHandler func(ctx context.Context, conn *grpc.ClientConn, cmd *base.Command, args []string) string
|
@ -2,7 +2,7 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
statsService "v2ray.com/core/app/stats/command"
|
statsService "v2ray.com/core/app/stats/command"
|
||||||
"v2ray.com/core/commands/base"
|
"v2ray.com/core/main/commands/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cmdGetStats = &base.Command{
|
var cmdGetStats = &base.Command{
|
@ -2,7 +2,7 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
statsService "v2ray.com/core/app/stats/command"
|
statsService "v2ray.com/core/app/stats/command"
|
||||||
"v2ray.com/core/commands/base"
|
"v2ray.com/core/main/commands/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cmdQueryStats = &base.Command{
|
var cmdQueryStats = &base.Command{
|
@ -2,7 +2,7 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
statsService "v2ray.com/core/app/stats/command"
|
statsService "v2ray.com/core/app/stats/command"
|
||||||
"v2ray.com/core/commands/base"
|
"v2ray.com/core/main/commands/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cmdSysStats = &base.Command{
|
var cmdSysStats = &base.Command{
|
@ -1,9 +1,9 @@
|
|||||||
package all
|
package all
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"v2ray.com/core/commands/all/api"
|
"v2ray.com/core/main/commands/all/api"
|
||||||
"v2ray.com/core/commands/all/tls"
|
"v2ray.com/core/main/commands/all/tls"
|
||||||
"v2ray.com/core/commands/base"
|
"v2ray.com/core/main/commands/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
// go:generate go run v2ray.com/core/common/errors/errorgen
|
// go:generate go run v2ray.com/core/common/errors/errorgen
|
@ -8,8 +8,8 @@ import (
|
|||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
"v2ray.com/core/commands/base"
|
|
||||||
"v2ray.com/core/infra/conf/serial"
|
"v2ray.com/core/infra/conf/serial"
|
||||||
|
"v2ray.com/core/main/commands/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cmdConvert = &base.Command{
|
var cmdConvert = &base.Command{
|
@ -6,10 +6,10 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"v2ray.com/core/commands/base"
|
|
||||||
"v2ray.com/core/common/cmdarg"
|
"v2ray.com/core/common/cmdarg"
|
||||||
"v2ray.com/core/infra/conf/json"
|
"v2ray.com/core/infra/conf/json"
|
||||||
"v2ray.com/core/infra/conf/merge"
|
"v2ray.com/core/infra/conf/merge"
|
||||||
|
"v2ray.com/core/main/commands/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
func mergeConvertToMap(files []string, format string) map[string]interface{} {
|
func mergeConvertToMap(files []string, format string) map[string]interface{} {
|
@ -1,7 +1,7 @@
|
|||||||
package all
|
package all
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"v2ray.com/core/commands/base"
|
"v2ray.com/core/main/commands/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
var docFormat = &base.Command{
|
var docFormat = &base.Command{
|
@ -7,9 +7,9 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"v2ray.com/core/commands/base"
|
|
||||||
"v2ray.com/core/common"
|
"v2ray.com/core/common"
|
||||||
"v2ray.com/core/common/platform"
|
"v2ray.com/core/common/platform"
|
||||||
|
"v2ray.com/core/main/commands/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cmdLove = &base.Command{
|
var cmdLove = &base.Command{
|
@ -1,7 +1,7 @@
|
|||||||
package all
|
package all
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"v2ray.com/core/commands/base"
|
"v2ray.com/core/main/commands/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
var docMerge = &base.Command{
|
var docMerge = &base.Command{
|
@ -8,10 +8,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"v2ray.com/core/commands/base"
|
|
||||||
"v2ray.com/core/common"
|
"v2ray.com/core/common"
|
||||||
"v2ray.com/core/common/protocol/tls/cert"
|
"v2ray.com/core/common/protocol/tls/cert"
|
||||||
"v2ray.com/core/common/task"
|
"v2ray.com/core/common/task"
|
||||||
|
"v2ray.com/core/main/commands/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
// cmdCert is the tls cert command
|
// cmdCert is the tls cert command
|
@ -6,7 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"v2ray.com/core/commands/base"
|
"v2ray.com/core/main/commands/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
// cmdPing is the tls ping command
|
// cmdPing is the tls ping command
|
@ -1,7 +1,7 @@
|
|||||||
package tls
|
package tls
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"v2ray.com/core/commands/base"
|
"v2ray.com/core/main/commands/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CmdTLS holds all tls sub commands
|
// CmdTLS holds all tls sub commands
|
@ -3,8 +3,8 @@ package all
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"v2ray.com/core/commands/base"
|
|
||||||
"v2ray.com/core/common/uuid"
|
"v2ray.com/core/common/uuid"
|
||||||
|
"v2ray.com/core/main/commands/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cmdUUID = &base.Command{
|
var cmdUUID = &base.Command{
|
@ -4,7 +4,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/v2fly/VSign/signerVerify"
|
"github.com/v2fly/VSign/signerVerify"
|
||||||
"v2ray.com/core/commands/base"
|
"v2ray.com/core/main/commands/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cmdVerify = &base.Command{
|
var cmdVerify = &base.Command{
|
@ -11,9 +11,9 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"v2ray.com/core"
|
"v2ray.com/core"
|
||||||
"v2ray.com/core/commands/base"
|
|
||||||
"v2ray.com/core/common/cmdarg"
|
"v2ray.com/core/common/cmdarg"
|
||||||
"v2ray.com/core/common/platform"
|
"v2ray.com/core/common/platform"
|
||||||
|
"v2ray.com/core/main/commands/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CmdRun runs V2Ray with config
|
// CmdRun runs V2Ray with config
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
|
|
||||||
"v2ray.com/core"
|
"v2ray.com/core"
|
||||||
"v2ray.com/core/commands/base"
|
"v2ray.com/core/main/commands/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CmdTest tests config files
|
// CmdTest tests config files
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"v2ray.com/core"
|
"v2ray.com/core"
|
||||||
"v2ray.com/core/commands/base"
|
"v2ray.com/core/main/commands/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CmdVersion prints V2Ray Versions
|
// CmdVersion prints V2Ray Versions
|
||||||
|
@ -62,5 +62,5 @@ import (
|
|||||||
_ "v2ray.com/core/main/yaml"
|
_ "v2ray.com/core/main/yaml"
|
||||||
|
|
||||||
// commands
|
// commands
|
||||||
_ "v2ray.com/core/commands/all"
|
_ "v2ray.com/core/main/commands/all"
|
||||||
)
|
)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"v2ray.com/core/commands/base"
|
|
||||||
"v2ray.com/core/main/commands"
|
"v2ray.com/core/main/commands"
|
||||||
|
"v2ray.com/core/main/commands/base"
|
||||||
_ "v2ray.com/core/main/distro/all"
|
_ "v2ray.com/core/main/distro/all"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
// Package blackhole is an outbound handler that blocks all connections.
|
// Package blackhole is an outbound handler that blocks all connections.
|
||||||
package blackhole
|
package blackhole
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package dns
|
package dns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package dokodemo
|
package dokodemo
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate go run v2ray.com/core/common/errors/errorgen
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package freedom
|
package freedom
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate go run v2ray.com/core/common/errors/errorgen
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package http
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package http
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package shadowsocks
|
package shadowsocks
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package shadowsocks
|
package shadowsocks
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package shadowsocks
|
package shadowsocks
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package socks
|
package socks
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package socks
|
package socks
|
||||||
|
|
||||||
import "v2ray.com/core/common/protocol"
|
import "v2ray.com/core/common/protocol"
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package socks
|
package socks
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package socks
|
package socks
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package trojan
|
package trojan
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package trojan
|
package trojan
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package trojan
|
package trojan
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package vless
|
package vless
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package encoding
|
package encoding
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package encoding
|
package encoding
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate go run v2ray.com/core/common/errors/errorgen
|
||||||
|
@ -1,3 +1 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package inbound
|
package inbound
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package inbound
|
package inbound
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate go run v2ray.com/core/common/errors/errorgen
|
||||||
|
@ -1,3 +1 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package outbound
|
package outbound
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package outbound
|
package outbound
|
||||||
|
|
||||||
//go:generate go run v2ray.com/core/common/errors/errorgen
|
//go:generate go run v2ray.com/core/common/errors/errorgen
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !confonly
|
|
||||||
|
|
||||||
package vless
|
package vless
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user