mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-05-01 01:44:15 +00:00
Config: Remove more legacy fields (#3817)
This commit is contained in:
parent
f406b2dee0
commit
57a41f3b4b
52 changed files with 569 additions and 1157 deletions
|
@ -9,7 +9,6 @@ type DokodemoConfig struct {
|
|||
Host *Address `json:"address"`
|
||||
PortValue uint16 `json:"port"`
|
||||
NetworkList *NetworkList `json:"network"`
|
||||
TimeoutValue uint32 `json:"timeout"`
|
||||
Redirect bool `json:"followRedirect"`
|
||||
UserLevel uint32 `json:"userLevel"`
|
||||
}
|
||||
|
@ -21,7 +20,6 @@ func (v *DokodemoConfig) Build() (proto.Message, error) {
|
|||
}
|
||||
config.Port = uint32(v.PortValue)
|
||||
config.Networks = v.NetworkList.Build()
|
||||
config.Timeout = v.TimeoutValue
|
||||
config.FollowRedirect = v.Redirect
|
||||
config.UserLevel = v.UserLevel
|
||||
return config, nil
|
||||
|
|
|
@ -19,7 +19,6 @@ func TestDokodemoConfig(t *testing.T) {
|
|||
"address": "8.8.8.8",
|
||||
"port": 53,
|
||||
"network": "tcp",
|
||||
"timeout": 10,
|
||||
"followRedirect": true,
|
||||
"userLevel": 1
|
||||
}`,
|
||||
|
@ -32,7 +31,6 @@ func TestDokodemoConfig(t *testing.T) {
|
|||
},
|
||||
Port: 53,
|
||||
Networks: []net.Network{net.Network_TCP},
|
||||
Timeout: 10,
|
||||
FollowRedirect: true,
|
||||
UserLevel: 1,
|
||||
},
|
||||
|
|
|
@ -15,7 +15,6 @@ import (
|
|||
|
||||
type FreedomConfig struct {
|
||||
DomainStrategy string `json:"domainStrategy"`
|
||||
Timeout *uint32 `json:"timeout"`
|
||||
Redirect string `json:"redirect"`
|
||||
UserLevel uint32 `json:"userLevel"`
|
||||
Fragment *Fragment `json:"fragment"`
|
||||
|
@ -167,9 +166,6 @@ func (c *FreedomConfig) Build() (proto.Message, error) {
|
|||
}
|
||||
}
|
||||
|
||||
if c.Timeout != nil {
|
||||
config.Timeout = *c.Timeout
|
||||
}
|
||||
config.UserLevel = c.UserLevel
|
||||
if len(c.Redirect) > 0 {
|
||||
host, portStr, err := net.SplitHostPort(c.Redirect)
|
||||
|
|
|
@ -18,14 +18,12 @@ func TestFreedomConfig(t *testing.T) {
|
|||
{
|
||||
Input: `{
|
||||
"domainStrategy": "AsIs",
|
||||
"timeout": 10,
|
||||
"redirect": "127.0.0.1:3366",
|
||||
"userLevel": 1
|
||||
}`,
|
||||
Parser: loadJSON(creator),
|
||||
Output: &freedom.Config{
|
||||
DomainStrategy: freedom.Config_AS_IS,
|
||||
Timeout: 10,
|
||||
DestinationOverride: &freedom.DestinationOverride{
|
||||
Server: &protocol.ServerEndpoint{
|
||||
Address: &net.IPOrDomain{
|
||||
|
|
|
@ -23,7 +23,6 @@ func (v *HTTPAccount) Build() *http.Account {
|
|||
}
|
||||
|
||||
type HTTPServerConfig struct {
|
||||
Timeout uint32 `json:"timeout"`
|
||||
Accounts []*HTTPAccount `json:"accounts"`
|
||||
Transparent bool `json:"allowTransparent"`
|
||||
UserLevel uint32 `json:"userLevel"`
|
||||
|
@ -31,7 +30,6 @@ type HTTPServerConfig struct {
|
|||
|
||||
func (c *HTTPServerConfig) Build() (proto.Message, error) {
|
||||
config := &http.ServerConfig{
|
||||
Timeout: c.Timeout,
|
||||
AllowTransparent: c.Transparent,
|
||||
UserLevel: c.UserLevel,
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ func TestHTTPServerConfig(t *testing.T) {
|
|||
runMultiTestCase(t, []TestCase{
|
||||
{
|
||||
Input: `{
|
||||
"timeout": 10,
|
||||
"accounts": [
|
||||
{
|
||||
"user": "my-username",
|
||||
|
@ -32,7 +31,6 @@ func TestHTTPServerConfig(t *testing.T) {
|
|||
},
|
||||
AllowTransparent: true,
|
||||
UserLevel: 1,
|
||||
Timeout: 10,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
|
@ -2,7 +2,6 @@ package conf
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
|
||||
"github.com/xtls/xray-core/common/errors"
|
||||
"github.com/xtls/xray-core/common/protocol"
|
||||
|
@ -33,7 +32,6 @@ type SocksServerConfig struct {
|
|||
Accounts []*SocksAccount `json:"accounts"`
|
||||
UDP bool `json:"udp"`
|
||||
Host *Address `json:"ip"`
|
||||
Timeout uint32 `json:"timeout"`
|
||||
UserLevel uint32 `json:"userLevel"`
|
||||
}
|
||||
|
||||
|
@ -61,7 +59,6 @@ func (v *SocksServerConfig) Build() (proto.Message, error) {
|
|||
config.Address = v.Host.Build()
|
||||
}
|
||||
|
||||
config.Timeout = v.Timeout
|
||||
config.UserLevel = v.UserLevel
|
||||
return config, nil
|
||||
}
|
||||
|
@ -74,22 +71,11 @@ type SocksRemoteConfig struct {
|
|||
|
||||
type SocksClientConfig struct {
|
||||
Servers []*SocksRemoteConfig `json:"servers"`
|
||||
Version string `json:"version"`
|
||||
}
|
||||
|
||||
func (v *SocksClientConfig) Build() (proto.Message, error) {
|
||||
config := new(socks.ClientConfig)
|
||||
config.Server = make([]*protocol.ServerEndpoint, len(v.Servers))
|
||||
switch strings.ToLower(v.Version) {
|
||||
case "4":
|
||||
config.Version = socks.Version_SOCKS4
|
||||
case "4a":
|
||||
config.Version = socks.Version_SOCKS4A
|
||||
case "", "5":
|
||||
config.Version = socks.Version_SOCKS5
|
||||
default:
|
||||
return nil, errors.New("failed to parse socks server version: ", v.Version).AtError()
|
||||
}
|
||||
for idx, serverConfig := range v.Servers {
|
||||
server := &protocol.ServerEndpoint{
|
||||
Address: serverConfig.Address.Build(),
|
||||
|
@ -104,9 +90,6 @@ func (v *SocksClientConfig) Build() (proto.Message, error) {
|
|||
if err := json.Unmarshal(rawUser, account); err != nil {
|
||||
return nil, errors.New("failed to parse socks account").Base(err).AtError()
|
||||
}
|
||||
if config.Version != socks.Version_SOCKS5 && account.Password != "" {
|
||||
return nil, errors.New("password is only supported in socks5").AtError()
|
||||
}
|
||||
user.Account = serial.ToTypedMessage(account.Build())
|
||||
server.User = append(server.User, user)
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ func TestSocksInboundConfig(t *testing.T) {
|
|||
],
|
||||
"udp": false,
|
||||
"ip": "127.0.0.1",
|
||||
"timeout": 5,
|
||||
"userLevel": 1
|
||||
}`,
|
||||
Parser: loadJSON(creator),
|
||||
|
@ -42,7 +41,6 @@ func TestSocksInboundConfig(t *testing.T) {
|
|||
Ip: []byte{127, 0, 0, 1},
|
||||
},
|
||||
},
|
||||
Timeout: 5,
|
||||
UserLevel: 1,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -94,7 +94,6 @@ type TrojanUserConfig struct {
|
|||
// TrojanServerConfig is Inbound configuration
|
||||
type TrojanServerConfig struct {
|
||||
Clients []*TrojanUserConfig `json:"clients"`
|
||||
Fallback *TrojanInboundFallback `json:"fallback"`
|
||||
Fallbacks []*TrojanInboundFallback `json:"fallbacks"`
|
||||
}
|
||||
|
||||
|
@ -118,9 +117,6 @@ func (c *TrojanServerConfig) Build() (proto.Message, error) {
|
|||
}
|
||||
}
|
||||
|
||||
if c.Fallback != nil {
|
||||
return nil, errors.New(`Trojan settings: please use "fallbacks":[{}] instead of "fallback":{}`)
|
||||
}
|
||||
for _, fb := range c.Fallbacks {
|
||||
var i uint16
|
||||
var s string
|
||||
|
|
|
@ -31,7 +31,6 @@ type VLessInboundFallback struct {
|
|||
type VLessInboundConfig struct {
|
||||
Clients []json.RawMessage `json:"clients"`
|
||||
Decryption string `json:"decryption"`
|
||||
Fallback *VLessInboundFallback `json:"fallback"`
|
||||
Fallbacks []*VLessInboundFallback `json:"fallbacks"`
|
||||
}
|
||||
|
||||
|
@ -74,9 +73,6 @@ func (c *VLessInboundConfig) Build() (proto.Message, error) {
|
|||
}
|
||||
config.Decryption = c.Decryption
|
||||
|
||||
if c.Fallback != nil {
|
||||
return nil, errors.New(`VLESS settings: please use "fallbacks":[{}] instead of "fallback":{}`)
|
||||
}
|
||||
for _, fb := range c.Fallbacks {
|
||||
var i uint16
|
||||
var s string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue