Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions common/platform/ctlcmd/attr_other.go

This file was deleted.

12 changes: 0 additions & 12 deletions common/platform/ctlcmd/attr_windows.go

This file was deleted.

50 changes: 0 additions & 50 deletions common/platform/ctlcmd/ctlcmd.go

This file was deleted.

9 changes: 0 additions & 9 deletions common/platform/others.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,10 @@ import (
"path/filepath"
)

func ExpandEnv(s string) string {
return os.ExpandEnv(s)
}

func LineSeparator() string {
return "\n"
}

func GetToolLocation(file string) string {
toolPath := NewEnvFlag(ToolLocation).GetValue(getExecutableDir)
return filepath.Join(toolPath, file)
}

// GetAssetLocation searches for `file` in the env dir, the executable dir, and certain locations
func GetAssetLocation(file string) string {
assetPath := NewEnvFlag(AssetLocation).GetValue(getExecutableDir)
Expand Down
13 changes: 0 additions & 13 deletions common/platform/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import (
)

const (
PluginLocation = "xray.location.plugin"
ConfigLocation = "xray.location.config"
ConfdirLocation = "xray.location.confdir"
ToolLocation = "xray.location.tool"
AssetLocation = "xray.location.asset"
CertLocation = "xray.location.cert"

Expand Down Expand Up @@ -79,17 +77,6 @@ func getExecutableDir() string {
return filepath.Dir(exec)
}

func getExecutableSubDir(dir string) func() string {
return func() string {
return filepath.Join(getExecutableDir(), dir)
}
}

func GetPluginDirectory() string {
pluginDir := NewEnvFlag(PluginLocation).GetValue(getExecutableSubDir("plugins"))
return pluginDir
}

func GetConfigurationPath() string {
configPath := NewEnvFlag(ConfigLocation).GetValue(getExecutableDir)
return filepath.Join(configPath, "config.json")
Expand Down
10 changes: 0 additions & 10 deletions common/platform/windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,10 @@ package platform

import "path/filepath"

func ExpandEnv(s string) string {
// TODO
return s
}

func LineSeparator() string {
return "\r\n"
}

func GetToolLocation(file string) string {
toolPath := NewEnvFlag(ToolLocation).GetValue(getExecutableDir)
return filepath.Join(toolPath, file+".exe")
}

// GetAssetLocation searches for `file` in the env dir and the executable dir
func GetAssetLocation(file string) string {
assetPath := NewEnvFlag(AssetLocation).GetValue(getExecutableDir)
Expand Down
6 changes: 3 additions & 3 deletions core/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func GetMergedConfig(args cmdarg.Arg) (string, error) {
var files []*ConfigSource
supported := []string{"json", "yaml", "toml"}
for _, file := range args {
format := getFormat(file)
format := GetFormat(file)
if slices.Contains(supported, format) {
files = append(files, &ConfigSource{
Name: file,
Expand Down Expand Up @@ -98,7 +98,7 @@ func getExtension(filename string) string {
return filename[idx+1:]
}

func getFormat(filename string) string {
func GetFormat(filename string) string {
return GetFormatByExtension(getExtension(filename))
}

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

if formatName == "auto" {
if file != "stdin:" {
f = getFormat(file)
f = GetFormat(file)
} else {
f = "json"
}
Expand Down
4 changes: 0 additions & 4 deletions infra/conf/xray.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package conf
import (
"context"
"encoding/json"
"log"
"os"
"path/filepath"
"strings"

Expand Down Expand Up @@ -47,8 +45,6 @@ var (
"dns": func() interface{} { return new(DNSOutboundConfig) },
"wireguard": func() interface{} { return &WireGuardConfig{IsClient: true} },
}, "protocol", "settings")

ctllog = log.New(os.Stderr, "xctl> ", 0)
)

type SniffingConfig struct {
Expand Down
11 changes: 1 addition & 10 deletions main/commands/all/convert/protobuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package convert
import (
"fmt"
"os"
"strings"

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

if len(optFile) > 0 {
switch core.GetFormatByExtension(getFileExtension(optFile)){
switch core.GetFormat(optFile){
case "protobuf", "":
fmt.Println("Output ProtoBuf file is ", optFile)
default:
Expand Down Expand Up @@ -106,11 +105,3 @@ func executeConvertConfigsToProtobuf(cmd *base.Command, args []string) {
}
}
}

func getFileExtension(filename string) string {
idx := strings.LastIndexByte(filename, '.')
if idx == -1 {
return ""
}
return filename[idx+1:]
}
12 changes: 0 additions & 12 deletions main/confloader/confloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ import (

type (
configFileLoader func(string) (io.Reader, error)
extconfigLoader func([]string, io.Reader) (io.Reader, error)
)

var (
EffectiveConfigFileLoader configFileLoader
EffectiveExtConfigLoader extconfigLoader
)

// LoadConfig reads from a path/url/stdin
Expand All @@ -27,13 +25,3 @@ func LoadConfig(file string) (io.Reader, error) {
}
return EffectiveConfigFileLoader(file)
}

// LoadExtConfig calls xctl to handle multiple config
// the actual work also in external module
func LoadExtConfig(files []string, reader io.Reader) (io.Reader, error) {
if EffectiveExtConfigLoader == nil {
return nil, errors.New("external config module not loaded").AtError()
}

return EffectiveExtConfigLoader(files, reader)
}
11 changes: 0 additions & 11 deletions main/confloader/external/external.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (

"github.com/xtls/xray-core/common/buf"
"github.com/xtls/xray-core/common/errors"
"github.com/xtls/xray-core/common/platform/ctlcmd"
"github.com/xtls/xray-core/main/confloader"
)

Expand Down Expand Up @@ -129,16 +128,6 @@ func FetchUnixSocketHTTPContent(target string) ([]byte, error) {
return content, nil
}

func ExtConfigLoader(files []string, reader io.Reader) (io.Reader, error) {
buf, err := ctlcmd.Run(append([]string{"convert"}, files...), reader)
if err != nil {
return nil, err
}

return strings.NewReader(buf.String()), nil
}

func init() {
confloader.EffectiveConfigFileLoader = ConfigLoader
confloader.EffectiveExtConfigLoader = ExtConfigLoader
}