Skip to content

Commit aea1238

Browse files
Chore: Remove ctlcmd and leftover envvar (#5392)
v2fly/v2ray-core#360
1 parent bd7503d commit aea1238

File tree

11 files changed

+4
-144
lines changed

11 files changed

+4
-144
lines changed

common/platform/ctlcmd/attr_other.go

Lines changed: 0 additions & 10 deletions
This file was deleted.

common/platform/ctlcmd/attr_windows.go

Lines changed: 0 additions & 12 deletions
This file was deleted.

common/platform/ctlcmd/ctlcmd.go

Lines changed: 0 additions & 50 deletions
This file was deleted.

common/platform/others.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,10 @@ import (
88
"path/filepath"
99
)
1010

11-
func ExpandEnv(s string) string {
12-
return os.ExpandEnv(s)
13-
}
14-
1511
func LineSeparator() string {
1612
return "\n"
1713
}
1814

19-
func GetToolLocation(file string) string {
20-
toolPath := NewEnvFlag(ToolLocation).GetValue(getExecutableDir)
21-
return filepath.Join(toolPath, file)
22-
}
23-
2415
// GetAssetLocation searches for `file` in the env dir, the executable dir, and certain locations
2516
func GetAssetLocation(file string) string {
2617
assetPath := NewEnvFlag(AssetLocation).GetValue(getExecutableDir)

common/platform/platform.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ import (
88
)
99

1010
const (
11-
PluginLocation = "xray.location.plugin"
1211
ConfigLocation = "xray.location.config"
1312
ConfdirLocation = "xray.location.confdir"
14-
ToolLocation = "xray.location.tool"
1513
AssetLocation = "xray.location.asset"
1614
CertLocation = "xray.location.cert"
1715

@@ -79,17 +77,6 @@ func getExecutableDir() string {
7977
return filepath.Dir(exec)
8078
}
8179

82-
func getExecutableSubDir(dir string) func() string {
83-
return func() string {
84-
return filepath.Join(getExecutableDir(), dir)
85-
}
86-
}
87-
88-
func GetPluginDirectory() string {
89-
pluginDir := NewEnvFlag(PluginLocation).GetValue(getExecutableSubDir("plugins"))
90-
return pluginDir
91-
}
92-
9380
func GetConfigurationPath() string {
9481
configPath := NewEnvFlag(ConfigLocation).GetValue(getExecutableDir)
9582
return filepath.Join(configPath, "config.json")

common/platform/windows.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,10 @@ package platform
55

66
import "path/filepath"
77

8-
func ExpandEnv(s string) string {
9-
// TODO
10-
return s
11-
}
12-
138
func LineSeparator() string {
149
return "\r\n"
1510
}
1611

17-
func GetToolLocation(file string) string {
18-
toolPath := NewEnvFlag(ToolLocation).GetValue(getExecutableDir)
19-
return filepath.Join(toolPath, file+".exe")
20-
}
21-
2212
// GetAssetLocation searches for `file` in the env dir and the executable dir
2313
func GetAssetLocation(file string) string {
2414
assetPath := NewEnvFlag(AssetLocation).GetValue(getExecutableDir)

core/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func GetMergedConfig(args cmdarg.Arg) (string, error) {
6464
var files []*ConfigSource
6565
supported := []string{"json", "yaml", "toml"}
6666
for _, file := range args {
67-
format := getFormat(file)
67+
format := GetFormat(file)
6868
if slices.Contains(supported, format) {
6969
files = append(files, &ConfigSource{
7070
Name: file,
@@ -98,7 +98,7 @@ func getExtension(filename string) string {
9898
return filename[idx+1:]
9999
}
100100

101-
func getFormat(filename string) string {
101+
func GetFormat(filename string) string {
102102
return GetFormatByExtension(getExtension(filename))
103103
}
104104

@@ -112,7 +112,7 @@ func LoadConfig(formatName string, input interface{}) (*Config, error) {
112112

113113
if formatName == "auto" {
114114
if file != "stdin:" {
115-
f = getFormat(file)
115+
f = GetFormat(file)
116116
} else {
117117
f = "json"
118118
}

infra/conf/xray.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package conf
33
import (
44
"context"
55
"encoding/json"
6-
"log"
7-
"os"
86
"path/filepath"
97
"strings"
108

@@ -47,8 +45,6 @@ var (
4745
"dns": func() interface{} { return new(DNSOutboundConfig) },
4846
"wireguard": func() interface{} { return &WireGuardConfig{IsClient: true} },
4947
}, "protocol", "settings")
50-
51-
ctllog = log.New(os.Stderr, "xctl> ", 0)
5248
)
5349

5450
type SniffingConfig struct {

main/commands/all/convert/protobuf.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package convert
33
import (
44
"fmt"
55
"os"
6-
"strings"
76

87
"github.com/xtls/xray-core/common/cmdarg"
98
creflect "github.com/xtls/xray-core/common/reflect"
@@ -61,7 +60,7 @@ func executeConvertConfigsToProtobuf(cmd *base.Command, args []string) {
6160
}
6261

6362
if len(optFile) > 0 {
64-
switch core.GetFormatByExtension(getFileExtension(optFile)){
63+
switch core.GetFormat(optFile){
6564
case "protobuf", "":
6665
fmt.Println("Output ProtoBuf file is ", optFile)
6766
default:
@@ -106,11 +105,3 @@ func executeConvertConfigsToProtobuf(cmd *base.Command, args []string) {
106105
}
107106
}
108107
}
109-
110-
func getFileExtension(filename string) string {
111-
idx := strings.LastIndexByte(filename, '.')
112-
if idx == -1 {
113-
return ""
114-
}
115-
return filename[idx+1:]
116-
}

main/confloader/confloader.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ import (
1010

1111
type (
1212
configFileLoader func(string) (io.Reader, error)
13-
extconfigLoader func([]string, io.Reader) (io.Reader, error)
1413
)
1514

1615
var (
1716
EffectiveConfigFileLoader configFileLoader
18-
EffectiveExtConfigLoader extconfigLoader
1917
)
2018

2119
// LoadConfig reads from a path/url/stdin
@@ -27,13 +25,3 @@ func LoadConfig(file string) (io.Reader, error) {
2725
}
2826
return EffectiveConfigFileLoader(file)
2927
}
30-
31-
// LoadExtConfig calls xctl to handle multiple config
32-
// the actual work also in external module
33-
func LoadExtConfig(files []string, reader io.Reader) (io.Reader, error) {
34-
if EffectiveExtConfigLoader == nil {
35-
return nil, errors.New("external config module not loaded").AtError()
36-
}
37-
38-
return EffectiveExtConfigLoader(files, reader)
39-
}

0 commit comments

Comments
 (0)