Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config: Remove some legacy fields from V2Ray 3.x era #3776

Merged
merged 5 commits into from
Sep 9, 2024
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
16 changes: 0 additions & 16 deletions app/proxyman/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,5 @@ func (c *ReceiverConfig) GetEffectiveSniffingSettings() *SniffingConfig {
return c.SniffingSettings
}

if len(c.DomainOverride) > 0 {
var p []string
for _, kd := range c.DomainOverride {
switch kd {
case KnownProtocols_HTTP:
p = append(p, "http")
case KnownProtocols_TLS:
p = append(p, "tls")
}
}
return &SniffingConfig{
Enabled: true,
DestinationOverride: p,
}
}

return nil
}
169 changes: 50 additions & 119 deletions app/proxyman/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 1 addition & 9 deletions app/proxyman/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ message AllocationStrategy {
AllocationStrategyRefresh refresh = 3;
}

enum KnownProtocols {
HTTP = 0;
TLS = 1;
}

message SniffingConfig {
// Whether or not to enable content sniffing on an inbound connection.
bool enabled = 1;
Expand All @@ -71,10 +66,7 @@ message ReceiverConfig {
xray.transport.internet.StreamConfig stream_settings = 4;
bool receive_original_destination = 5;
reserved 6;
// Override domains for the given protocol.
// Deprecated. Use sniffing_settings.
repeated KnownProtocols domain_override = 7 [ deprecated = true ];
SniffingConfig sniffing_settings = 8;
SniffingConfig sniffing_settings = 7;
}

message InboundHandlerConfig {
Expand Down
7 changes: 0 additions & 7 deletions infra/conf/vmess.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ func (c *VMessDetourConfig) Build() *inbound.DetourConfig {
}
}

type FeaturesConfig struct {
Detour *VMessDetourConfig `json:"detour"`
}

type VMessDefaultConfig struct {
Level byte `json:"level"`
}
Expand All @@ -74,7 +70,6 @@ func (c *VMessDefaultConfig) Build() *inbound.DefaultConfig {

type VMessInboundConfig struct {
Users []json.RawMessage `json:"clients"`
Features *FeaturesConfig `json:"features"`
Defaults *VMessDefaultConfig `json:"default"`
DetourConfig *VMessDetourConfig `json:"detour"`
}
Expand All @@ -89,8 +84,6 @@ func (c *VMessInboundConfig) Build() (proto.Message, error) {

if c.DetourConfig != nil {
config.Detour = c.DetourConfig.Build()
} else if c.Features != nil && c.Features.Detour != nil {
config.Detour = c.Features.Detour.Build()
}

config.User = make([]*protocol.User, len(c.Users))
Expand Down
23 changes: 0 additions & 23 deletions infra/conf/xray.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,6 @@ var (
ctllog = log.New(os.Stderr, "xctl> ", 0)
)

func toProtocolList(s []string) ([]proxyman.KnownProtocols, error) {
kp := make([]proxyman.KnownProtocols, 0, 8)
for _, p := range s {
switch strings.ToLower(p) {
case "http":
kp = append(kp, proxyman.KnownProtocols_HTTP)
case "https", "tls", "ssl":
kp = append(kp, proxyman.KnownProtocols_TLS)
default:
return nil, errors.New("Unknown protocol: ", p)
}
}
return kp, nil
}

type SniffingConfig struct {
Enabled bool `json:"enabled"`
DestOverride *StringList `json:"destOverride"`
Expand Down Expand Up @@ -175,7 +160,6 @@ type InboundDetourConfig struct {
Tag string `json:"tag"`
Allocation *InboundDetourAllocationConfig `json:"allocate"`
StreamSetting *StreamConfig `json:"streamSettings"`
DomainOverride *StringList `json:"domainOverride"`
SniffingConfig *SniffingConfig `json:"sniffing"`
}

Expand Down Expand Up @@ -249,13 +233,6 @@ func (c *InboundDetourConfig) Build() (*core.InboundHandlerConfig, error) {
}
receiverSettings.SniffingSettings = s
}
if c.DomainOverride != nil {
kp, err := toProtocolList(*c.DomainOverride)
if err != nil {
return nil, errors.New("failed to parse inbound detour config").Base(err)
}
receiverSettings.DomainOverride = kp
}

settings := []byte("{}")
if c.Settings != nil {
Expand Down
5 changes: 3 additions & 2 deletions testing/scenarios/feature_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,9 @@ func TestDomainSniffing(t *testing.T) {
ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{
PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(sniffingPort)}},
Listen: net.NewIPOrDomain(net.LocalHostIP),
DomainOverride: []proxyman.KnownProtocols{
proxyman.KnownProtocols_TLS,
SniffingSettings: &proxyman.SniffingConfig{
Enabled: true,
DestinationOverride: []string{"tls"},
},
}),
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
Expand Down