mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-08-22 09:36:49 +08:00
Compare commits
42 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6baad79f98 | ||
![]() |
98e85b7f3c | ||
![]() |
002d08bf83 | ||
![]() |
8674ed5a0d | ||
![]() |
815a959c96 | ||
![]() |
1cfed96aba | ||
![]() |
592c2daf58 | ||
![]() |
5d7dfbbcac | ||
![]() |
3dd3bf94d4 | ||
![]() |
c0c23fdfeb | ||
![]() |
34e0a2fb41 | ||
![]() |
83eef6bc1f | ||
![]() |
2be03c56cb | ||
![]() |
790f908f0b | ||
![]() |
0df7fa23f8 | ||
![]() |
41d03d1856 | ||
![]() |
160316d53c | ||
![]() |
1562e1ffb9 | ||
![]() |
11b04807b9 | ||
![]() |
b612da26eb | ||
![]() |
030c9efc8c | ||
![]() |
08d1840344 | ||
![]() |
f0547bc04d | ||
![]() |
498d8eb3cc | ||
![]() |
0c7303960a | ||
![]() |
513182adf3 | ||
![]() |
a3b306aaa4 | ||
![]() |
f650d87083 | ||
![]() |
85e2ebc6f7 | ||
![]() |
9e93c19161 | ||
![]() |
96e8b8b279 | ||
![]() |
1a95add8e3 | ||
![]() |
ac628a9427 | ||
![]() |
4a1c0d7124 | ||
![]() |
661cb901de | ||
![]() |
c6d9d430bf | ||
![]() |
1dfec5056d | ||
![]() |
2a5eb3db7d | ||
![]() |
4c9e4b9de7 | ||
![]() |
644901d1a5 | ||
![]() |
7e24239c9a | ||
![]() |
4b7947cca9 |
12
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
12
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@@ -13,16 +13,14 @@ body:
|
||||
required: true
|
||||
- label: I searched issues and did not find any similar issues.
|
||||
required: true
|
||||
- type: input
|
||||
attributes:
|
||||
label: Version
|
||||
description: Version of Xray-core
|
||||
validations:
|
||||
required: true
|
||||
- label: The problem can be successfully reproduced in the latest Release
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Description
|
||||
description: Please provide a detailed description of the error. And the information you think valuable.
|
||||
description: |-
|
||||
Please provide a detailed description of the error. And the information you think valuable.
|
||||
If the problem occurs after the update, please provide the **specific** version
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
|
14
.github/ISSUE_TEMPLATE/bug_report_zh.yml
vendored
14
.github/ISSUE_TEMPLATE/bug_report_zh.yml
vendored
@@ -11,18 +11,16 @@ body:
|
||||
required: true
|
||||
- label: 我提供了完整的配置文件和日志,而不是出于自己的判断只给出截取的部分。
|
||||
required: true
|
||||
- label: 我搜索了issues,没有发现已提出的类似问题。
|
||||
- label: 我搜索了 issues, 没有发现已提出的类似问题。
|
||||
required: true
|
||||
- label: 问题在 Release 最新的版本上可以成功复现
|
||||
required: true
|
||||
- type: input
|
||||
attributes:
|
||||
label: 版本
|
||||
description: 使用的Xray-core版本
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: 描述
|
||||
description: 请提供错误的详细描述。以及你认为有价值的信息。
|
||||
description: |-
|
||||
请提供错误的详细描述。以及你认为有价值的信息。
|
||||
如果问题在更新后出现,请提供**具体**出现问题的版本号。
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
|
2
.github/docker/Dockerfile
vendored
2
.github/docker/Dockerfile
vendored
@@ -25,4 +25,4 @@ ENTRYPOINT [ "/usr/bin/xray" ]
|
||||
CMD [ "-config", "/etc/xray/config.json" ]
|
||||
|
||||
ARG flavor=v2fly
|
||||
COPY --from=build /$flavor /usr/share/xray
|
||||
COPY --from=build --chmod=644 /$flavor /usr/share/xray
|
||||
|
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -187,7 +187,7 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ matrix.gotoolchain || '1.22' }}
|
||||
go-version: ${{ matrix.gotoolchain || '1.23' }}
|
||||
check-latest: true
|
||||
|
||||
- name: Get project dependencies
|
||||
|
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@@ -32,7 +32,7 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.22'
|
||||
go-version: '1.23'
|
||||
check-latest: true
|
||||
- name: Restore Cache
|
||||
uses: actions/cache/restore@v4
|
||||
|
@@ -4,6 +4,10 @@
|
||||
|
||||
[README](https://github.com/XTLS/Xray-core#readme) is open, so feel free to submit your project [here](https://github.com/XTLS/Xray-core/pulls).
|
||||
|
||||
## Donation & NFTs
|
||||
|
||||
[Announcement of NFTs by Project X](https://github.com/XTLS/Xray-core/discussions/3633)
|
||||
|
||||
## License
|
||||
|
||||
[Mozilla Public License Version 2.0](https://github.com/XTLS/Xray-core/blob/main/LICENSE)
|
||||
@@ -18,6 +22,8 @@
|
||||
|
||||
[Project X Channel](https://t.me/projectXtls)
|
||||
|
||||
[Project VLESS](https://t.me/projectVless) (non-Chinese)
|
||||
|
||||
## Installation
|
||||
|
||||
- Linux Script
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: app/commander/config.proto
|
||||
|
||||
@@ -166,7 +166,7 @@ func file_app_commander_config_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_app_commander_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_app_commander_config_proto_goTypes = []interface{}{
|
||||
var file_app_commander_config_proto_goTypes = []any{
|
||||
(*Config)(nil), // 0: xray.app.commander.Config
|
||||
(*ReflectionConfig)(nil), // 1: xray.app.commander.ReflectionConfig
|
||||
(*serial.TypedMessage)(nil), // 2: xray.common.serial.TypedMessage
|
||||
@@ -186,7 +186,7 @@ func file_app_commander_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_app_commander_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_commander_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -198,7 +198,7 @@ func file_app_commander_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_commander_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_commander_config_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ReflectionConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: app/dispatcher/config.proto
|
||||
|
||||
@@ -139,7 +139,7 @@ func file_app_dispatcher_config_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_app_dispatcher_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_app_dispatcher_config_proto_goTypes = []interface{}{
|
||||
var file_app_dispatcher_config_proto_goTypes = []any{
|
||||
(*SessionConfig)(nil), // 0: xray.app.dispatcher.SessionConfig
|
||||
(*Config)(nil), // 1: xray.app.dispatcher.Config
|
||||
}
|
||||
@@ -158,7 +158,7 @@ func file_app_dispatcher_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_app_dispatcher_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_dispatcher_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*SessionConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -170,7 +170,7 @@ func file_app_dispatcher_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_dispatcher_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_dispatcher_config_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: app/dns/config.proto
|
||||
|
||||
@@ -658,7 +658,7 @@ func file_app_dns_config_proto_rawDescGZIP() []byte {
|
||||
|
||||
var file_app_dns_config_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
|
||||
var file_app_dns_config_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
|
||||
var file_app_dns_config_proto_goTypes = []interface{}{
|
||||
var file_app_dns_config_proto_goTypes = []any{
|
||||
(DomainMatchingType)(0), // 0: xray.app.dns.DomainMatchingType
|
||||
(QueryStrategy)(0), // 1: xray.app.dns.QueryStrategy
|
||||
(*NameServer)(nil), // 2: xray.app.dns.NameServer
|
||||
@@ -698,7 +698,7 @@ func file_app_dns_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_app_dns_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_dns_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*NameServer); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -710,7 +710,7 @@ func file_app_dns_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_dns_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_dns_config_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -722,7 +722,7 @@ func file_app_dns_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_dns_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_dns_config_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*NameServer_PriorityDomain); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -734,7 +734,7 @@ func file_app_dns_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_dns_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_dns_config_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*NameServer_OriginalRule); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -746,7 +746,7 @@ func file_app_dns_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_dns_config_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_dns_config_proto_msgTypes[5].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config_HostMapping); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: app/dns/fakedns/fakedns.proto
|
||||
|
||||
@@ -159,7 +159,7 @@ func file_app_dns_fakedns_fakedns_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_app_dns_fakedns_fakedns_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_app_dns_fakedns_fakedns_proto_goTypes = []interface{}{
|
||||
var file_app_dns_fakedns_fakedns_proto_goTypes = []any{
|
||||
(*FakeDnsPool)(nil), // 0: xray.app.dns.fakedns.FakeDnsPool
|
||||
(*FakeDnsPoolMulti)(nil), // 1: xray.app.dns.fakedns.FakeDnsPoolMulti
|
||||
}
|
||||
@@ -178,7 +178,7 @@ func file_app_dns_fakedns_fakedns_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_app_dns_fakedns_fakedns_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_dns_fakedns_fakedns_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*FakeDnsPool); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -190,7 +190,7 @@ func file_app_dns_fakedns_fakedns_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_dns_fakedns_fakedns_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_dns_fakedns_fakedns_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*FakeDnsPoolMulti); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -62,7 +62,7 @@ func NewServer(dest net.Destination, dispatcher routing.Dispatcher, queryStrateg
|
||||
dest.Network = net.Network_UDP
|
||||
}
|
||||
if dest.Network == net.Network_UDP { // UDP classic DNS mode
|
||||
return NewClassicNameServer(dest, dispatcher), nil
|
||||
return NewClassicNameServer(dest, dispatcher, queryStrategy), nil
|
||||
}
|
||||
return nil, errors.New("No available name server could be created from ", dest).AtWarning()
|
||||
}
|
||||
@@ -90,7 +90,7 @@ func NewClient(
|
||||
ns.PrioritizedDomain = append(ns.PrioritizedDomain, localTLDsAndDotlessDomains...)
|
||||
ns.OriginalRules = append(ns.OriginalRules, localTLDsAndDotlessDomainsRule)
|
||||
// The following lines is a solution to avoid core panics(rule index out of range) when setting `localhost` DNS client in config.
|
||||
// Because the `localhost` DNS client will apend len(localTLDsAndDotlessDomains) rules into matcherInfos to match `geosite:private` default rule.
|
||||
// Because the `localhost` DNS client will append len(localTLDsAndDotlessDomains) rules into matcherInfos to match `geosite:private` default rule.
|
||||
// But `matcherInfos` has no enough length to add rules, which leads to core panics (rule index out of range).
|
||||
// To avoid this, the length of `matcherInfos` must be equal to the expected, so manually append it with Golang default zero value first for later modification.
|
||||
// Related issues:
|
||||
|
@@ -24,29 +24,31 @@ import (
|
||||
// ClassicNameServer implemented traditional UDP DNS.
|
||||
type ClassicNameServer struct {
|
||||
sync.RWMutex
|
||||
name string
|
||||
address *net.Destination
|
||||
ips map[string]*record
|
||||
requests map[uint16]*dnsRequest
|
||||
pub *pubsub.Service
|
||||
udpServer *udp.Dispatcher
|
||||
cleanup *task.Periodic
|
||||
reqID uint32
|
||||
name string
|
||||
address *net.Destination
|
||||
ips map[string]*record
|
||||
requests map[uint16]*dnsRequest
|
||||
pub *pubsub.Service
|
||||
udpServer *udp.Dispatcher
|
||||
cleanup *task.Periodic
|
||||
reqID uint32
|
||||
queryStrategy QueryStrategy
|
||||
}
|
||||
|
||||
// NewClassicNameServer creates udp server object for remote resolving.
|
||||
func NewClassicNameServer(address net.Destination, dispatcher routing.Dispatcher) *ClassicNameServer {
|
||||
func NewClassicNameServer(address net.Destination, dispatcher routing.Dispatcher, queryStrategy QueryStrategy) *ClassicNameServer {
|
||||
// default to 53 if unspecific
|
||||
if address.Port == 0 {
|
||||
address.Port = net.Port(53)
|
||||
}
|
||||
|
||||
s := &ClassicNameServer{
|
||||
address: &address,
|
||||
ips: make(map[string]*record),
|
||||
requests: make(map[uint16]*dnsRequest),
|
||||
pub: pubsub.NewService(),
|
||||
name: strings.ToUpper(address.String()),
|
||||
address: &address,
|
||||
ips: make(map[string]*record),
|
||||
requests: make(map[uint16]*dnsRequest),
|
||||
pub: pubsub.NewService(),
|
||||
name: strings.ToUpper(address.String()),
|
||||
queryStrategy: queryStrategy,
|
||||
}
|
||||
s.cleanup = &task.Periodic{
|
||||
Interval: time.Minute,
|
||||
@@ -239,6 +241,10 @@ func (s *ClassicNameServer) findIPsForDomain(domain string, option dns_feature.I
|
||||
// QueryIP implements Server.
|
||||
func (s *ClassicNameServer) QueryIP(ctx context.Context, domain string, clientIP net.IP, option dns_feature.IPOption, disableCache bool) ([]net.IP, error) {
|
||||
fqdn := Fqdn(domain)
|
||||
option = ResolveIpOptionOverride(s.queryStrategy, option)
|
||||
if !option.IPv4Enable && !option.IPv6Enable {
|
||||
return nil, dns_feature.ErrEmptyResponse
|
||||
}
|
||||
|
||||
if disableCache {
|
||||
errors.LogDebug(ctx, "DNS cache is disabled. Querying IP for ", domain, " at ", s.name)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: app/log/command/config.proto
|
||||
|
||||
@@ -174,7 +174,7 @@ func file_app_log_command_config_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_app_log_command_config_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_app_log_command_config_proto_goTypes = []interface{}{
|
||||
var file_app_log_command_config_proto_goTypes = []any{
|
||||
(*Config)(nil), // 0: xray.app.log.command.Config
|
||||
(*RestartLoggerRequest)(nil), // 1: xray.app.log.command.RestartLoggerRequest
|
||||
(*RestartLoggerResponse)(nil), // 2: xray.app.log.command.RestartLoggerResponse
|
||||
@@ -195,7 +195,7 @@ func file_app_log_command_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_app_log_command_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_log_command_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -207,7 +207,7 @@ func file_app_log_command_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_log_command_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_log_command_config_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*RestartLoggerRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -219,7 +219,7 @@ func file_app_log_command_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_log_command_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_log_command_config_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*RestartLoggerResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.3.0
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc v5.27.0
|
||||
// source: app/log/command/config.proto
|
||||
|
||||
@@ -15,8 +15,8 @@ import (
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
LoggerService_RestartLogger_FullMethodName = "/xray.app.log.command.LoggerService/RestartLogger"
|
||||
@@ -38,8 +38,9 @@ func NewLoggerServiceClient(cc grpc.ClientConnInterface) LoggerServiceClient {
|
||||
}
|
||||
|
||||
func (c *loggerServiceClient) RestartLogger(ctx context.Context, in *RestartLoggerRequest, opts ...grpc.CallOption) (*RestartLoggerResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(RestartLoggerResponse)
|
||||
err := c.cc.Invoke(ctx, LoggerService_RestartLogger_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, LoggerService_RestartLogger_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -48,20 +49,24 @@ func (c *loggerServiceClient) RestartLogger(ctx context.Context, in *RestartLogg
|
||||
|
||||
// LoggerServiceServer is the server API for LoggerService service.
|
||||
// All implementations must embed UnimplementedLoggerServiceServer
|
||||
// for forward compatibility
|
||||
// for forward compatibility.
|
||||
type LoggerServiceServer interface {
|
||||
RestartLogger(context.Context, *RestartLoggerRequest) (*RestartLoggerResponse, error)
|
||||
mustEmbedUnimplementedLoggerServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedLoggerServiceServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedLoggerServiceServer struct {
|
||||
}
|
||||
// UnimplementedLoggerServiceServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedLoggerServiceServer struct{}
|
||||
|
||||
func (UnimplementedLoggerServiceServer) RestartLogger(context.Context, *RestartLoggerRequest) (*RestartLoggerResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method RestartLogger not implemented")
|
||||
}
|
||||
func (UnimplementedLoggerServiceServer) mustEmbedUnimplementedLoggerServiceServer() {}
|
||||
func (UnimplementedLoggerServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeLoggerServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to LoggerServiceServer will
|
||||
@@ -71,6 +76,13 @@ type UnsafeLoggerServiceServer interface {
|
||||
}
|
||||
|
||||
func RegisterLoggerServiceServer(s grpc.ServiceRegistrar, srv LoggerServiceServer) {
|
||||
// If the following call pancis, it indicates UnimplementedLoggerServiceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&LoggerService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: app/log/config.proto
|
||||
|
||||
@@ -211,7 +211,7 @@ func file_app_log_config_proto_rawDescGZIP() []byte {
|
||||
|
||||
var file_app_log_config_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_app_log_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_app_log_config_proto_goTypes = []interface{}{
|
||||
var file_app_log_config_proto_goTypes = []any{
|
||||
(LogType)(0), // 0: xray.app.log.LogType
|
||||
(*Config)(nil), // 1: xray.app.log.Config
|
||||
(log.Severity)(0), // 2: xray.common.log.Severity
|
||||
@@ -233,7 +233,7 @@ func file_app_log_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_app_log_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_log_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: app/metrics/config.proto
|
||||
|
||||
@@ -98,7 +98,7 @@ func file_app_metrics_config_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_app_metrics_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_app_metrics_config_proto_goTypes = []interface{}{
|
||||
var file_app_metrics_config_proto_goTypes = []any{
|
||||
(*Config)(nil), // 0: xray.app.metrics.Config
|
||||
}
|
||||
var file_app_metrics_config_proto_depIdxs = []int32{
|
||||
@@ -115,7 +115,7 @@ func file_app_metrics_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_app_metrics_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_metrics_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: app/observatory/burst/config.proto
|
||||
|
||||
@@ -211,7 +211,7 @@ func file_app_observatory_burst_config_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_app_observatory_burst_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_app_observatory_burst_config_proto_goTypes = []interface{}{
|
||||
var file_app_observatory_burst_config_proto_goTypes = []any{
|
||||
(*Config)(nil), // 0: xray.core.app.observatory.burst.Config
|
||||
(*HealthPingConfig)(nil), // 1: xray.core.app.observatory.burst.HealthPingConfig
|
||||
}
|
||||
@@ -230,7 +230,7 @@ func file_app_observatory_burst_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_app_observatory_burst_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_observatory_burst_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -242,7 +242,7 @@ func file_app_observatory_burst_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_observatory_burst_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_observatory_burst_config_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*HealthPingConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: app/observatory/command/command.proto
|
||||
|
||||
@@ -197,7 +197,7 @@ func file_app_observatory_command_command_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_app_observatory_command_command_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_app_observatory_command_command_proto_goTypes = []interface{}{
|
||||
var file_app_observatory_command_command_proto_goTypes = []any{
|
||||
(*GetOutboundStatusRequest)(nil), // 0: xray.core.app.observatory.command.GetOutboundStatusRequest
|
||||
(*GetOutboundStatusResponse)(nil), // 1: xray.core.app.observatory.command.GetOutboundStatusResponse
|
||||
(*Config)(nil), // 2: xray.core.app.observatory.command.Config
|
||||
@@ -220,7 +220,7 @@ func file_app_observatory_command_command_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_app_observatory_command_command_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_observatory_command_command_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*GetOutboundStatusRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -232,7 +232,7 @@ func file_app_observatory_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_observatory_command_command_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_observatory_command_command_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*GetOutboundStatusResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -244,7 +244,7 @@ func file_app_observatory_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_observatory_command_command_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_observatory_command_command_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.3.0
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc v5.27.0
|
||||
// source: app/observatory/command/command.proto
|
||||
|
||||
@@ -15,8 +15,8 @@ import (
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
ObservatoryService_GetOutboundStatus_FullMethodName = "/xray.core.app.observatory.command.ObservatoryService/GetOutboundStatus"
|
||||
@@ -38,8 +38,9 @@ func NewObservatoryServiceClient(cc grpc.ClientConnInterface) ObservatoryService
|
||||
}
|
||||
|
||||
func (c *observatoryServiceClient) GetOutboundStatus(ctx context.Context, in *GetOutboundStatusRequest, opts ...grpc.CallOption) (*GetOutboundStatusResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetOutboundStatusResponse)
|
||||
err := c.cc.Invoke(ctx, ObservatoryService_GetOutboundStatus_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, ObservatoryService_GetOutboundStatus_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -48,20 +49,24 @@ func (c *observatoryServiceClient) GetOutboundStatus(ctx context.Context, in *Ge
|
||||
|
||||
// ObservatoryServiceServer is the server API for ObservatoryService service.
|
||||
// All implementations must embed UnimplementedObservatoryServiceServer
|
||||
// for forward compatibility
|
||||
// for forward compatibility.
|
||||
type ObservatoryServiceServer interface {
|
||||
GetOutboundStatus(context.Context, *GetOutboundStatusRequest) (*GetOutboundStatusResponse, error)
|
||||
mustEmbedUnimplementedObservatoryServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedObservatoryServiceServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedObservatoryServiceServer struct {
|
||||
}
|
||||
// UnimplementedObservatoryServiceServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedObservatoryServiceServer struct{}
|
||||
|
||||
func (UnimplementedObservatoryServiceServer) GetOutboundStatus(context.Context, *GetOutboundStatusRequest) (*GetOutboundStatusResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetOutboundStatus not implemented")
|
||||
}
|
||||
func (UnimplementedObservatoryServiceServer) mustEmbedUnimplementedObservatoryServiceServer() {}
|
||||
func (UnimplementedObservatoryServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeObservatoryServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to ObservatoryServiceServer will
|
||||
@@ -71,6 +76,13 @@ type UnsafeObservatoryServiceServer interface {
|
||||
}
|
||||
|
||||
func RegisterObservatoryServiceServer(s grpc.ServiceRegistrar, srv ObservatoryServiceServer) {
|
||||
// If the following call pancis, it indicates UnimplementedObservatoryServiceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&ObservatoryService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: app/observatory/config.proto
|
||||
|
||||
@@ -536,7 +536,7 @@ func file_app_observatory_config_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_app_observatory_config_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
|
||||
var file_app_observatory_config_proto_goTypes = []interface{}{
|
||||
var file_app_observatory_config_proto_goTypes = []any{
|
||||
(*ObservationResult)(nil), // 0: xray.core.app.observatory.ObservationResult
|
||||
(*HealthPingMeasurementResult)(nil), // 1: xray.core.app.observatory.HealthPingMeasurementResult
|
||||
(*OutboundStatus)(nil), // 2: xray.core.app.observatory.OutboundStatus
|
||||
@@ -560,7 +560,7 @@ func file_app_observatory_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_app_observatory_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_observatory_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ObservationResult); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -572,7 +572,7 @@ func file_app_observatory_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_observatory_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_observatory_config_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*HealthPingMeasurementResult); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -584,7 +584,7 @@ func file_app_observatory_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_observatory_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_observatory_config_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*OutboundStatus); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -596,7 +596,7 @@ func file_app_observatory_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_observatory_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_observatory_config_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ProbeResult); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -608,7 +608,7 @@ func file_app_observatory_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_observatory_config_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_observatory_config_proto_msgTypes[4].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Intensity); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -620,7 +620,7 @@ func file_app_observatory_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_observatory_config_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_observatory_config_proto_msgTypes[5].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: app/policy/config.proto
|
||||
|
||||
@@ -570,7 +570,7 @@ func file_app_policy_config_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_app_policy_config_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
|
||||
var file_app_policy_config_proto_goTypes = []interface{}{
|
||||
var file_app_policy_config_proto_goTypes = []any{
|
||||
(*Second)(nil), // 0: xray.app.policy.Second
|
||||
(*Policy)(nil), // 1: xray.app.policy.Policy
|
||||
(*SystemPolicy)(nil), // 2: xray.app.policy.SystemPolicy
|
||||
@@ -606,7 +606,7 @@ func file_app_policy_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_app_policy_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_policy_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Second); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -618,7 +618,7 @@ func file_app_policy_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_policy_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_policy_config_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Policy); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -630,7 +630,7 @@ func file_app_policy_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_policy_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_policy_config_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*SystemPolicy); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -642,7 +642,7 @@ func file_app_policy_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_policy_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_policy_config_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -654,7 +654,7 @@ func file_app_policy_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_policy_config_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_policy_config_proto_msgTypes[4].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Policy_Timeout); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -666,7 +666,7 @@ func file_app_policy_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_policy_config_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_policy_config_proto_msgTypes[5].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Policy_Stats); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -678,7 +678,7 @@ func file_app_policy_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_policy_config_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_policy_config_proto_msgTypes[6].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Policy_Buffer); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -690,7 +690,7 @@ func file_app_policy_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_policy_config_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_policy_config_proto_msgTypes[7].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*SystemPolicy_Stats); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: app/proxyman/command/command.proto
|
||||
|
||||
@@ -806,7 +806,7 @@ func file_app_proxyman_command_command_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_app_proxyman_command_command_proto_msgTypes = make([]protoimpl.MessageInfo, 15)
|
||||
var file_app_proxyman_command_command_proto_goTypes = []interface{}{
|
||||
var file_app_proxyman_command_command_proto_goTypes = []any{
|
||||
(*AddUserOperation)(nil), // 0: xray.app.proxyman.command.AddUserOperation
|
||||
(*RemoveUserOperation)(nil), // 1: xray.app.proxyman.command.RemoveUserOperation
|
||||
(*AddInboundRequest)(nil), // 2: xray.app.proxyman.command.AddInboundRequest
|
||||
@@ -858,7 +858,7 @@ func file_app_proxyman_command_command_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_app_proxyman_command_command_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_proxyman_command_command_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*AddUserOperation); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -870,7 +870,7 @@ func file_app_proxyman_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_proxyman_command_command_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_proxyman_command_command_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*RemoveUserOperation); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -882,7 +882,7 @@ func file_app_proxyman_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_proxyman_command_command_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_proxyman_command_command_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*AddInboundRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -894,7 +894,7 @@ func file_app_proxyman_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_proxyman_command_command_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_proxyman_command_command_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*AddInboundResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -906,7 +906,7 @@ func file_app_proxyman_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_proxyman_command_command_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_proxyman_command_command_proto_msgTypes[4].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*RemoveInboundRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -918,7 +918,7 @@ func file_app_proxyman_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_proxyman_command_command_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_proxyman_command_command_proto_msgTypes[5].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*RemoveInboundResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -930,7 +930,7 @@ func file_app_proxyman_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_proxyman_command_command_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_proxyman_command_command_proto_msgTypes[6].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*AlterInboundRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -942,7 +942,7 @@ func file_app_proxyman_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_proxyman_command_command_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_proxyman_command_command_proto_msgTypes[7].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*AlterInboundResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -954,7 +954,7 @@ func file_app_proxyman_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_proxyman_command_command_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_proxyman_command_command_proto_msgTypes[8].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*AddOutboundRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -966,7 +966,7 @@ func file_app_proxyman_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_proxyman_command_command_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_proxyman_command_command_proto_msgTypes[9].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*AddOutboundResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -978,7 +978,7 @@ func file_app_proxyman_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_proxyman_command_command_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_proxyman_command_command_proto_msgTypes[10].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*RemoveOutboundRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -990,7 +990,7 @@ func file_app_proxyman_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_proxyman_command_command_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_proxyman_command_command_proto_msgTypes[11].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*RemoveOutboundResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1002,7 +1002,7 @@ func file_app_proxyman_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_proxyman_command_command_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_proxyman_command_command_proto_msgTypes[12].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*AlterOutboundRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1014,7 +1014,7 @@ func file_app_proxyman_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_proxyman_command_command_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_proxyman_command_command_proto_msgTypes[13].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*AlterOutboundResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1026,7 +1026,7 @@ func file_app_proxyman_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_proxyman_command_command_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_proxyman_command_command_proto_msgTypes[14].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.3.0
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc v5.27.0
|
||||
// source: app/proxyman/command/command.proto
|
||||
|
||||
@@ -15,8 +15,8 @@ import (
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
HandlerService_AddInbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/AddInbound"
|
||||
@@ -48,8 +48,9 @@ func NewHandlerServiceClient(cc grpc.ClientConnInterface) HandlerServiceClient {
|
||||
}
|
||||
|
||||
func (c *handlerServiceClient) AddInbound(ctx context.Context, in *AddInboundRequest, opts ...grpc.CallOption) (*AddInboundResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(AddInboundResponse)
|
||||
err := c.cc.Invoke(ctx, HandlerService_AddInbound_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, HandlerService_AddInbound_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -57,8 +58,9 @@ func (c *handlerServiceClient) AddInbound(ctx context.Context, in *AddInboundReq
|
||||
}
|
||||
|
||||
func (c *handlerServiceClient) RemoveInbound(ctx context.Context, in *RemoveInboundRequest, opts ...grpc.CallOption) (*RemoveInboundResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(RemoveInboundResponse)
|
||||
err := c.cc.Invoke(ctx, HandlerService_RemoveInbound_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, HandlerService_RemoveInbound_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -66,8 +68,9 @@ func (c *handlerServiceClient) RemoveInbound(ctx context.Context, in *RemoveInbo
|
||||
}
|
||||
|
||||
func (c *handlerServiceClient) AlterInbound(ctx context.Context, in *AlterInboundRequest, opts ...grpc.CallOption) (*AlterInboundResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(AlterInboundResponse)
|
||||
err := c.cc.Invoke(ctx, HandlerService_AlterInbound_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, HandlerService_AlterInbound_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -75,8 +78,9 @@ func (c *handlerServiceClient) AlterInbound(ctx context.Context, in *AlterInboun
|
||||
}
|
||||
|
||||
func (c *handlerServiceClient) AddOutbound(ctx context.Context, in *AddOutboundRequest, opts ...grpc.CallOption) (*AddOutboundResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(AddOutboundResponse)
|
||||
err := c.cc.Invoke(ctx, HandlerService_AddOutbound_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, HandlerService_AddOutbound_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -84,8 +88,9 @@ func (c *handlerServiceClient) AddOutbound(ctx context.Context, in *AddOutboundR
|
||||
}
|
||||
|
||||
func (c *handlerServiceClient) RemoveOutbound(ctx context.Context, in *RemoveOutboundRequest, opts ...grpc.CallOption) (*RemoveOutboundResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(RemoveOutboundResponse)
|
||||
err := c.cc.Invoke(ctx, HandlerService_RemoveOutbound_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, HandlerService_RemoveOutbound_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -93,8 +98,9 @@ func (c *handlerServiceClient) RemoveOutbound(ctx context.Context, in *RemoveOut
|
||||
}
|
||||
|
||||
func (c *handlerServiceClient) AlterOutbound(ctx context.Context, in *AlterOutboundRequest, opts ...grpc.CallOption) (*AlterOutboundResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(AlterOutboundResponse)
|
||||
err := c.cc.Invoke(ctx, HandlerService_AlterOutbound_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, HandlerService_AlterOutbound_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -103,7 +109,7 @@ func (c *handlerServiceClient) AlterOutbound(ctx context.Context, in *AlterOutbo
|
||||
|
||||
// HandlerServiceServer is the server API for HandlerService service.
|
||||
// All implementations must embed UnimplementedHandlerServiceServer
|
||||
// for forward compatibility
|
||||
// for forward compatibility.
|
||||
type HandlerServiceServer interface {
|
||||
AddInbound(context.Context, *AddInboundRequest) (*AddInboundResponse, error)
|
||||
RemoveInbound(context.Context, *RemoveInboundRequest) (*RemoveInboundResponse, error)
|
||||
@@ -114,9 +120,12 @@ type HandlerServiceServer interface {
|
||||
mustEmbedUnimplementedHandlerServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedHandlerServiceServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedHandlerServiceServer struct {
|
||||
}
|
||||
// UnimplementedHandlerServiceServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedHandlerServiceServer struct{}
|
||||
|
||||
func (UnimplementedHandlerServiceServer) AddInbound(context.Context, *AddInboundRequest) (*AddInboundResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method AddInbound not implemented")
|
||||
@@ -137,6 +146,7 @@ func (UnimplementedHandlerServiceServer) AlterOutbound(context.Context, *AlterOu
|
||||
return nil, status.Errorf(codes.Unimplemented, "method AlterOutbound not implemented")
|
||||
}
|
||||
func (UnimplementedHandlerServiceServer) mustEmbedUnimplementedHandlerServiceServer() {}
|
||||
func (UnimplementedHandlerServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeHandlerServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to HandlerServiceServer will
|
||||
@@ -146,6 +156,13 @@ type UnsafeHandlerServiceServer interface {
|
||||
}
|
||||
|
||||
func RegisterHandlerServiceServer(s grpc.ServiceRegistrar, srv HandlerServiceServer) {
|
||||
// If the following call pancis, it indicates UnimplementedHandlerServiceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&HandlerService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: app/proxyman/config.proto
|
||||
|
||||
@@ -920,7 +920,7 @@ func file_app_proxyman_config_proto_rawDescGZIP() []byte {
|
||||
|
||||
var file_app_proxyman_config_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
|
||||
var file_app_proxyman_config_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
|
||||
var file_app_proxyman_config_proto_goTypes = []interface{}{
|
||||
var file_app_proxyman_config_proto_goTypes = []any{
|
||||
(KnownProtocols)(0), // 0: xray.app.proxyman.KnownProtocols
|
||||
(AllocationStrategy_Type)(0), // 1: xray.app.proxyman.AllocationStrategy.Type
|
||||
(*InboundConfig)(nil), // 2: xray.app.proxyman.InboundConfig
|
||||
@@ -968,7 +968,7 @@ func file_app_proxyman_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_app_proxyman_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_proxyman_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*InboundConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -980,7 +980,7 @@ func file_app_proxyman_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_proxyman_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_proxyman_config_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*AllocationStrategy); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -992,7 +992,7 @@ func file_app_proxyman_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_proxyman_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_proxyman_config_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*SniffingConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1004,7 +1004,7 @@ func file_app_proxyman_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_proxyman_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_proxyman_config_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ReceiverConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1016,7 +1016,7 @@ func file_app_proxyman_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_proxyman_config_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_proxyman_config_proto_msgTypes[4].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*InboundHandlerConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1028,7 +1028,7 @@ func file_app_proxyman_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_proxyman_config_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_proxyman_config_proto_msgTypes[5].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*OutboundConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1040,7 +1040,7 @@ func file_app_proxyman_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_proxyman_config_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_proxyman_config_proto_msgTypes[6].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*SenderConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1052,7 +1052,7 @@ func file_app_proxyman_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_proxyman_config_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_proxyman_config_proto_msgTypes[7].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*MultiplexingConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1064,7 +1064,7 @@ func file_app_proxyman_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_proxyman_config_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_proxyman_config_proto_msgTypes[8].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*AllocationStrategy_AllocationStrategyConcurrency); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1076,7 +1076,7 @@ func file_app_proxyman_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_proxyman_config_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_proxyman_config_proto_msgTypes[9].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*AllocationStrategy_AllocationStrategyRefresh); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: app/reverse/config.proto
|
||||
|
||||
@@ -338,7 +338,7 @@ func file_app_reverse_config_proto_rawDescGZIP() []byte {
|
||||
|
||||
var file_app_reverse_config_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_app_reverse_config_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||
var file_app_reverse_config_proto_goTypes = []interface{}{
|
||||
var file_app_reverse_config_proto_goTypes = []any{
|
||||
(Control_State)(0), // 0: xray.app.reverse.Control.State
|
||||
(*Control)(nil), // 1: xray.app.reverse.Control
|
||||
(*BridgeConfig)(nil), // 2: xray.app.reverse.BridgeConfig
|
||||
@@ -362,7 +362,7 @@ func file_app_reverse_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_app_reverse_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_reverse_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Control); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -374,7 +374,7 @@ func file_app_reverse_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_reverse_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_reverse_config_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*BridgeConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -386,7 +386,7 @@ func file_app_reverse_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_reverse_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_reverse_config_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*PortalConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -398,7 +398,7 @@ func file_app_reverse_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_reverse_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_reverse_config_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: app/router/command/command.proto
|
||||
|
||||
@@ -1019,7 +1019,7 @@ func file_app_router_command_command_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_app_router_command_command_proto_msgTypes = make([]protoimpl.MessageInfo, 16)
|
||||
var file_app_router_command_command_proto_goTypes = []interface{}{
|
||||
var file_app_router_command_command_proto_goTypes = []any{
|
||||
(*RoutingContext)(nil), // 0: xray.app.router.command.RoutingContext
|
||||
(*SubscribeRoutingStatsRequest)(nil), // 1: xray.app.router.command.SubscribeRoutingStatsRequest
|
||||
(*TestRouteRequest)(nil), // 2: xray.app.router.command.TestRouteRequest
|
||||
@@ -1072,7 +1072,7 @@ func file_app_router_command_command_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_app_router_command_command_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_router_command_command_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*RoutingContext); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1084,7 +1084,7 @@ func file_app_router_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_router_command_command_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_router_command_command_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*SubscribeRoutingStatsRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1096,7 +1096,7 @@ func file_app_router_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_router_command_command_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_router_command_command_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*TestRouteRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1108,7 +1108,7 @@ func file_app_router_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_router_command_command_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_router_command_command_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*PrincipleTargetInfo); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1120,7 +1120,7 @@ func file_app_router_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_router_command_command_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_router_command_command_proto_msgTypes[4].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*OverrideInfo); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1132,7 +1132,7 @@ func file_app_router_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_router_command_command_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_router_command_command_proto_msgTypes[5].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*BalancerMsg); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1144,7 +1144,7 @@ func file_app_router_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_router_command_command_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_router_command_command_proto_msgTypes[6].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*GetBalancerInfoRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1156,7 +1156,7 @@ func file_app_router_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_router_command_command_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_router_command_command_proto_msgTypes[7].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*GetBalancerInfoResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1168,7 +1168,7 @@ func file_app_router_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_router_command_command_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_router_command_command_proto_msgTypes[8].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*OverrideBalancerTargetRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1180,7 +1180,7 @@ func file_app_router_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_router_command_command_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_router_command_command_proto_msgTypes[9].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*OverrideBalancerTargetResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1192,7 +1192,7 @@ func file_app_router_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_router_command_command_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_router_command_command_proto_msgTypes[10].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*AddRuleRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1204,7 +1204,7 @@ func file_app_router_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_router_command_command_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_router_command_command_proto_msgTypes[11].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*AddRuleResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1216,7 +1216,7 @@ func file_app_router_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_router_command_command_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_router_command_command_proto_msgTypes[12].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*RemoveRuleRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1228,7 +1228,7 @@ func file_app_router_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_router_command_command_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_router_command_command_proto_msgTypes[13].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*RemoveRuleResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1240,7 +1240,7 @@ func file_app_router_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_router_command_command_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_router_command_command_proto_msgTypes[14].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.3.0
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc v5.27.0
|
||||
// source: app/router/command/command.proto
|
||||
|
||||
@@ -15,8 +15,8 @@ import (
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
RoutingService_SubscribeRoutingStats_FullMethodName = "/xray.app.router.command.RoutingService/SubscribeRoutingStats"
|
||||
@@ -31,7 +31,7 @@ const (
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type RoutingServiceClient interface {
|
||||
SubscribeRoutingStats(ctx context.Context, in *SubscribeRoutingStatsRequest, opts ...grpc.CallOption) (RoutingService_SubscribeRoutingStatsClient, error)
|
||||
SubscribeRoutingStats(ctx context.Context, in *SubscribeRoutingStatsRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[RoutingContext], error)
|
||||
TestRoute(ctx context.Context, in *TestRouteRequest, opts ...grpc.CallOption) (*RoutingContext, error)
|
||||
GetBalancerInfo(ctx context.Context, in *GetBalancerInfoRequest, opts ...grpc.CallOption) (*GetBalancerInfoResponse, error)
|
||||
OverrideBalancerTarget(ctx context.Context, in *OverrideBalancerTargetRequest, opts ...grpc.CallOption) (*OverrideBalancerTargetResponse, error)
|
||||
@@ -47,12 +47,13 @@ func NewRoutingServiceClient(cc grpc.ClientConnInterface) RoutingServiceClient {
|
||||
return &routingServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *routingServiceClient) SubscribeRoutingStats(ctx context.Context, in *SubscribeRoutingStatsRequest, opts ...grpc.CallOption) (RoutingService_SubscribeRoutingStatsClient, error) {
|
||||
stream, err := c.cc.NewStream(ctx, &RoutingService_ServiceDesc.Streams[0], RoutingService_SubscribeRoutingStats_FullMethodName, opts...)
|
||||
func (c *routingServiceClient) SubscribeRoutingStats(ctx context.Context, in *SubscribeRoutingStatsRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[RoutingContext], error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
stream, err := c.cc.NewStream(ctx, &RoutingService_ServiceDesc.Streams[0], RoutingService_SubscribeRoutingStats_FullMethodName, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &routingServiceSubscribeRoutingStatsClient{stream}
|
||||
x := &grpc.GenericClientStream[SubscribeRoutingStatsRequest, RoutingContext]{ClientStream: stream}
|
||||
if err := x.ClientStream.SendMsg(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -62,26 +63,13 @@ func (c *routingServiceClient) SubscribeRoutingStats(ctx context.Context, in *Su
|
||||
return x, nil
|
||||
}
|
||||
|
||||
type RoutingService_SubscribeRoutingStatsClient interface {
|
||||
Recv() (*RoutingContext, error)
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
type routingServiceSubscribeRoutingStatsClient struct {
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
func (x *routingServiceSubscribeRoutingStatsClient) Recv() (*RoutingContext, error) {
|
||||
m := new(RoutingContext)
|
||||
if err := x.ClientStream.RecvMsg(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type RoutingService_SubscribeRoutingStatsClient = grpc.ServerStreamingClient[RoutingContext]
|
||||
|
||||
func (c *routingServiceClient) TestRoute(ctx context.Context, in *TestRouteRequest, opts ...grpc.CallOption) (*RoutingContext, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(RoutingContext)
|
||||
err := c.cc.Invoke(ctx, RoutingService_TestRoute_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, RoutingService_TestRoute_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -89,8 +77,9 @@ func (c *routingServiceClient) TestRoute(ctx context.Context, in *TestRouteReque
|
||||
}
|
||||
|
||||
func (c *routingServiceClient) GetBalancerInfo(ctx context.Context, in *GetBalancerInfoRequest, opts ...grpc.CallOption) (*GetBalancerInfoResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetBalancerInfoResponse)
|
||||
err := c.cc.Invoke(ctx, RoutingService_GetBalancerInfo_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, RoutingService_GetBalancerInfo_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -98,8 +87,9 @@ func (c *routingServiceClient) GetBalancerInfo(ctx context.Context, in *GetBalan
|
||||
}
|
||||
|
||||
func (c *routingServiceClient) OverrideBalancerTarget(ctx context.Context, in *OverrideBalancerTargetRequest, opts ...grpc.CallOption) (*OverrideBalancerTargetResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(OverrideBalancerTargetResponse)
|
||||
err := c.cc.Invoke(ctx, RoutingService_OverrideBalancerTarget_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, RoutingService_OverrideBalancerTarget_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -107,8 +97,9 @@ func (c *routingServiceClient) OverrideBalancerTarget(ctx context.Context, in *O
|
||||
}
|
||||
|
||||
func (c *routingServiceClient) AddRule(ctx context.Context, in *AddRuleRequest, opts ...grpc.CallOption) (*AddRuleResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(AddRuleResponse)
|
||||
err := c.cc.Invoke(ctx, RoutingService_AddRule_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, RoutingService_AddRule_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -116,8 +107,9 @@ func (c *routingServiceClient) AddRule(ctx context.Context, in *AddRuleRequest,
|
||||
}
|
||||
|
||||
func (c *routingServiceClient) RemoveRule(ctx context.Context, in *RemoveRuleRequest, opts ...grpc.CallOption) (*RemoveRuleResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(RemoveRuleResponse)
|
||||
err := c.cc.Invoke(ctx, RoutingService_RemoveRule_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, RoutingService_RemoveRule_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -126,9 +118,9 @@ func (c *routingServiceClient) RemoveRule(ctx context.Context, in *RemoveRuleReq
|
||||
|
||||
// RoutingServiceServer is the server API for RoutingService service.
|
||||
// All implementations must embed UnimplementedRoutingServiceServer
|
||||
// for forward compatibility
|
||||
// for forward compatibility.
|
||||
type RoutingServiceServer interface {
|
||||
SubscribeRoutingStats(*SubscribeRoutingStatsRequest, RoutingService_SubscribeRoutingStatsServer) error
|
||||
SubscribeRoutingStats(*SubscribeRoutingStatsRequest, grpc.ServerStreamingServer[RoutingContext]) error
|
||||
TestRoute(context.Context, *TestRouteRequest) (*RoutingContext, error)
|
||||
GetBalancerInfo(context.Context, *GetBalancerInfoRequest) (*GetBalancerInfoResponse, error)
|
||||
OverrideBalancerTarget(context.Context, *OverrideBalancerTargetRequest) (*OverrideBalancerTargetResponse, error)
|
||||
@@ -137,11 +129,14 @@ type RoutingServiceServer interface {
|
||||
mustEmbedUnimplementedRoutingServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedRoutingServiceServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedRoutingServiceServer struct {
|
||||
}
|
||||
// UnimplementedRoutingServiceServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedRoutingServiceServer struct{}
|
||||
|
||||
func (UnimplementedRoutingServiceServer) SubscribeRoutingStats(*SubscribeRoutingStatsRequest, RoutingService_SubscribeRoutingStatsServer) error {
|
||||
func (UnimplementedRoutingServiceServer) SubscribeRoutingStats(*SubscribeRoutingStatsRequest, grpc.ServerStreamingServer[RoutingContext]) error {
|
||||
return status.Errorf(codes.Unimplemented, "method SubscribeRoutingStats not implemented")
|
||||
}
|
||||
func (UnimplementedRoutingServiceServer) TestRoute(context.Context, *TestRouteRequest) (*RoutingContext, error) {
|
||||
@@ -160,6 +155,7 @@ func (UnimplementedRoutingServiceServer) RemoveRule(context.Context, *RemoveRule
|
||||
return nil, status.Errorf(codes.Unimplemented, "method RemoveRule not implemented")
|
||||
}
|
||||
func (UnimplementedRoutingServiceServer) mustEmbedUnimplementedRoutingServiceServer() {}
|
||||
func (UnimplementedRoutingServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeRoutingServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to RoutingServiceServer will
|
||||
@@ -169,6 +165,13 @@ type UnsafeRoutingServiceServer interface {
|
||||
}
|
||||
|
||||
func RegisterRoutingServiceServer(s grpc.ServiceRegistrar, srv RoutingServiceServer) {
|
||||
// If the following call pancis, it indicates UnimplementedRoutingServiceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&RoutingService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
@@ -177,21 +180,11 @@ func _RoutingService_SubscribeRoutingStats_Handler(srv interface{}, stream grpc.
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
}
|
||||
return srv.(RoutingServiceServer).SubscribeRoutingStats(m, &routingServiceSubscribeRoutingStatsServer{stream})
|
||||
return srv.(RoutingServiceServer).SubscribeRoutingStats(m, &grpc.GenericServerStream[SubscribeRoutingStatsRequest, RoutingContext]{ServerStream: stream})
|
||||
}
|
||||
|
||||
type RoutingService_SubscribeRoutingStatsServer interface {
|
||||
Send(*RoutingContext) error
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
type routingServiceSubscribeRoutingStatsServer struct {
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
func (x *routingServiceSubscribeRoutingStatsServer) Send(m *RoutingContext) error {
|
||||
return x.ServerStream.SendMsg(m)
|
||||
}
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type RoutingService_SubscribeRoutingStatsServer = grpc.ServerStreamingServer[RoutingContext]
|
||||
|
||||
func _RoutingService_TestRoute_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(TestRouteRequest)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: app/router/config.proto
|
||||
|
||||
@@ -1275,7 +1275,7 @@ func file_app_router_config_proto_rawDescGZIP() []byte {
|
||||
|
||||
var file_app_router_config_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
|
||||
var file_app_router_config_proto_msgTypes = make([]protoimpl.MessageInfo, 13)
|
||||
var file_app_router_config_proto_goTypes = []interface{}{
|
||||
var file_app_router_config_proto_goTypes = []any{
|
||||
(Domain_Type)(0), // 0: xray.app.router.Domain.Type
|
||||
(Config_DomainStrategy)(0), // 1: xray.app.router.Config.DomainStrategy
|
||||
(*Domain)(nil), // 2: xray.app.router.Domain
|
||||
@@ -1333,7 +1333,7 @@ func file_app_router_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_app_router_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_router_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Domain); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1345,7 +1345,7 @@ func file_app_router_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_router_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_router_config_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*CIDR); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1357,7 +1357,7 @@ func file_app_router_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_router_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_router_config_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*GeoIP); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1369,7 +1369,7 @@ func file_app_router_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_router_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_router_config_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*GeoIPList); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1381,7 +1381,7 @@ func file_app_router_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_router_config_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_router_config_proto_msgTypes[4].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*GeoSite); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1393,7 +1393,7 @@ func file_app_router_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_router_config_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_router_config_proto_msgTypes[5].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*GeoSiteList); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1405,7 +1405,7 @@ func file_app_router_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_router_config_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_router_config_proto_msgTypes[6].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*RoutingRule); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1417,7 +1417,7 @@ func file_app_router_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_router_config_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_router_config_proto_msgTypes[7].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*BalancingRule); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1429,7 +1429,7 @@ func file_app_router_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_router_config_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_router_config_proto_msgTypes[8].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*StrategyWeight); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1441,7 +1441,7 @@ func file_app_router_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_router_config_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_router_config_proto_msgTypes[9].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*StrategyLeastLoadConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1453,7 +1453,7 @@ func file_app_router_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_router_config_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_router_config_proto_msgTypes[10].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1465,7 +1465,7 @@ func file_app_router_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_router_config_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_router_config_proto_msgTypes[11].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Domain_Attribute); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -1478,11 +1478,11 @@ func file_app_router_config_proto_init() {
|
||||
}
|
||||
}
|
||||
}
|
||||
file_app_router_config_proto_msgTypes[6].OneofWrappers = []interface{}{
|
||||
file_app_router_config_proto_msgTypes[6].OneofWrappers = []any{
|
||||
(*RoutingRule_Tag)(nil),
|
||||
(*RoutingRule_BalancingTag)(nil),
|
||||
}
|
||||
file_app_router_config_proto_msgTypes[11].OneofWrappers = []interface{}{
|
||||
file_app_router_config_proto_msgTypes[11].OneofWrappers = []any{
|
||||
(*Domain_Attribute_BoolValue)(nil),
|
||||
(*Domain_Attribute_IntValue)(nil),
|
||||
}
|
||||
|
@@ -203,7 +203,7 @@ func TestStatsChannelBlocking(t *testing.T) {
|
||||
|
||||
// Test blocking channel publishing
|
||||
go func() {
|
||||
// Dummy messsage with no subscriber receiving, will block broadcasting goroutine
|
||||
// Dummy message with no subscriber receiving, will block broadcasting goroutine
|
||||
c.Publish(context.Background(), nil)
|
||||
|
||||
<-pauseCh
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: app/stats/command/command.proto
|
||||
|
||||
@@ -565,7 +565,7 @@ func file_app_stats_command_command_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_app_stats_command_command_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
|
||||
var file_app_stats_command_command_proto_goTypes = []interface{}{
|
||||
var file_app_stats_command_command_proto_goTypes = []any{
|
||||
(*GetStatsRequest)(nil), // 0: xray.app.stats.command.GetStatsRequest
|
||||
(*Stat)(nil), // 1: xray.app.stats.command.Stat
|
||||
(*GetStatsResponse)(nil), // 2: xray.app.stats.command.GetStatsResponse
|
||||
@@ -597,7 +597,7 @@ func file_app_stats_command_command_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_app_stats_command_command_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_stats_command_command_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*GetStatsRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -609,7 +609,7 @@ func file_app_stats_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_stats_command_command_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_stats_command_command_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Stat); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -621,7 +621,7 @@ func file_app_stats_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_stats_command_command_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_stats_command_command_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*GetStatsResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -633,7 +633,7 @@ func file_app_stats_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_stats_command_command_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_stats_command_command_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*QueryStatsRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -645,7 +645,7 @@ func file_app_stats_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_stats_command_command_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_stats_command_command_proto_msgTypes[4].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*QueryStatsResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -657,7 +657,7 @@ func file_app_stats_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_stats_command_command_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_stats_command_command_proto_msgTypes[5].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*SysStatsRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -669,7 +669,7 @@ func file_app_stats_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_stats_command_command_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_stats_command_command_proto_msgTypes[6].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*SysStatsResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -681,7 +681,7 @@ func file_app_stats_command_command_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_stats_command_command_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_stats_command_command_proto_msgTypes[7].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.3.0
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc v5.27.0
|
||||
// source: app/stats/command/command.proto
|
||||
|
||||
@@ -15,8 +15,8 @@ import (
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
StatsService_GetStats_FullMethodName = "/xray.app.stats.command.StatsService/GetStats"
|
||||
@@ -42,8 +42,9 @@ func NewStatsServiceClient(cc grpc.ClientConnInterface) StatsServiceClient {
|
||||
}
|
||||
|
||||
func (c *statsServiceClient) GetStats(ctx context.Context, in *GetStatsRequest, opts ...grpc.CallOption) (*GetStatsResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetStatsResponse)
|
||||
err := c.cc.Invoke(ctx, StatsService_GetStats_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, StatsService_GetStats_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -51,8 +52,9 @@ func (c *statsServiceClient) GetStats(ctx context.Context, in *GetStatsRequest,
|
||||
}
|
||||
|
||||
func (c *statsServiceClient) QueryStats(ctx context.Context, in *QueryStatsRequest, opts ...grpc.CallOption) (*QueryStatsResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(QueryStatsResponse)
|
||||
err := c.cc.Invoke(ctx, StatsService_QueryStats_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, StatsService_QueryStats_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -60,8 +62,9 @@ func (c *statsServiceClient) QueryStats(ctx context.Context, in *QueryStatsReque
|
||||
}
|
||||
|
||||
func (c *statsServiceClient) GetSysStats(ctx context.Context, in *SysStatsRequest, opts ...grpc.CallOption) (*SysStatsResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(SysStatsResponse)
|
||||
err := c.cc.Invoke(ctx, StatsService_GetSysStats_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, StatsService_GetSysStats_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -70,7 +73,7 @@ func (c *statsServiceClient) GetSysStats(ctx context.Context, in *SysStatsReques
|
||||
|
||||
// StatsServiceServer is the server API for StatsService service.
|
||||
// All implementations must embed UnimplementedStatsServiceServer
|
||||
// for forward compatibility
|
||||
// for forward compatibility.
|
||||
type StatsServiceServer interface {
|
||||
GetStats(context.Context, *GetStatsRequest) (*GetStatsResponse, error)
|
||||
QueryStats(context.Context, *QueryStatsRequest) (*QueryStatsResponse, error)
|
||||
@@ -78,9 +81,12 @@ type StatsServiceServer interface {
|
||||
mustEmbedUnimplementedStatsServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedStatsServiceServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedStatsServiceServer struct {
|
||||
}
|
||||
// UnimplementedStatsServiceServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedStatsServiceServer struct{}
|
||||
|
||||
func (UnimplementedStatsServiceServer) GetStats(context.Context, *GetStatsRequest) (*GetStatsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetStats not implemented")
|
||||
@@ -92,6 +98,7 @@ func (UnimplementedStatsServiceServer) GetSysStats(context.Context, *SysStatsReq
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetSysStats not implemented")
|
||||
}
|
||||
func (UnimplementedStatsServiceServer) mustEmbedUnimplementedStatsServiceServer() {}
|
||||
func (UnimplementedStatsServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeStatsServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to StatsServiceServer will
|
||||
@@ -101,6 +108,13 @@ type UnsafeStatsServiceServer interface {
|
||||
}
|
||||
|
||||
func RegisterStatsServiceServer(s grpc.ServiceRegistrar, srv StatsServiceServer) {
|
||||
// If the following call pancis, it indicates UnimplementedStatsServiceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&StatsService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: app/stats/config.proto
|
||||
|
||||
@@ -155,7 +155,7 @@ func file_app_stats_config_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_app_stats_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_app_stats_config_proto_goTypes = []interface{}{
|
||||
var file_app_stats_config_proto_goTypes = []any{
|
||||
(*Config)(nil), // 0: xray.app.stats.Config
|
||||
(*ChannelConfig)(nil), // 1: xray.app.stats.ChannelConfig
|
||||
}
|
||||
@@ -173,7 +173,7 @@ func file_app_stats_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_app_stats_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_stats_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -185,7 +185,7 @@ func file_app_stats_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_app_stats_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_stats_config_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ChannelConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -31,6 +31,8 @@ type AccessMessage struct {
|
||||
|
||||
func (m *AccessMessage) String() string {
|
||||
builder := strings.Builder{}
|
||||
builder.WriteString("from")
|
||||
builder.WriteByte(' ')
|
||||
builder.WriteString(serial.ToString(m.From))
|
||||
builder.WriteByte(' ')
|
||||
builder.WriteString(string(m.Status))
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: common/log/log.proto
|
||||
|
||||
@@ -106,7 +106,7 @@ func file_common_log_log_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_common_log_log_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_common_log_log_proto_goTypes = []interface{}{
|
||||
var file_common_log_log_proto_goTypes = []any{
|
||||
(Severity)(0), // 0: xray.common.log.Severity
|
||||
}
|
||||
var file_common_log_log_proto_depIdxs = []int32{
|
||||
|
@@ -22,7 +22,7 @@ import (
|
||||
)
|
||||
|
||||
type ClientManager struct {
|
||||
Enabled bool // wheather mux is enabled from user config
|
||||
Enabled bool // whether mux is enabled from user config
|
||||
Picker WorkerPicker
|
||||
}
|
||||
|
||||
|
@@ -118,6 +118,9 @@ func (w *ServerWorker) handleStatusKeepAlive(meta *FrameMetadata, reader *buf.Bu
|
||||
}
|
||||
|
||||
func (w *ServerWorker) handleStatusNew(ctx context.Context, meta *FrameMetadata, reader *buf.BufferedReader) error {
|
||||
// deep-clone outbounds because it is going to be mutated concurrently
|
||||
// (Target and OriginalTarget)
|
||||
ctx = session.ContextCloneOutbounds(ctx)
|
||||
errors.LogInfo(ctx, "received request for ", meta.Target)
|
||||
{
|
||||
msg := &log.AccessMessage{
|
||||
@@ -170,7 +173,7 @@ func (w *ServerWorker) handleStatusNew(ctx context.Context, meta *FrameMetadata,
|
||||
b.Release()
|
||||
mb = nil
|
||||
}
|
||||
errors.LogInfoInner(ctx, err,"XUDP hit ", meta.GlobalID)
|
||||
errors.LogInfoInner(ctx, err, "XUDP hit ", meta.GlobalID)
|
||||
}
|
||||
if mb != nil {
|
||||
ctx = session.ContextWithTimeoutOnly(ctx, true)
|
||||
|
124
common/mux/server_test.go
Normal file
124
common/mux/server_test.go
Normal file
@@ -0,0 +1,124 @@
|
||||
package mux_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/xtls/xray-core/common"
|
||||
"github.com/xtls/xray-core/common/buf"
|
||||
"github.com/xtls/xray-core/common/mux"
|
||||
"github.com/xtls/xray-core/common/net"
|
||||
"github.com/xtls/xray-core/common/session"
|
||||
"github.com/xtls/xray-core/features/routing"
|
||||
"github.com/xtls/xray-core/transport"
|
||||
"github.com/xtls/xray-core/transport/pipe"
|
||||
)
|
||||
|
||||
func newLinkPair() (*transport.Link, *transport.Link) {
|
||||
opt := pipe.WithoutSizeLimit()
|
||||
uplinkReader, uplinkWriter := pipe.New(opt)
|
||||
downlinkReader, downlinkWriter := pipe.New(opt)
|
||||
|
||||
uplink := &transport.Link{
|
||||
Reader: uplinkReader,
|
||||
Writer: downlinkWriter,
|
||||
}
|
||||
|
||||
downlink := &transport.Link{
|
||||
Reader: downlinkReader,
|
||||
Writer: uplinkWriter,
|
||||
}
|
||||
|
||||
return uplink, downlink
|
||||
}
|
||||
|
||||
type TestDispatcher struct {
|
||||
OnDispatch func(ctx context.Context, dest net.Destination) (*transport.Link, error)
|
||||
}
|
||||
|
||||
func (d *TestDispatcher) Dispatch(ctx context.Context, dest net.Destination) (*transport.Link, error) {
|
||||
return d.OnDispatch(ctx, dest)
|
||||
}
|
||||
|
||||
func (d *TestDispatcher) DispatchLink(ctx context.Context, destination net.Destination, outbound *transport.Link) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *TestDispatcher) Start() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *TestDispatcher) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*TestDispatcher) Type() interface{} {
|
||||
return routing.DispatcherType()
|
||||
}
|
||||
|
||||
func TestRegressionOutboundLeak(t *testing.T) {
|
||||
originalOutbounds := []*session.Outbound{{}}
|
||||
serverCtx := session.ContextWithOutbounds(context.Background(), originalOutbounds)
|
||||
|
||||
websiteUplink, websiteDownlink := newLinkPair()
|
||||
|
||||
dispatcher := TestDispatcher{
|
||||
OnDispatch: func(ctx context.Context, dest net.Destination) (*transport.Link, error) {
|
||||
// emulate what DefaultRouter.Dispatch does, and mutate something on the context
|
||||
ob := session.OutboundsFromContext(ctx)[0]
|
||||
ob.Target = dest
|
||||
return websiteDownlink, nil
|
||||
},
|
||||
}
|
||||
|
||||
muxServerUplink, muxServerDownlink := newLinkPair()
|
||||
_, err := mux.NewServerWorker(serverCtx, &dispatcher, muxServerUplink)
|
||||
common.Must(err)
|
||||
|
||||
client, err := mux.NewClientWorker(*muxServerDownlink, mux.ClientStrategy{})
|
||||
common.Must(err)
|
||||
|
||||
clientCtx := session.ContextWithOutbounds(context.Background(), []*session.Outbound{{
|
||||
Target: net.TCPDestination(net.DomainAddress("www.example.com"), 80),
|
||||
}})
|
||||
|
||||
muxClientUplink, muxClientDownlink := newLinkPair()
|
||||
|
||||
ok := client.Dispatch(clientCtx, muxClientUplink)
|
||||
if !ok {
|
||||
t.Error("failed to dispatch")
|
||||
}
|
||||
|
||||
{
|
||||
b := buf.FromBytes([]byte("hello"))
|
||||
common.Must(muxClientDownlink.Writer.WriteMultiBuffer(buf.MultiBuffer{b}))
|
||||
}
|
||||
|
||||
resMb, err := websiteUplink.Reader.ReadMultiBuffer()
|
||||
common.Must(err)
|
||||
res := resMb.String()
|
||||
if res != "hello" {
|
||||
t.Error("upload: ", res)
|
||||
}
|
||||
|
||||
{
|
||||
b := buf.FromBytes([]byte("world"))
|
||||
common.Must(websiteUplink.Writer.WriteMultiBuffer(buf.MultiBuffer{b}))
|
||||
}
|
||||
|
||||
resMb, err = muxClientDownlink.Reader.ReadMultiBuffer()
|
||||
common.Must(err)
|
||||
res = resMb.String()
|
||||
if res != "world" {
|
||||
t.Error("download: ", res)
|
||||
}
|
||||
|
||||
outbounds := session.OutboundsFromContext(serverCtx)
|
||||
if outbounds[0] != originalOutbounds[0] {
|
||||
t.Error("outbound got reassigned: ", outbounds[0])
|
||||
}
|
||||
|
||||
if outbounds[0].Target.Address != nil {
|
||||
t.Error("outbound target got leaked: ", outbounds[0].Target.String())
|
||||
}
|
||||
}
|
@@ -121,6 +121,11 @@ func IPAddress(ip []byte) Address {
|
||||
}
|
||||
|
||||
// DomainAddress creates an Address with given domain.
|
||||
// This is an internal function that forcibly converts a string to domain.
|
||||
// It's mainly used in test files and mux.
|
||||
// Unless you have a specific reason, use net.ParseAddress instead,
|
||||
// as this function does not check whether the input is an IP address.
|
||||
// Otherwise, you will get strange results like domain: 1.1.1.1
|
||||
func DomainAddress(domain string) Address {
|
||||
return domainAddress(domain)
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: common/net/address.proto
|
||||
|
||||
@@ -136,7 +136,7 @@ func file_common_net_address_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_common_net_address_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_common_net_address_proto_goTypes = []interface{}{
|
||||
var file_common_net_address_proto_goTypes = []any{
|
||||
(*IPOrDomain)(nil), // 0: xray.common.net.IPOrDomain
|
||||
}
|
||||
var file_common_net_address_proto_depIdxs = []int32{
|
||||
@@ -153,7 +153,7 @@ func file_common_net_address_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_common_net_address_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_common_net_address_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*IPOrDomain); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -166,7 +166,7 @@ func file_common_net_address_proto_init() {
|
||||
}
|
||||
}
|
||||
}
|
||||
file_common_net_address_proto_msgTypes[0].OneofWrappers = []interface{}{
|
||||
file_common_net_address_proto_msgTypes[0].OneofWrappers = []any{
|
||||
(*IPOrDomain_Ip)(nil),
|
||||
(*IPOrDomain_Domain)(nil),
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: common/net/destination.proto
|
||||
|
||||
@@ -123,7 +123,7 @@ func file_common_net_destination_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_common_net_destination_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_common_net_destination_proto_goTypes = []interface{}{
|
||||
var file_common_net_destination_proto_goTypes = []any{
|
||||
(*Endpoint)(nil), // 0: xray.common.net.Endpoint
|
||||
(Network)(0), // 1: xray.common.net.Network
|
||||
(*IPOrDomain)(nil), // 2: xray.common.net.IPOrDomain
|
||||
@@ -146,7 +146,7 @@ func file_common_net_destination_proto_init() {
|
||||
file_common_net_network_proto_init()
|
||||
file_common_net_address_proto_init()
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_common_net_destination_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_common_net_destination_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Endpoint); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: common/net/network.proto
|
||||
|
||||
@@ -160,7 +160,7 @@ func file_common_net_network_proto_rawDescGZIP() []byte {
|
||||
|
||||
var file_common_net_network_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_common_net_network_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_common_net_network_proto_goTypes = []interface{}{
|
||||
var file_common_net_network_proto_goTypes = []any{
|
||||
(Network)(0), // 0: xray.common.net.Network
|
||||
(*NetworkList)(nil), // 1: xray.common.net.NetworkList
|
||||
}
|
||||
@@ -179,7 +179,7 @@ func file_common_net_network_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_common_net_network_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_common_net_network_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*NetworkList); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: common/net/port.proto
|
||||
|
||||
@@ -159,7 +159,7 @@ func file_common_net_port_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_common_net_port_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_common_net_port_proto_goTypes = []interface{}{
|
||||
var file_common_net_port_proto_goTypes = []any{
|
||||
(*PortRange)(nil), // 0: xray.common.net.PortRange
|
||||
(*PortList)(nil), // 1: xray.common.net.PortList
|
||||
}
|
||||
@@ -178,7 +178,7 @@ func file_common_net_port_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_common_net_port_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_common_net_port_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*PortRange); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -190,7 +190,7 @@ func file_common_net_port_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_common_net_port_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_common_net_port_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*PortList); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: common/protocol/headers.proto
|
||||
|
||||
@@ -165,7 +165,7 @@ func file_common_protocol_headers_proto_rawDescGZIP() []byte {
|
||||
|
||||
var file_common_protocol_headers_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_common_protocol_headers_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_common_protocol_headers_proto_goTypes = []interface{}{
|
||||
var file_common_protocol_headers_proto_goTypes = []any{
|
||||
(SecurityType)(0), // 0: xray.common.protocol.SecurityType
|
||||
(*SecurityConfig)(nil), // 1: xray.common.protocol.SecurityConfig
|
||||
}
|
||||
@@ -184,7 +184,7 @@ func file_common_protocol_headers_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_common_protocol_headers_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_common_protocol_headers_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*SecurityConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: common/protocol/server_spec.proto
|
||||
|
||||
@@ -125,7 +125,7 @@ func file_common_protocol_server_spec_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_common_protocol_server_spec_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_common_protocol_server_spec_proto_goTypes = []interface{}{
|
||||
var file_common_protocol_server_spec_proto_goTypes = []any{
|
||||
(*ServerEndpoint)(nil), // 0: xray.common.protocol.ServerEndpoint
|
||||
(*net.IPOrDomain)(nil), // 1: xray.common.net.IPOrDomain
|
||||
(*User)(nil), // 2: xray.common.protocol.User
|
||||
@@ -147,7 +147,7 @@ func file_common_protocol_server_spec_proto_init() {
|
||||
}
|
||||
file_common_protocol_user_proto_init()
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_common_protocol_server_spec_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_common_protocol_server_spec_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ServerEndpoint); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: common/protocol/user.proto
|
||||
|
||||
@@ -124,7 +124,7 @@ func file_common_protocol_user_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_common_protocol_user_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_common_protocol_user_proto_goTypes = []interface{}{
|
||||
var file_common_protocol_user_proto_goTypes = []any{
|
||||
(*User)(nil), // 0: xray.common.protocol.User
|
||||
(*serial.TypedMessage)(nil), // 1: xray.common.serial.TypedMessage
|
||||
}
|
||||
@@ -143,7 +143,7 @@ func file_common_protocol_user_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_common_protocol_user_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_common_protocol_user_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*User); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,22 +1,36 @@
|
||||
package reflect
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
cnet "github.com/xtls/xray-core/common/net"
|
||||
cserial "github.com/xtls/xray-core/common/serial"
|
||||
"github.com/xtls/xray-core/infra/conf"
|
||||
)
|
||||
|
||||
func MarshalToJson(v interface{}) (string, bool) {
|
||||
if itf := marshalInterface(v, true); itf != nil {
|
||||
if b, err := json.MarshalIndent(itf, "", " "); err == nil {
|
||||
func MarshalToJson(v interface{}, insertTypeInfo bool) (string, bool) {
|
||||
if itf := marshalInterface(v, true, insertTypeInfo); itf != nil {
|
||||
if b, err := JSONMarshalWithoutEscape(itf); err == nil {
|
||||
return string(b[:]), true
|
||||
}
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
|
||||
func marshalTypedMessage(v *cserial.TypedMessage, ignoreNullValue bool) interface{} {
|
||||
func JSONMarshalWithoutEscape(t interface{}) ([]byte, error) {
|
||||
buffer := &bytes.Buffer{}
|
||||
encoder := json.NewEncoder(buffer)
|
||||
encoder.SetIndent("", " ")
|
||||
encoder.SetEscapeHTML(false)
|
||||
err := encoder.Encode(t)
|
||||
return buffer.Bytes(), err
|
||||
}
|
||||
|
||||
func marshalTypedMessage(v *cserial.TypedMessage, ignoreNullValue bool, insertTypeInfo bool) interface{} {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -24,36 +38,67 @@ func marshalTypedMessage(v *cserial.TypedMessage, ignoreNullValue bool) interfac
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
r := marshalInterface(tmsg, ignoreNullValue)
|
||||
if msg, ok := r.(map[string]interface{}); ok {
|
||||
r := marshalInterface(tmsg, ignoreNullValue, insertTypeInfo)
|
||||
if msg, ok := r.(map[string]interface{}); ok && insertTypeInfo {
|
||||
msg["_TypedMessage_"] = v.Type
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func marshalSlice(v reflect.Value, ignoreNullValue bool) interface{} {
|
||||
func marshalSlice(v reflect.Value, ignoreNullValue bool, insertTypeInfo bool) interface{} {
|
||||
r := make([]interface{}, 0)
|
||||
for i := 0; i < v.Len(); i++ {
|
||||
rv := v.Index(i)
|
||||
if rv.CanInterface() {
|
||||
value := rv.Interface()
|
||||
r = append(r, marshalInterface(value, ignoreNullValue))
|
||||
r = append(r, marshalInterface(value, ignoreNullValue, insertTypeInfo))
|
||||
}
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func marshalStruct(v reflect.Value, ignoreNullValue bool) interface{} {
|
||||
func isNullValue(f reflect.StructField, rv reflect.Value) bool {
|
||||
if rv.Kind() == reflect.String && rv.Len() == 0 {
|
||||
return true
|
||||
} else if !isValueKind(rv.Kind()) && rv.IsNil() {
|
||||
return true
|
||||
} else if tag := f.Tag.Get("json"); strings.Contains(tag, "omitempty") {
|
||||
if !rv.IsValid() || rv.IsZero() {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func toJsonName(f reflect.StructField) string {
|
||||
if tags := f.Tag.Get("protobuf"); len(tags) > 0 {
|
||||
for _, tag := range strings.Split(tags, ",") {
|
||||
if before, after, ok := strings.Cut(tag, "="); ok && before == "json" {
|
||||
return after
|
||||
}
|
||||
}
|
||||
}
|
||||
if tag := f.Tag.Get("json"); len(tag) > 0 {
|
||||
if before, _, ok := strings.Cut(tag, ","); ok {
|
||||
return before
|
||||
} else {
|
||||
return tag
|
||||
}
|
||||
}
|
||||
return f.Name
|
||||
}
|
||||
|
||||
func marshalStruct(v reflect.Value, ignoreNullValue bool, insertTypeInfo bool) interface{} {
|
||||
r := make(map[string]interface{})
|
||||
t := v.Type()
|
||||
for i := 0; i < v.NumField(); i++ {
|
||||
rv := v.Field(i)
|
||||
if rv.CanInterface() {
|
||||
ft := t.Field(i)
|
||||
name := ft.Name
|
||||
value := rv.Interface()
|
||||
tv := marshalInterface(value, ignoreNullValue)
|
||||
if tv != nil || !ignoreNullValue {
|
||||
if !ignoreNullValue || !isNullValue(ft, rv) {
|
||||
name := toJsonName(ft)
|
||||
value := rv.Interface()
|
||||
tv := marshalInterface(value, ignoreNullValue, insertTypeInfo)
|
||||
r[name] = tv
|
||||
}
|
||||
}
|
||||
@@ -61,7 +106,7 @@ func marshalStruct(v reflect.Value, ignoreNullValue bool) interface{} {
|
||||
return r
|
||||
}
|
||||
|
||||
func marshalMap(v reflect.Value, ignoreNullValue bool) interface{} {
|
||||
func marshalMap(v reflect.Value, ignoreNullValue bool, insertTypeInfo bool) interface{} {
|
||||
// policy.level is map[uint32] *struct
|
||||
kt := v.Type().Key()
|
||||
vt := reflect.TypeOf((*interface{})(nil))
|
||||
@@ -71,7 +116,7 @@ func marshalMap(v reflect.Value, ignoreNullValue bool) interface{} {
|
||||
rv := v.MapIndex(key)
|
||||
if rv.CanInterface() {
|
||||
iv := rv.Interface()
|
||||
tv := marshalInterface(iv, ignoreNullValue)
|
||||
tv := marshalInterface(iv, ignoreNullValue, insertTypeInfo)
|
||||
if tv != nil || !ignoreNullValue {
|
||||
r.SetMapIndex(key, reflect.ValueOf(&tv))
|
||||
}
|
||||
@@ -87,27 +132,63 @@ func marshalIString(v interface{}) (r string, ok bool) {
|
||||
ok = false
|
||||
}
|
||||
}()
|
||||
|
||||
if iStringFn, ok := v.(interface{ String() string }); ok {
|
||||
return iStringFn.String(), true
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
|
||||
func marshalKnownType(v interface{}, ignoreNullValue bool) (interface{}, bool) {
|
||||
func serializePortList(portList *cnet.PortList) (interface{}, bool) {
|
||||
if portList == nil {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
n := len(portList.Range)
|
||||
if n == 1 {
|
||||
if first := portList.Range[0]; first.From == first.To {
|
||||
return first.From, true
|
||||
}
|
||||
}
|
||||
|
||||
r := make([]string, 0, n)
|
||||
for _, pr := range portList.Range {
|
||||
if pr.From == pr.To {
|
||||
r = append(r, pr.FromPort().String())
|
||||
} else {
|
||||
r = append(r, fmt.Sprintf("%d-%d", pr.From, pr.To))
|
||||
}
|
||||
}
|
||||
return strings.Join(r, ","), true
|
||||
}
|
||||
|
||||
func marshalKnownType(v interface{}, ignoreNullValue bool, insertTypeInfo bool) (interface{}, bool) {
|
||||
switch ty := v.(type) {
|
||||
case cserial.TypedMessage:
|
||||
return marshalTypedMessage(&ty, ignoreNullValue), true
|
||||
return marshalTypedMessage(&ty, ignoreNullValue, insertTypeInfo), true
|
||||
case *cserial.TypedMessage:
|
||||
return marshalTypedMessage(ty, ignoreNullValue), true
|
||||
return marshalTypedMessage(ty, ignoreNullValue, insertTypeInfo), true
|
||||
case map[string]json.RawMessage:
|
||||
return ty, true
|
||||
case []json.RawMessage:
|
||||
return ty, true
|
||||
case *json.RawMessage:
|
||||
return ty, true
|
||||
case json.RawMessage:
|
||||
case *json.RawMessage, json.RawMessage:
|
||||
return ty, true
|
||||
case *cnet.IPOrDomain:
|
||||
if domain := v.(*cnet.IPOrDomain); domain != nil {
|
||||
return domain.AsAddress().String(), true
|
||||
}
|
||||
return nil, false
|
||||
case *cnet.PortList:
|
||||
npl := v.(*cnet.PortList)
|
||||
return serializePortList(npl)
|
||||
case *conf.PortList:
|
||||
cpl := v.(*conf.PortList)
|
||||
return serializePortList(cpl.Build())
|
||||
case cnet.Address:
|
||||
if addr := v.(cnet.Address); addr != nil {
|
||||
return addr.String(), true
|
||||
}
|
||||
return nil, false
|
||||
default:
|
||||
return nil, false
|
||||
}
|
||||
@@ -138,9 +219,9 @@ func isValueKind(kind reflect.Kind) bool {
|
||||
}
|
||||
}
|
||||
|
||||
func marshalInterface(v interface{}, ignoreNullValue bool) interface{} {
|
||||
func marshalInterface(v interface{}, ignoreNullValue bool, insertTypeInfo bool) interface{} {
|
||||
|
||||
if r, ok := marshalKnownType(v, ignoreNullValue); ok {
|
||||
if r, ok := marshalKnownType(v, ignoreNullValue, insertTypeInfo); ok {
|
||||
return r
|
||||
}
|
||||
|
||||
@@ -152,19 +233,27 @@ func marshalInterface(v interface{}, ignoreNullValue bool) interface{} {
|
||||
if k == reflect.Invalid {
|
||||
return nil
|
||||
}
|
||||
if isValueKind(k) {
|
||||
|
||||
if ty := rv.Type().Name(); isValueKind(k) {
|
||||
if k.String() != ty {
|
||||
if s, ok := marshalIString(v); ok {
|
||||
return s
|
||||
}
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// fmt.Println("kind:", k, "type:", rv.Type().Name())
|
||||
|
||||
switch k {
|
||||
case reflect.Struct:
|
||||
return marshalStruct(rv, ignoreNullValue)
|
||||
return marshalStruct(rv, ignoreNullValue, insertTypeInfo)
|
||||
case reflect.Slice:
|
||||
return marshalSlice(rv, ignoreNullValue)
|
||||
return marshalSlice(rv, ignoreNullValue, insertTypeInfo)
|
||||
case reflect.Array:
|
||||
return marshalSlice(rv, ignoreNullValue)
|
||||
return marshalSlice(rv, ignoreNullValue, insertTypeInfo)
|
||||
case reflect.Map:
|
||||
return marshalMap(rv, ignoreNullValue)
|
||||
return marshalMap(rv, ignoreNullValue, insertTypeInfo)
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
@@ -6,11 +6,40 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/xtls/xray-core/common/protocol"
|
||||
. "github.com/xtls/xray-core/common/reflect"
|
||||
cserial "github.com/xtls/xray-core/common/serial"
|
||||
iserial "github.com/xtls/xray-core/infra/conf/serial"
|
||||
"github.com/xtls/xray-core/proxy/shadowsocks"
|
||||
)
|
||||
|
||||
func TestMashalAccount(t *testing.T) {
|
||||
account := &shadowsocks.Account{
|
||||
Password: "shadowsocks-password",
|
||||
CipherType: shadowsocks.CipherType_CHACHA20_POLY1305,
|
||||
}
|
||||
|
||||
user := &protocol.User{
|
||||
Level: 0,
|
||||
Email: "love@v2ray.com",
|
||||
Account: cserial.ToTypedMessage(account),
|
||||
}
|
||||
|
||||
j, ok := MarshalToJson(user, false)
|
||||
if !ok || strings.Contains(j, "_TypedMessage_") {
|
||||
|
||||
t.Error("marshal account failed")
|
||||
}
|
||||
|
||||
kws := []string{"CHACHA20_POLY1305", "cipherType", "shadowsocks-password"}
|
||||
for _, kw := range kws {
|
||||
if !strings.Contains(j, kw) {
|
||||
t.Error("marshal account failed")
|
||||
}
|
||||
}
|
||||
// t.Log(j)
|
||||
}
|
||||
|
||||
func TestMashalStruct(t *testing.T) {
|
||||
type Foo = struct {
|
||||
N int `json:"n"`
|
||||
@@ -36,8 +65,8 @@ func TestMashalStruct(t *testing.T) {
|
||||
Arr: &arr,
|
||||
}
|
||||
|
||||
s, ok1 := MarshalToJson(f1)
|
||||
sp, ok2 := MarshalToJson(&f1)
|
||||
s, ok1 := MarshalToJson(f1, true)
|
||||
sp, ok2 := MarshalToJson(&f1, true)
|
||||
|
||||
if !ok1 || !ok2 || s != sp {
|
||||
t.Error("marshal failed")
|
||||
@@ -69,7 +98,7 @@ func TestMarshalConfigJson(t *testing.T) {
|
||||
}
|
||||
|
||||
tmsg := cserial.ToTypedMessage(bc)
|
||||
tc, ok := MarshalToJson(tmsg)
|
||||
tc, ok := MarshalToJson(tmsg, true)
|
||||
if !ok {
|
||||
t.Error("marshal config failed")
|
||||
}
|
||||
@@ -79,15 +108,14 @@ func TestMarshalConfigJson(t *testing.T) {
|
||||
keywords := []string{
|
||||
"4784f9b8-a879-4fec-9718-ebddefa47750",
|
||||
"bing.com",
|
||||
"DomainStrategy",
|
||||
"InboundTag",
|
||||
"Level",
|
||||
"Stats",
|
||||
"UserDownlink",
|
||||
"UserUplink",
|
||||
"System",
|
||||
"InboundDownlink",
|
||||
"OutboundUplink",
|
||||
"inboundTag",
|
||||
"level",
|
||||
"stats",
|
||||
"userDownlink",
|
||||
"userUplink",
|
||||
"system",
|
||||
"inboundDownlink",
|
||||
"outboundUplink",
|
||||
}
|
||||
for _, kw := range keywords {
|
||||
if !strings.Contains(tc, kw) {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: common/serial/typed_message.proto
|
||||
|
||||
@@ -110,7 +110,7 @@ func file_common_serial_typed_message_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_common_serial_typed_message_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_common_serial_typed_message_proto_goTypes = []interface{}{
|
||||
var file_common_serial_typed_message_proto_goTypes = []any{
|
||||
(*TypedMessage)(nil), // 0: xray.common.serial.TypedMessage
|
||||
}
|
||||
var file_common_serial_typed_message_proto_depIdxs = []int32{
|
||||
@@ -127,7 +127,7 @@ func file_common_serial_typed_message_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_common_serial_typed_message_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_common_serial_typed_message_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*TypedMessage); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -40,6 +40,22 @@ func ContextWithOutbounds(ctx context.Context, outbounds []*Outbound) context.Co
|
||||
return context.WithValue(ctx, outboundSessionKey, outbounds)
|
||||
}
|
||||
|
||||
func ContextCloneOutbounds(ctx context.Context) context.Context {
|
||||
outbounds := OutboundsFromContext(ctx)
|
||||
newOutbounds := make([]*Outbound, len(outbounds))
|
||||
for i, ob := range outbounds {
|
||||
if ob == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
// copy outbound by value
|
||||
v := *ob
|
||||
newOutbounds[i] = &v
|
||||
}
|
||||
|
||||
return ContextWithOutbounds(ctx, newOutbounds)
|
||||
}
|
||||
|
||||
func OutboundsFromContext(ctx context.Context) []*Outbound {
|
||||
if outbounds, ok := ctx.Value(outboundSessionKey).([]*Outbound); ok {
|
||||
return outbounds
|
||||
|
@@ -19,14 +19,19 @@ type ConfigFormat struct {
|
||||
Loader ConfigLoader
|
||||
}
|
||||
|
||||
type ConfigSource struct {
|
||||
Name string
|
||||
Format string
|
||||
}
|
||||
|
||||
// ConfigLoader is a utility to load Xray config from external source.
|
||||
type ConfigLoader func(input interface{}) (*Config, error)
|
||||
|
||||
// ConfigBuilder is a builder to build core.Config from filenames and formats
|
||||
type ConfigBuilder func(files []string, formats []string) (*Config, error)
|
||||
type ConfigBuilder func(files []*ConfigSource) (*Config, error)
|
||||
|
||||
// ConfigsMerger merge multiple json configs into on config
|
||||
type ConfigsMerger func(files []string, formats []string) (string, error)
|
||||
type ConfigsMerger func(files []*ConfigSource) (string, error)
|
||||
|
||||
var (
|
||||
configLoaderByName = make(map[string]*ConfigFormat)
|
||||
@@ -55,20 +60,21 @@ func RegisterConfigLoader(format *ConfigFormat) error {
|
||||
}
|
||||
|
||||
func GetMergedConfig(args cmdarg.Arg) (string, error) {
|
||||
files := make([]string, 0)
|
||||
formats := make([]string, 0)
|
||||
var files []*ConfigSource
|
||||
supported := []string{"json", "yaml", "toml"}
|
||||
for _, file := range args {
|
||||
format := getFormat(file)
|
||||
for _, s := range supported {
|
||||
if s == format {
|
||||
files = append(files, file)
|
||||
formats = append(formats, format)
|
||||
files = append(files, &ConfigSource{
|
||||
Name: file,
|
||||
Format: format,
|
||||
})
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return ConfigMergedFormFiles(files, formats)
|
||||
return ConfigMergedFormFiles(files)
|
||||
}
|
||||
|
||||
func GetFormatByExtension(ext string) string {
|
||||
@@ -101,7 +107,7 @@ func getFormat(filename string) string {
|
||||
func LoadConfig(formatName string, input interface{}) (*Config, error) {
|
||||
switch v := input.(type) {
|
||||
case cmdarg.Arg:
|
||||
formats := make([]string, len(v))
|
||||
files := make([]*ConfigSource, len(v))
|
||||
hasProtobuf := false
|
||||
for i, file := range v {
|
||||
var f string
|
||||
@@ -123,7 +129,10 @@ func LoadConfig(formatName string, input interface{}) (*Config, error) {
|
||||
if f == "protobuf" {
|
||||
hasProtobuf = true
|
||||
}
|
||||
formats[i] = f
|
||||
files[i] = &ConfigSource{
|
||||
Name: file,
|
||||
Format: f,
|
||||
}
|
||||
}
|
||||
|
||||
// only one protobuf config file is allowed
|
||||
@@ -136,8 +145,7 @@ func LoadConfig(formatName string, input interface{}) (*Config, error) {
|
||||
}
|
||||
|
||||
// to avoid import cycle
|
||||
return ConfigBuilderForFiles(v, formats)
|
||||
|
||||
return ConfigBuilderForFiles(files)
|
||||
case io.Reader:
|
||||
if f, found := configLoaderByName[formatName]; found {
|
||||
return f.Loader(v)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: core/config.proto
|
||||
|
||||
@@ -347,7 +347,7 @@ func file_core_config_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_core_config_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_core_config_proto_goTypes = []interface{}{
|
||||
var file_core_config_proto_goTypes = []any{
|
||||
(*Config)(nil), // 0: xray.core.Config
|
||||
(*InboundHandlerConfig)(nil), // 1: xray.core.InboundHandlerConfig
|
||||
(*OutboundHandlerConfig)(nil), // 2: xray.core.OutboundHandlerConfig
|
||||
@@ -377,7 +377,7 @@ func file_core_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_core_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_core_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -389,7 +389,7 @@ func file_core_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_core_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_core_config_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*InboundHandlerConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -401,7 +401,7 @@ func file_core_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_core_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_core_config_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*OutboundHandlerConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -21,7 +21,7 @@ import (
|
||||
var (
|
||||
Version_x byte = 1
|
||||
Version_y byte = 8
|
||||
Version_z byte = 23
|
||||
Version_z byte = 24
|
||||
)
|
||||
|
||||
var (
|
||||
|
@@ -1,5 +1,5 @@
|
||||
package core
|
||||
|
||||
//go:generate go install -v google.golang.org/protobuf/cmd/protoc-gen-go@latest
|
||||
//go:generate go install -v google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
|
||||
//go:generate go install -v google.golang.org/protobuf/cmd/protoc-gen-go@v1.34.2
|
||||
//go:generate go install -v google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.5.1
|
||||
//go:generate go run ../infra/vprotogen/main.go -pwd ./..
|
||||
|
22
go.mod
22
go.mod
@@ -4,30 +4,30 @@ go 1.21.4
|
||||
|
||||
require (
|
||||
github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0
|
||||
github.com/cloudflare/circl v1.3.9
|
||||
github.com/cloudflare/circl v1.4.0
|
||||
github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344
|
||||
github.com/golang/mock v1.7.0-rc.1
|
||||
github.com/google/go-cmp v0.6.0
|
||||
github.com/gorilla/websocket v1.5.3
|
||||
github.com/miekg/dns v1.1.61
|
||||
github.com/miekg/dns v1.1.62
|
||||
github.com/pelletier/go-toml v1.9.5
|
||||
github.com/pires/go-proxyproto v0.7.0
|
||||
github.com/quic-go/quic-go v0.45.1
|
||||
github.com/quic-go/quic-go v0.46.0
|
||||
github.com/refraction-networking/utls v1.6.7
|
||||
github.com/sagernet/sing v0.4.1
|
||||
github.com/sagernet/sing-shadowsocks v0.2.7
|
||||
github.com/seiflotfy/cuckoofilter v0.0.0-20240715131351-a2f2c23f1771
|
||||
github.com/stretchr/testify v1.9.0
|
||||
github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e
|
||||
github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3
|
||||
github.com/vishvananda/netlink v1.3.0
|
||||
github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d
|
||||
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba
|
||||
golang.org/x/crypto v0.25.0
|
||||
golang.org/x/net v0.27.0
|
||||
golang.org/x/sync v0.7.0
|
||||
golang.org/x/sys v0.22.0
|
||||
golang.org/x/crypto v0.26.0
|
||||
golang.org/x/net v0.28.0
|
||||
golang.org/x/sync v0.8.0
|
||||
golang.org/x/sys v0.24.0
|
||||
golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173
|
||||
google.golang.org/grpc v1.65.0
|
||||
google.golang.org/grpc v1.66.0
|
||||
google.golang.org/protobuf v1.34.2
|
||||
gvisor.dev/gvisor v0.0.0-20231202080848-1f7806d17489
|
||||
h12.io/socks v1.0.3
|
||||
@@ -52,11 +52,11 @@ require (
|
||||
go.uber.org/mock v0.4.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
|
||||
golang.org/x/mod v0.18.0 // indirect
|
||||
golang.org/x/text v0.16.0 // indirect
|
||||
golang.org/x/text v0.17.0 // indirect
|
||||
golang.org/x/time v0.5.0 // indirect
|
||||
golang.org/x/tools v0.22.0 // indirect
|
||||
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
49
go.sum
49
go.sum
@@ -17,8 +17,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
|
||||
github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g=
|
||||
github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cloudflare/circl v1.3.9 h1:QFrlgFYf2Qpi8bSpVPK1HBvWpx16v/1TZivyo7pGuBE=
|
||||
github.com/cloudflare/circl v1.3.9/go.mod h1:PDRU+oXvdD7KCtgKxW95M5Z8BpSCJXQORiZFnBQS5QU=
|
||||
github.com/cloudflare/circl v1.4.0 h1:BV7h5MgrktNzytKmWjpOtdYrf0lkkbF8YMlBGPhJQrY=
|
||||
github.com/cloudflare/circl v1.4.0/go.mod h1:PDRU+oXvdD7KCtgKxW95M5Z8BpSCJXQORiZFnBQS5QU=
|
||||
github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
@@ -86,8 +86,8 @@ github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm
|
||||
github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4=
|
||||
github.com/miekg/dns v1.1.61 h1:nLxbwF3XxhwVSm8g9Dghm9MHPaUZuqhPiGL+675ZmEs=
|
||||
github.com/miekg/dns v1.1.61/go.mod h1:mnAarhS3nWaW+NVP2wTkYVIZyHNJ098SJZUki3eykwQ=
|
||||
github.com/miekg/dns v1.1.62 h1:cN8OuEF1/x5Rq6Np+h1epln8OiyPWV+lROx9LxcGgIQ=
|
||||
github.com/miekg/dns v1.1.62/go.mod h1:mvDlcItzm+br7MToIKqkglaGhlFMHJ9DTNNWONWXbNQ=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo=
|
||||
@@ -112,8 +112,8 @@ github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7q
|
||||
github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo=
|
||||
github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A=
|
||||
github.com/quic-go/quic-go v0.45.1 h1:tPfeYCk+uZHjmDRwHHQmvHRYL2t44ROTujLeFVBmjCA=
|
||||
github.com/quic-go/quic-go v0.45.1/go.mod h1:1dLehS7TIR64+vxGR70GDcatWTOtMX2PUtnKsjbTurI=
|
||||
github.com/quic-go/quic-go v0.46.0 h1:uuwLClEEyk1DNvchH8uCByQVjo3yKL9opKulExNDs7Y=
|
||||
github.com/quic-go/quic-go v0.46.0/go.mod h1:1dLehS7TIR64+vxGR70GDcatWTOtMX2PUtnKsjbTurI=
|
||||
github.com/refraction-networking/utls v1.6.7 h1:zVJ7sP1dJx/WtVuITug3qYUq034cDq9B2MR1K67ULZM=
|
||||
github.com/refraction-networking/utls v1.6.7/go.mod h1:BC3O4vQzye5hqpmDTWUqi4P5DDhzJfkV1tdqtawQIH0=
|
||||
github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg=
|
||||
@@ -160,9 +160,8 @@ github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e h1:5QefA066A1tF
|
||||
github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e/go.mod h1:5t19P9LBIrNamL6AcMQOncg/r10y3Pc01AbHeMhwlpU=
|
||||
github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU=
|
||||
github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM=
|
||||
github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3 h1:tkMT5pTye+1NlKIXETU78NXw0fyjnaNHmJyyLyzw8+U=
|
||||
github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3/go.mod h1:cAAsePK2e15YDAMJNyOpGYEWNe4sIghTY7gpz4cX/Ik=
|
||||
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
|
||||
github.com/vishvananda/netlink v1.3.0 h1:X7l42GfcV4S6E4vHTsw48qbrV+9PVojNfIhZcwQdrZk=
|
||||
github.com/vishvananda/netlink v1.3.0/go.mod h1:i6NetklAujEcC6fK0JPjT8qSwWyO0HLn4UKG+hGqeJs=
|
||||
github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8=
|
||||
github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM=
|
||||
github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d h1:+B97uD9uHLgAAulhigmys4BVwZZypzK7gPN3WtpgRJg=
|
||||
@@ -179,8 +178,8 @@ golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnf
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
|
||||
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
|
||||
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
|
||||
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg=
|
||||
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
|
||||
@@ -201,8 +200,8 @@ golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
|
||||
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
|
||||
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
|
||||
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
@@ -214,29 +213,29 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
|
||||
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190316082340-a2f829d7f35f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220804214406-8e32c043e418/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
|
||||
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
|
||||
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
|
||||
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
||||
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
|
||||
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
|
||||
@@ -269,14 +268,14 @@ google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoA
|
||||
google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg=
|
||||
google.golang.org/genproto v0.0.0-20190306203927-b5d61aea6440/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 h1:Zy9XzmMEflZ/MAaA7vNcoebnRAld7FsPW1EeBB7V0m8=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 h1:1GBuWVLM/KMVUv1t1En5Gs+gFZCNd360GGb4sSxtrhU=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0=
|
||||
google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
|
||||
google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio=
|
||||
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc=
|
||||
google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ=
|
||||
google.golang.org/grpc v1.66.0 h1:DibZuoBznOxbDQxRINckZcUvnCEvrW9pcWIE2yF9r1c=
|
||||
google.golang.org/grpc v1.66.0/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y=
|
||||
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
|
||||
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
|
@@ -18,6 +18,7 @@ type FreedomConfig struct {
|
||||
Redirect string `json:"redirect"`
|
||||
UserLevel uint32 `json:"userLevel"`
|
||||
Fragment *Fragment `json:"fragment"`
|
||||
Noise *Noise `json:"noise"`
|
||||
ProxyProtocol uint32 `json:"proxyProtocol"`
|
||||
}
|
||||
|
||||
@@ -27,6 +28,11 @@ type Fragment struct {
|
||||
Interval string `json:"interval"`
|
||||
}
|
||||
|
||||
type Noise struct {
|
||||
Packet string `json:"packet"`
|
||||
Delay string `json:"delay"`
|
||||
}
|
||||
|
||||
// Build implements Buildable
|
||||
func (c *FreedomConfig) Build() (proto.Message, error) {
|
||||
config := new(freedom.Config)
|
||||
@@ -143,6 +149,76 @@ func (c *FreedomConfig) Build() (proto.Message, error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if c.Noise != nil {
|
||||
config.Noise = new(freedom.Noise)
|
||||
var err, err2 error
|
||||
p := strings.Split(strings.ToLower(c.Noise.Packet), ":")
|
||||
if len(p) != 2 {
|
||||
return nil, errors.New("invalid type for packet")
|
||||
}
|
||||
switch p[0] {
|
||||
case "rand":
|
||||
randValue := strings.Split(p[1], "-")
|
||||
if len(randValue) > 2 {
|
||||
return nil, errors.New("Only 2 values are allowed for rand")
|
||||
}
|
||||
if len(randValue) == 2 {
|
||||
config.Noise.LengthMin, err = strconv.ParseUint(randValue[0], 10, 64)
|
||||
config.Noise.LengthMax, err2 = strconv.ParseUint(randValue[1], 10, 64)
|
||||
}
|
||||
if len(randValue) == 1 {
|
||||
config.Noise.LengthMin, err = strconv.ParseUint(randValue[0], 10, 64)
|
||||
config.Noise.LengthMax = config.Noise.LengthMin
|
||||
}
|
||||
if err != nil {
|
||||
return nil, errors.New("invalid value for rand LengthMin").Base(err)
|
||||
}
|
||||
if err2 != nil {
|
||||
return nil, errors.New("invalid value for rand LengthMax").Base(err2)
|
||||
}
|
||||
if config.Noise.LengthMin > config.Noise.LengthMax {
|
||||
config.Noise.LengthMin, config.Noise.LengthMax = config.Noise.LengthMax, config.Noise.LengthMin
|
||||
}
|
||||
if config.Noise.LengthMin == 0 {
|
||||
return nil, errors.New("rand lengthMin or lengthMax cannot be 0")
|
||||
}
|
||||
|
||||
case "str":
|
||||
//user input string
|
||||
config.Noise.StrNoise = strings.TrimSpace(p[1])
|
||||
|
||||
default:
|
||||
return nil, errors.New("Invalid packet,only rand and str are supported")
|
||||
}
|
||||
if c.Noise.Delay != "" {
|
||||
d := strings.Split(strings.ToLower(c.Noise.Delay), "-")
|
||||
if len(d) > 2 {
|
||||
return nil, errors.New("Invalid delay value")
|
||||
}
|
||||
if len(d) == 2 {
|
||||
config.Noise.DelayMin, err = strconv.ParseUint(d[0], 10, 64)
|
||||
config.Noise.DelayMax, err2 = strconv.ParseUint(d[1], 10, 64)
|
||||
|
||||
} else {
|
||||
config.Noise.DelayMin, err = strconv.ParseUint(d[0], 10, 64)
|
||||
config.Noise.DelayMax = config.Noise.DelayMin
|
||||
}
|
||||
if err != nil {
|
||||
return nil, errors.New("Invalid value for DelayMin").Base(err)
|
||||
}
|
||||
if err2 != nil {
|
||||
return nil, errors.New("Invalid value for DelayMax").Base(err2)
|
||||
}
|
||||
if config.Noise.DelayMin > config.Noise.DelayMax {
|
||||
config.Noise.DelayMin, config.Noise.DelayMax = config.Noise.DelayMax, config.Noise.DelayMin
|
||||
}
|
||||
if config.Noise.DelayMin == 0 {
|
||||
return nil, errors.New("DelayMin or DelayMax cannot be 0")
|
||||
}
|
||||
} else {
|
||||
config.Noise.DelayMin = 0
|
||||
}
|
||||
}
|
||||
|
||||
if c.Timeout != nil {
|
||||
config.Timeout = *c.Timeout
|
||||
|
@@ -11,27 +11,27 @@ import (
|
||||
"github.com/xtls/xray-core/main/confloader"
|
||||
)
|
||||
|
||||
func MergeConfigFromFiles(files []string, formats []string) (string, error) {
|
||||
c, err := mergeConfigs(files, formats)
|
||||
func MergeConfigFromFiles(files []*core.ConfigSource) (string, error) {
|
||||
c, err := mergeConfigs(files)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if j, ok := creflect.MarshalToJson(c); ok {
|
||||
if j, ok := creflect.MarshalToJson(c, true); ok {
|
||||
return j, nil
|
||||
}
|
||||
return "", errors.New("marshal to json failed.").AtError()
|
||||
}
|
||||
|
||||
func mergeConfigs(files []string, formats []string) (*conf.Config, error) {
|
||||
func mergeConfigs(files []*core.ConfigSource) (*conf.Config, error) {
|
||||
cf := &conf.Config{}
|
||||
for i, file := range files {
|
||||
errors.LogInfo(context.Background(), "Reading config: ", file)
|
||||
r, err := confloader.LoadConfig(file)
|
||||
r, err := confloader.LoadConfig(file.Name)
|
||||
if err != nil {
|
||||
return nil, errors.New("failed to read config: ", file).Base(err)
|
||||
}
|
||||
c, err := ReaderDecoderByFormat[formats[i]](r)
|
||||
c, err := ReaderDecoderByFormat[file.Format](r)
|
||||
if err != nil {
|
||||
return nil, errors.New("failed to decode config: ", file).Base(err)
|
||||
}
|
||||
@@ -39,13 +39,13 @@ func mergeConfigs(files []string, formats []string) (*conf.Config, error) {
|
||||
*cf = *c
|
||||
continue
|
||||
}
|
||||
cf.Override(c, file)
|
||||
cf.Override(c, file.Name)
|
||||
}
|
||||
return cf, nil
|
||||
}
|
||||
|
||||
func BuildConfig(files []string, formats []string) (*core.Config, error) {
|
||||
config, err := mergeConfigs(files, formats)
|
||||
func BuildConfig(files []*core.ConfigSource) (*core.Config, error) {
|
||||
config, err := mergeConfigs(files)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@@ -229,10 +229,22 @@ type SplitHTTPConfig struct {
|
||||
Host string `json:"host"`
|
||||
Path string `json:"path"`
|
||||
Headers map[string]string `json:"headers"`
|
||||
ScMaxConcurrentPosts Int32Range `json:"scMaxConcurrentPosts"`
|
||||
ScMaxEachPostBytes Int32Range `json:"scMaxEachPostBytes"`
|
||||
ScMinPostsIntervalMs Int32Range `json:"scMinPostsIntervalMs"`
|
||||
ScMaxConcurrentPosts *Int32Range `json:"scMaxConcurrentPosts"`
|
||||
ScMaxEachPostBytes *Int32Range `json:"scMaxEachPostBytes"`
|
||||
ScMinPostsIntervalMs *Int32Range `json:"scMinPostsIntervalMs"`
|
||||
NoSSEHeader bool `json:"noSSEHeader"`
|
||||
XPaddingBytes *Int32Range `json:"xPaddingBytes"`
|
||||
}
|
||||
|
||||
func splithttpNewRandRangeConfig(input *Int32Range) *splithttp.RandRangeConfig {
|
||||
if input == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &splithttp.RandRangeConfig{
|
||||
From: input.From,
|
||||
To: input.To,
|
||||
}
|
||||
}
|
||||
|
||||
// Build implements Buildable.
|
||||
@@ -246,22 +258,14 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) {
|
||||
c.Host = c.Headers["Host"]
|
||||
}
|
||||
config := &splithttp.Config{
|
||||
Path: c.Path,
|
||||
Host: c.Host,
|
||||
Header: c.Headers,
|
||||
ScMaxConcurrentPosts: &splithttp.RandRangeConfig{
|
||||
From: c.ScMaxConcurrentPosts.From,
|
||||
To: c.ScMaxConcurrentPosts.To,
|
||||
},
|
||||
ScMaxEachPostBytes: &splithttp.RandRangeConfig{
|
||||
From: c.ScMaxEachPostBytes.From,
|
||||
To: c.ScMaxEachPostBytes.To,
|
||||
},
|
||||
ScMinPostsIntervalMs: &splithttp.RandRangeConfig{
|
||||
From: c.ScMinPostsIntervalMs.From,
|
||||
To: c.ScMinPostsIntervalMs.To,
|
||||
},
|
||||
NoSSEHeader: c.NoSSEHeader,
|
||||
Path: c.Path,
|
||||
Host: c.Host,
|
||||
Header: c.Headers,
|
||||
ScMaxConcurrentPosts: splithttpNewRandRangeConfig(c.ScMaxConcurrentPosts),
|
||||
ScMaxEachPostBytes: splithttpNewRandRangeConfig(c.ScMaxEachPostBytes),
|
||||
ScMinPostsIntervalMs: splithttpNewRandRangeConfig(c.ScMinPostsIntervalMs),
|
||||
NoSSEHeader: c.NoSSEHeader,
|
||||
XPaddingBytes: splithttpNewRandRangeConfig(c.XPaddingBytes),
|
||||
}
|
||||
return config, nil
|
||||
}
|
||||
|
@@ -13,10 +13,10 @@ import (
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
|
||||
"github.com/xtls/xray-core/common/buf"
|
||||
"github.com/xtls/xray-core/main/commands/base"
|
||||
creflect "github.com/xtls/xray-core/common/reflect"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
@@ -107,20 +107,16 @@ func fetchHTTPContent(target string) ([]byte, error) {
|
||||
return content, nil
|
||||
}
|
||||
|
||||
func protoToJSONString(m proto.Message, prefix, indent string) (string, error) {
|
||||
return strings.TrimSpace(protojson.MarshalOptions{Indent: indent}.Format(m)), nil
|
||||
}
|
||||
|
||||
func showJSONResponse(m proto.Message) {
|
||||
if isNil(m) {
|
||||
return
|
||||
}
|
||||
output, err := protoToJSONString(m, "", " ")
|
||||
if err != nil {
|
||||
if j, ok := creflect.MarshalToJson(m, true); ok {
|
||||
fmt.Println(j)
|
||||
} else {
|
||||
fmt.Fprintf(os.Stdout, "%v\n", m)
|
||||
base.Fatalf("error encode json: %s", err)
|
||||
base.Fatalf("error encode json")
|
||||
}
|
||||
fmt.Println(output)
|
||||
}
|
||||
|
||||
func isNil(i interface{}) bool {
|
||||
|
@@ -2,6 +2,7 @@ package all
|
||||
|
||||
import (
|
||||
"github.com/xtls/xray-core/main/commands/all/api"
|
||||
"github.com/xtls/xray-core/main/commands/all/convert"
|
||||
"github.com/xtls/xray-core/main/commands/all/tls"
|
||||
"github.com/xtls/xray-core/main/commands/base"
|
||||
)
|
||||
@@ -12,7 +13,7 @@ func init() {
|
||||
base.RootCommand.Commands = append(
|
||||
base.RootCommand.Commands,
|
||||
api.CmdAPI,
|
||||
// cmdConvert,
|
||||
convert.CmdConvert,
|
||||
tls.CmdTLS,
|
||||
cmdUUID,
|
||||
cmdX25519,
|
||||
|
@@ -1,126 +0,0 @@
|
||||
package all
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/xtls/xray-core/common"
|
||||
"github.com/xtls/xray-core/common/buf"
|
||||
"github.com/xtls/xray-core/common/errors"
|
||||
"github.com/xtls/xray-core/infra/conf"
|
||||
"github.com/xtls/xray-core/infra/conf/serial"
|
||||
"github.com/xtls/xray-core/main/commands/base"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
var cmdConvert = &base.Command{
|
||||
UsageLine: "{{.Exec}} convert [json file] [json file] ...",
|
||||
Short: "Convert multiple json config to protobuf",
|
||||
Long: `
|
||||
Convert multiple json config to protobuf.
|
||||
|
||||
Examples:
|
||||
|
||||
{{.Exec}} convert config.json c1.json c2.json <url>.json
|
||||
`,
|
||||
}
|
||||
|
||||
func init() {
|
||||
cmdConvert.Run = executeConvert // break init loop
|
||||
}
|
||||
|
||||
func executeConvert(cmd *base.Command, args []string) {
|
||||
unnamedArgs := cmdConvert.Flag.Args()
|
||||
if len(unnamedArgs) < 1 {
|
||||
base.Fatalf("empty config list")
|
||||
}
|
||||
|
||||
conf := &conf.Config{}
|
||||
for _, arg := range unnamedArgs {
|
||||
fmt.Fprintf(os.Stderr, "Read config: %s", arg)
|
||||
r, err := loadArg(arg)
|
||||
common.Must(err)
|
||||
c, err := serial.DecodeJSONConfig(r)
|
||||
if err != nil {
|
||||
base.Fatalf(err.Error())
|
||||
}
|
||||
conf.Override(c, arg)
|
||||
}
|
||||
|
||||
pbConfig, err := conf.Build()
|
||||
if err != nil {
|
||||
base.Fatalf(err.Error())
|
||||
}
|
||||
|
||||
bytesConfig, err := proto.Marshal(pbConfig)
|
||||
if err != nil {
|
||||
base.Fatalf("failed to marshal proto config: %s", err)
|
||||
}
|
||||
|
||||
if _, err := os.Stdout.Write(bytesConfig); err != nil {
|
||||
base.Fatalf("failed to write proto config: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
// loadArg loads one arg, maybe an remote url, or local file path
|
||||
func loadArg(arg string) (out io.Reader, err error) {
|
||||
var data []byte
|
||||
switch {
|
||||
case strings.HasPrefix(arg, "http://"), strings.HasPrefix(arg, "https://"):
|
||||
data, err = FetchHTTPContent(arg)
|
||||
|
||||
case arg == "stdin:":
|
||||
data, err = io.ReadAll(os.Stdin)
|
||||
|
||||
default:
|
||||
data, err = os.ReadFile(arg)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
out = bytes.NewBuffer(data)
|
||||
return
|
||||
}
|
||||
|
||||
// FetchHTTPContent dials https for remote content
|
||||
func FetchHTTPContent(target string) ([]byte, error) {
|
||||
parsedTarget, err := url.Parse(target)
|
||||
if err != nil {
|
||||
return nil, errors.New("invalid URL: ", target).Base(err)
|
||||
}
|
||||
|
||||
if s := strings.ToLower(parsedTarget.Scheme); s != "http" && s != "https" {
|
||||
return nil, errors.New("invalid scheme: ", parsedTarget.Scheme)
|
||||
}
|
||||
|
||||
client := &http.Client{
|
||||
Timeout: 30 * time.Second,
|
||||
}
|
||||
resp, err := client.Do(&http.Request{
|
||||
Method: "GET",
|
||||
URL: parsedTarget,
|
||||
Close: true,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, errors.New("failed to dial to ", target).Base(err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
return nil, errors.New("unexpected HTTP status code: ", resp.StatusCode)
|
||||
}
|
||||
|
||||
content, err := buf.ReadAllToBytes(resp.Body)
|
||||
if err != nil {
|
||||
return nil, errors.New("failed to read HTTP response").Base(err)
|
||||
}
|
||||
|
||||
return content, nil
|
||||
}
|
17
main/commands/all/convert/convert.go
Normal file
17
main/commands/all/convert/convert.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package convert
|
||||
|
||||
import (
|
||||
"github.com/xtls/xray-core/main/commands/base"
|
||||
)
|
||||
|
||||
// CmdConvert do config convertion
|
||||
var CmdConvert = &base.Command{
|
||||
UsageLine: "{{.Exec}} convert",
|
||||
Short: "Convert configs",
|
||||
Long: `{{.Exec}} {{.LongName}} provides tools to convert config.
|
||||
`,
|
||||
Commands: []*base.Command{
|
||||
cmdProtobuf,
|
||||
cmdJson,
|
||||
},
|
||||
}
|
71
main/commands/all/convert/json.go
Normal file
71
main/commands/all/convert/json.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package convert
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
creflect "github.com/xtls/xray-core/common/reflect"
|
||||
cserial "github.com/xtls/xray-core/common/serial"
|
||||
"github.com/xtls/xray-core/main/commands/base"
|
||||
"github.com/xtls/xray-core/main/confloader"
|
||||
)
|
||||
|
||||
var cmdJson = &base.Command{
|
||||
CustomFlags: true,
|
||||
UsageLine: "{{.Exec}} convert json [-type] [stdin:] [typedMessage file] ",
|
||||
Short: "Convert typedMessage to json",
|
||||
Long: `
|
||||
Convert ONE typedMessage to json.
|
||||
|
||||
Where typedMessage file need to be in the following format:
|
||||
|
||||
{
|
||||
"type": "xray.proxy.shadowsocks.Account",
|
||||
"value": "CgMxMTEQBg=="
|
||||
}
|
||||
|
||||
Arguments:
|
||||
|
||||
-t, -type
|
||||
Inject type infomation.
|
||||
|
||||
Examples:
|
||||
|
||||
{{.Exec}} convert json user.tmsg
|
||||
`,
|
||||
Run: executeTypedMessageToJson,
|
||||
}
|
||||
|
||||
func executeTypedMessageToJson(cmd *base.Command, args []string) {
|
||||
|
||||
var injectTypeInfo bool
|
||||
cmd.Flag.BoolVar(&injectTypeInfo, "t", false, "")
|
||||
cmd.Flag.BoolVar(&injectTypeInfo, "type", false, "")
|
||||
cmd.Flag.Parse(args)
|
||||
|
||||
if cmd.Flag.NArg() < 1 {
|
||||
base.Fatalf("empty input list")
|
||||
}
|
||||
|
||||
reader, err := confloader.LoadConfig(cmd.Flag.Arg(0))
|
||||
if err != nil {
|
||||
base.Fatalf(err.Error())
|
||||
}
|
||||
|
||||
b, err := io.ReadAll(reader)
|
||||
if err != nil {
|
||||
base.Fatalf(err.Error())
|
||||
}
|
||||
|
||||
tm := cserial.TypedMessage{}
|
||||
if err = json.Unmarshal(b, &tm); err != nil {
|
||||
base.Fatalf(err.Error())
|
||||
}
|
||||
|
||||
if j, ok := creflect.MarshalToJson(&tm, injectTypeInfo); ok {
|
||||
fmt.Println(j)
|
||||
} else {
|
||||
base.Fatalf("marshal TypedMessage to json failed")
|
||||
}
|
||||
}
|
81
main/commands/all/convert/protobuf.go
Normal file
81
main/commands/all/convert/protobuf.go
Normal file
@@ -0,0 +1,81 @@
|
||||
package convert
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/xtls/xray-core/common/cmdarg"
|
||||
creflect "github.com/xtls/xray-core/common/reflect"
|
||||
"github.com/xtls/xray-core/core"
|
||||
"github.com/xtls/xray-core/main/commands/base"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
var cmdProtobuf = &base.Command{
|
||||
CustomFlags: true,
|
||||
UsageLine: "{{.Exec}} convert pb [-debug] [-type] [json file] [json file] ...",
|
||||
Short: "Convert multiple json configs to protobuf",
|
||||
Long: `
|
||||
Convert multiple json configs to protobuf.
|
||||
|
||||
Arguments:
|
||||
|
||||
-d, -debug
|
||||
Show mix.pb as json.
|
||||
FOR DEBUGGING ONLY!
|
||||
DO NOT PASS THIS OUTPUT TO XRAY-CORE!
|
||||
|
||||
-t, -type
|
||||
Inject type information into debug output.
|
||||
|
||||
Examples:
|
||||
|
||||
{{.Exec}} convert pb config.json c1.json c2.json c3.json > mix.pb
|
||||
`,
|
||||
Run: executeConvertConfigsToProtobuf,
|
||||
}
|
||||
|
||||
func executeConvertConfigsToProtobuf(cmd *base.Command, args []string) {
|
||||
|
||||
var optDump bool
|
||||
var optType bool
|
||||
|
||||
cmd.Flag.BoolVar(&optDump, "d", false, "")
|
||||
cmd.Flag.BoolVar(&optDump, "debug", false, "")
|
||||
cmd.Flag.BoolVar(&optType, "t", false, "")
|
||||
cmd.Flag.BoolVar(&optType, "type", false, "")
|
||||
cmd.Flag.Parse(args)
|
||||
|
||||
unnamedArgs := cmdarg.Arg{}
|
||||
for _, v := range cmd.Flag.Args() {
|
||||
unnamedArgs.Set(v)
|
||||
}
|
||||
|
||||
if len(unnamedArgs) < 1 {
|
||||
base.Fatalf("empty config list")
|
||||
}
|
||||
|
||||
pbConfig, err := core.LoadConfig("auto", unnamedArgs)
|
||||
if err != nil {
|
||||
base.Fatalf(err.Error())
|
||||
}
|
||||
|
||||
if optDump {
|
||||
if j, ok := creflect.MarshalToJson(pbConfig, optType); ok {
|
||||
fmt.Println(j)
|
||||
return
|
||||
} else {
|
||||
base.Fatalf("failed to marshal proto config to json.")
|
||||
}
|
||||
}
|
||||
|
||||
bytesConfig, err := proto.Marshal(pbConfig)
|
||||
if err != nil {
|
||||
base.Fatalf("failed to marshal proto config: %s", err)
|
||||
}
|
||||
|
||||
if _, err := os.Stdout.Write(bytesConfig); err != nil {
|
||||
base.Fatalf("failed to write proto config: %s", err)
|
||||
}
|
||||
}
|
@@ -1,10 +1,5 @@
|
||||
package base
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
)
|
||||
|
||||
// CommandEnvHolder is a struct holds the environment info of commands
|
||||
type CommandEnvHolder struct {
|
||||
// Executable name of current binary
|
||||
@@ -17,10 +12,12 @@ type CommandEnvHolder struct {
|
||||
var CommandEnv CommandEnvHolder
|
||||
|
||||
func init() {
|
||||
exec, err := os.Executable()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
CommandEnv.Exec = path.Base(exec)
|
||||
/*
|
||||
exec, err := os.Executable()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
CommandEnv.Exec = path.Base(exec)
|
||||
*/
|
||||
CommandEnv.Exec = "xray"
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ import (
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// copied from "github.com/golang/go/main.go"
|
||||
|
||||
// Execute excute the commands
|
||||
// Execute execute the commands
|
||||
func Execute() {
|
||||
flag.Parse()
|
||||
args := flag.Args()
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: proxy/blackhole/config.proto
|
||||
|
||||
@@ -181,7 +181,7 @@ func file_proxy_blackhole_config_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_proxy_blackhole_config_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_proxy_blackhole_config_proto_goTypes = []interface{}{
|
||||
var file_proxy_blackhole_config_proto_goTypes = []any{
|
||||
(*NoneResponse)(nil), // 0: xray.proxy.blackhole.NoneResponse
|
||||
(*HTTPResponse)(nil), // 1: xray.proxy.blackhole.HTTPResponse
|
||||
(*Config)(nil), // 2: xray.proxy.blackhole.Config
|
||||
@@ -202,7 +202,7 @@ func file_proxy_blackhole_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_proxy_blackhole_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_blackhole_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*NoneResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -214,7 +214,7 @@ func file_proxy_blackhole_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proxy_blackhole_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_blackhole_config_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*HTTPResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -226,7 +226,7 @@ func file_proxy_blackhole_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proxy_blackhole_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_blackhole_config_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: proxy/dns/config.proto
|
||||
|
||||
@@ -122,7 +122,7 @@ func file_proxy_dns_config_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_proxy_dns_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_proxy_dns_config_proto_goTypes = []interface{}{
|
||||
var file_proxy_dns_config_proto_goTypes = []any{
|
||||
(*Config)(nil), // 0: xray.proxy.dns.Config
|
||||
(*net.Endpoint)(nil), // 1: xray.common.net.Endpoint
|
||||
}
|
||||
@@ -141,7 +141,7 @@ func file_proxy_dns_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_proxy_dns_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_dns_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: proxy/dokodemo/config.proto
|
||||
|
||||
@@ -175,7 +175,7 @@ func file_proxy_dokodemo_config_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_proxy_dokodemo_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_proxy_dokodemo_config_proto_goTypes = []interface{}{
|
||||
var file_proxy_dokodemo_config_proto_goTypes = []any{
|
||||
(*Config)(nil), // 0: xray.proxy.dokodemo.Config
|
||||
(*net.IPOrDomain)(nil), // 1: xray.common.net.IPOrDomain
|
||||
(*net.NetworkList)(nil), // 2: xray.common.net.NetworkList
|
||||
@@ -198,7 +198,7 @@ func file_proxy_dokodemo_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_proxy_dokodemo_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_dokodemo_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: proxy/freedom/config.proto
|
||||
|
||||
@@ -91,7 +91,7 @@ func (x Config_DomainStrategy) Number() protoreflect.EnumNumber {
|
||||
|
||||
// Deprecated: Use Config_DomainStrategy.Descriptor instead.
|
||||
func (Config_DomainStrategy) EnumDescriptor() ([]byte, []int) {
|
||||
return file_proxy_freedom_config_proto_rawDescGZIP(), []int{2, 0}
|
||||
return file_proxy_freedom_config_proto_rawDescGZIP(), []int{3, 0}
|
||||
}
|
||||
|
||||
type DestinationOverride struct {
|
||||
@@ -228,6 +228,85 @@ func (x *Fragment) GetIntervalMax() uint64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
type Noise struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
LengthMin uint64 `protobuf:"varint,1,opt,name=length_min,json=lengthMin,proto3" json:"length_min,omitempty"`
|
||||
LengthMax uint64 `protobuf:"varint,2,opt,name=length_max,json=lengthMax,proto3" json:"length_max,omitempty"`
|
||||
DelayMin uint64 `protobuf:"varint,3,opt,name=delay_min,json=delayMin,proto3" json:"delay_min,omitempty"`
|
||||
DelayMax uint64 `protobuf:"varint,4,opt,name=delay_max,json=delayMax,proto3" json:"delay_max,omitempty"`
|
||||
StrNoise string `protobuf:"bytes,5,opt,name=str_noise,json=strNoise,proto3" json:"str_noise,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Noise) Reset() {
|
||||
*x = Noise{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proxy_freedom_config_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Noise) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Noise) ProtoMessage() {}
|
||||
|
||||
func (x *Noise) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proxy_freedom_config_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Noise.ProtoReflect.Descriptor instead.
|
||||
func (*Noise) Descriptor() ([]byte, []int) {
|
||||
return file_proxy_freedom_config_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *Noise) GetLengthMin() uint64 {
|
||||
if x != nil {
|
||||
return x.LengthMin
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Noise) GetLengthMax() uint64 {
|
||||
if x != nil {
|
||||
return x.LengthMax
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Noise) GetDelayMin() uint64 {
|
||||
if x != nil {
|
||||
return x.DelayMin
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Noise) GetDelayMax() uint64 {
|
||||
if x != nil {
|
||||
return x.DelayMax
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Noise) GetStrNoise() string {
|
||||
if x != nil {
|
||||
return x.StrNoise
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
@@ -240,12 +319,13 @@ type Config struct {
|
||||
UserLevel uint32 `protobuf:"varint,4,opt,name=user_level,json=userLevel,proto3" json:"user_level,omitempty"`
|
||||
Fragment *Fragment `protobuf:"bytes,5,opt,name=fragment,proto3" json:"fragment,omitempty"`
|
||||
ProxyProtocol uint32 `protobuf:"varint,6,opt,name=proxy_protocol,json=proxyProtocol,proto3" json:"proxy_protocol,omitempty"`
|
||||
Noise *Noise `protobuf:"bytes,7,opt,name=noise,proto3" json:"noise,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Config) Reset() {
|
||||
*x = Config{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proxy_freedom_config_proto_msgTypes[2]
|
||||
mi := &file_proxy_freedom_config_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -258,7 +338,7 @@ func (x *Config) String() string {
|
||||
func (*Config) ProtoMessage() {}
|
||||
|
||||
func (x *Config) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proxy_freedom_config_proto_msgTypes[2]
|
||||
mi := &file_proxy_freedom_config_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -271,7 +351,7 @@ func (x *Config) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use Config.ProtoReflect.Descriptor instead.
|
||||
func (*Config) Descriptor() ([]byte, []int) {
|
||||
return file_proxy_freedom_config_proto_rawDescGZIP(), []int{2}
|
||||
return file_proxy_freedom_config_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *Config) GetDomainStrategy() Config_DomainStrategy {
|
||||
@@ -317,6 +397,13 @@ func (x *Config) GetProxyProtocol() uint32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Config) GetNoise() *Noise {
|
||||
if x != nil {
|
||||
return x.Noise
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_proxy_freedom_config_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_proxy_freedom_config_proto_rawDesc = []byte{
|
||||
@@ -343,29 +430,42 @@ var file_proxy_freedom_config_proto_rawDesc = []byte{
|
||||
0x6c, 0x5f, 0x6d, 0x69, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x69, 0x6e, 0x74,
|
||||
0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x69, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x6e, 0x74, 0x65,
|
||||
0x72, 0x76, 0x61, 0x6c, 0x5f, 0x6d, 0x61, 0x78, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b,
|
||||
0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x61, 0x78, 0x22, 0x82, 0x04, 0x0a, 0x06,
|
||||
0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x52, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e,
|
||||
0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32,
|
||||
0x29, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65,
|
||||
0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x44, 0x6f, 0x6d, 0x61,
|
||||
0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0e, 0x64, 0x6f, 0x6d, 0x61,
|
||||
0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x1c, 0x0a, 0x07, 0x74, 0x69,
|
||||
0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x42, 0x02, 0x18, 0x01, 0x52,
|
||||
0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x5a, 0x0a, 0x14, 0x64, 0x65, 0x73, 0x74,
|
||||
0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65,
|
||||
0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72,
|
||||
0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x44, 0x65, 0x73, 0x74,
|
||||
0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x52,
|
||||
0x13, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x76, 0x65, 0x72,
|
||||
0x72, 0x69, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x65, 0x76,
|
||||
0x65, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x4c, 0x65,
|
||||
0x76, 0x65, 0x6c, 0x12, 0x38, 0x0a, 0x08, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x18,
|
||||
0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f,
|
||||
0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x46, 0x72, 0x61, 0x67, 0x6d,
|
||||
0x65, 0x6e, 0x74, 0x52, 0x08, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x0a,
|
||||
0x0e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18,
|
||||
0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x50, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x63, 0x6f, 0x6c, 0x22, 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53,
|
||||
0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x61, 0x78, 0x22, 0x9c, 0x01, 0x0a, 0x05,
|
||||
0x4e, 0x6f, 0x69, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x5f,
|
||||
0x6d, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x6c, 0x65, 0x6e, 0x67, 0x74,
|
||||
0x68, 0x4d, 0x69, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x5f, 0x6d,
|
||||
0x61, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68,
|
||||
0x4d, 0x61, 0x78, 0x12, 0x1b, 0x0a, 0x09, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x5f, 0x6d, 0x69, 0x6e,
|
||||
0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x4d, 0x69, 0x6e,
|
||||
0x12, 0x1b, 0x0a, 0x09, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x5f, 0x6d, 0x61, 0x78, 0x18, 0x04, 0x20,
|
||||
0x01, 0x28, 0x04, 0x52, 0x08, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x4d, 0x61, 0x78, 0x12, 0x1b, 0x0a,
|
||||
0x09, 0x73, 0x74, 0x72, 0x5f, 0x6e, 0x6f, 0x69, 0x73, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x08, 0x73, 0x74, 0x72, 0x4e, 0x6f, 0x69, 0x73, 0x65, 0x22, 0xb3, 0x04, 0x0a, 0x06, 0x43,
|
||||
0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x52, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f,
|
||||
0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x29,
|
||||
0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65,
|
||||
0x64, 0x6f, 0x6d, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69,
|
||||
0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0e, 0x64, 0x6f, 0x6d, 0x61, 0x69,
|
||||
0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x1c, 0x0a, 0x07, 0x74, 0x69, 0x6d,
|
||||
0x65, 0x6f, 0x75, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x42, 0x02, 0x18, 0x01, 0x52, 0x07,
|
||||
0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x5a, 0x0a, 0x14, 0x64, 0x65, 0x73, 0x74, 0x69,
|
||||
0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x18,
|
||||
0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f,
|
||||
0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x44, 0x65, 0x73, 0x74, 0x69,
|
||||
0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x52, 0x13,
|
||||
0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x76, 0x65, 0x72, 0x72,
|
||||
0x69, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x65, 0x76, 0x65,
|
||||
0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x4c, 0x65, 0x76,
|
||||
0x65, 0x6c, 0x12, 0x38, 0x0a, 0x08, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x05,
|
||||
0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78,
|
||||
0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x46, 0x72, 0x61, 0x67, 0x6d, 0x65,
|
||||
0x6e, 0x74, 0x52, 0x08, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x0a, 0x0e,
|
||||
0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x06,
|
||||
0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x63, 0x6f, 0x6c, 0x12, 0x2f, 0x0a, 0x05, 0x6e, 0x6f, 0x69, 0x73, 0x65, 0x18, 0x07, 0x20, 0x01,
|
||||
0x28, 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e,
|
||||
0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x4e, 0x6f, 0x69, 0x73, 0x65, 0x52, 0x05, 0x6e,
|
||||
0x6f, 0x69, 0x73, 0x65, 0x22, 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53,
|
||||
0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53,
|
||||
0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b,
|
||||
0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55,
|
||||
@@ -398,24 +498,26 @@ func file_proxy_freedom_config_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_proxy_freedom_config_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_proxy_freedom_config_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_proxy_freedom_config_proto_goTypes = []interface{}{
|
||||
var file_proxy_freedom_config_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||
var file_proxy_freedom_config_proto_goTypes = []any{
|
||||
(Config_DomainStrategy)(0), // 0: xray.proxy.freedom.Config.DomainStrategy
|
||||
(*DestinationOverride)(nil), // 1: xray.proxy.freedom.DestinationOverride
|
||||
(*Fragment)(nil), // 2: xray.proxy.freedom.Fragment
|
||||
(*Config)(nil), // 3: xray.proxy.freedom.Config
|
||||
(*protocol.ServerEndpoint)(nil), // 4: xray.common.protocol.ServerEndpoint
|
||||
(*Noise)(nil), // 3: xray.proxy.freedom.Noise
|
||||
(*Config)(nil), // 4: xray.proxy.freedom.Config
|
||||
(*protocol.ServerEndpoint)(nil), // 5: xray.common.protocol.ServerEndpoint
|
||||
}
|
||||
var file_proxy_freedom_config_proto_depIdxs = []int32{
|
||||
4, // 0: xray.proxy.freedom.DestinationOverride.server:type_name -> xray.common.protocol.ServerEndpoint
|
||||
5, // 0: xray.proxy.freedom.DestinationOverride.server:type_name -> xray.common.protocol.ServerEndpoint
|
||||
0, // 1: xray.proxy.freedom.Config.domain_strategy:type_name -> xray.proxy.freedom.Config.DomainStrategy
|
||||
1, // 2: xray.proxy.freedom.Config.destination_override:type_name -> xray.proxy.freedom.DestinationOverride
|
||||
2, // 3: xray.proxy.freedom.Config.fragment:type_name -> xray.proxy.freedom.Fragment
|
||||
4, // [4:4] is the sub-list for method output_type
|
||||
4, // [4:4] is the sub-list for method input_type
|
||||
4, // [4:4] is the sub-list for extension type_name
|
||||
4, // [4:4] is the sub-list for extension extendee
|
||||
0, // [0:4] is the sub-list for field type_name
|
||||
3, // 4: xray.proxy.freedom.Config.noise:type_name -> xray.proxy.freedom.Noise
|
||||
5, // [5:5] is the sub-list for method output_type
|
||||
5, // [5:5] is the sub-list for method input_type
|
||||
5, // [5:5] is the sub-list for extension type_name
|
||||
5, // [5:5] is the sub-list for extension extendee
|
||||
0, // [0:5] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_proxy_freedom_config_proto_init() }
|
||||
@@ -424,7 +526,7 @@ func file_proxy_freedom_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_proxy_freedom_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_freedom_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*DestinationOverride); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -436,7 +538,7 @@ func file_proxy_freedom_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proxy_freedom_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_freedom_config_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Fragment); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -448,7 +550,19 @@ func file_proxy_freedom_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proxy_freedom_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_freedom_config_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Noise); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proxy_freedom_config_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -467,7 +581,7 @@ func file_proxy_freedom_config_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_proxy_freedom_config_proto_rawDesc,
|
||||
NumEnums: 1,
|
||||
NumMessages: 3,
|
||||
NumMessages: 4,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
@@ -20,6 +20,13 @@ message Fragment {
|
||||
uint64 interval_min = 5;
|
||||
uint64 interval_max = 6;
|
||||
}
|
||||
message Noise {
|
||||
uint64 length_min = 1;
|
||||
uint64 length_max = 2;
|
||||
uint64 delay_min = 3;
|
||||
uint64 delay_max = 4;
|
||||
string str_noise = 5;
|
||||
}
|
||||
|
||||
message Config {
|
||||
enum DomainStrategy {
|
||||
@@ -41,4 +48,5 @@ message Config {
|
||||
uint32 user_level = 4;
|
||||
Fragment fragment = 5;
|
||||
uint32 proxy_protocol = 6;
|
||||
Noise noise = 7;
|
||||
}
|
||||
|
@@ -208,6 +208,16 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
|
||||
}
|
||||
} else {
|
||||
writer = NewPacketWriter(conn, h, ctx, UDPOverride)
|
||||
if h.config.Noise != nil {
|
||||
errors.LogDebug(ctx, "NOISE", h.config.Noise.StrNoise, h.config.Noise.LengthMin, h.config.Noise.LengthMax,
|
||||
h.config.Noise.DelayMin, h.config.Noise.DelayMax)
|
||||
writer = &NoisePacketWriter{
|
||||
Writer: writer,
|
||||
noise: h.config.Noise,
|
||||
firstWrite: true,
|
||||
UDPOverride: UDPOverride,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := buf.Copy(input, writer, buf.UpdateActivity(timer)); err != nil {
|
||||
@@ -276,24 +286,24 @@ func NewPacketReader(conn net.Conn, UDPOverride net.Destination) buf.Reader {
|
||||
if statConn != nil {
|
||||
counter = statConn.ReadCounter
|
||||
}
|
||||
if c, ok := iConn.(*internet.PacketConnWrapper); ok && UDPOverride.Address == nil && UDPOverride.Port == 0 {
|
||||
if c, ok := iConn.(net.PacketConn); ok && UDPOverride.Address == nil && UDPOverride.Port == 0 {
|
||||
return &PacketReader{
|
||||
PacketConnWrapper: c,
|
||||
Counter: counter,
|
||||
PacketConn: c,
|
||||
Counter: counter,
|
||||
}
|
||||
}
|
||||
return &buf.PacketReader{Reader: conn}
|
||||
}
|
||||
|
||||
type PacketReader struct {
|
||||
*internet.PacketConnWrapper
|
||||
net.PacketConn
|
||||
stats.Counter
|
||||
}
|
||||
|
||||
func (r *PacketReader) ReadMultiBuffer() (buf.MultiBuffer, error) {
|
||||
b := buf.New()
|
||||
b.Resize(0, buf.Size)
|
||||
n, d, err := r.PacketConnWrapper.ReadFrom(b.Bytes())
|
||||
n, d, err := r.PacketConn.ReadFrom(b.Bytes())
|
||||
if err != nil {
|
||||
b.Release()
|
||||
return nil, err
|
||||
@@ -320,24 +330,27 @@ func NewPacketWriter(conn net.Conn, h *Handler, ctx context.Context, UDPOverride
|
||||
if statConn != nil {
|
||||
counter = statConn.WriteCounter
|
||||
}
|
||||
if c, ok := iConn.(*internet.PacketConnWrapper); ok {
|
||||
if c, ok := iConn.(net.PacketConn); ok {
|
||||
return &PacketWriter{
|
||||
PacketConnWrapper: c,
|
||||
Counter: counter,
|
||||
Handler: h,
|
||||
Context: ctx,
|
||||
UDPOverride: UDPOverride,
|
||||
PacketConn: c,
|
||||
Counter: counter,
|
||||
Handler: h,
|
||||
Context: ctx,
|
||||
UDPOverride: UDPOverride,
|
||||
Conn: iConn,
|
||||
}
|
||||
|
||||
}
|
||||
return &buf.SequentialWriter{Writer: conn}
|
||||
}
|
||||
|
||||
type PacketWriter struct {
|
||||
*internet.PacketConnWrapper
|
||||
net.PacketConn
|
||||
stats.Counter
|
||||
*Handler
|
||||
context.Context
|
||||
UDPOverride net.Destination
|
||||
Conn net.Conn
|
||||
}
|
||||
|
||||
func (w *PacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
|
||||
@@ -367,9 +380,9 @@ func (w *PacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
|
||||
b.Release()
|
||||
continue
|
||||
}
|
||||
n, err = w.PacketConnWrapper.WriteTo(b.Bytes(), destAddr)
|
||||
n, err = w.PacketConn.WriteTo(b.Bytes(), destAddr)
|
||||
} else {
|
||||
n, err = w.PacketConnWrapper.Write(b.Bytes())
|
||||
n, err = w.Conn.Write(b.Bytes())
|
||||
}
|
||||
b.Release()
|
||||
if err != nil {
|
||||
@@ -383,6 +396,45 @@ func (w *PacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type NoisePacketWriter struct {
|
||||
buf.Writer
|
||||
noise *Noise
|
||||
firstWrite bool
|
||||
UDPOverride net.Destination
|
||||
}
|
||||
|
||||
// MultiBuffer writer with Noise in first packet
|
||||
func (w *NoisePacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
|
||||
if w.firstWrite {
|
||||
w.firstWrite = false
|
||||
//Do not send Noise for dns requests(just to be safe)
|
||||
if w.UDPOverride.Port == 53 {
|
||||
return w.Writer.WriteMultiBuffer(mb)
|
||||
}
|
||||
var noise []byte
|
||||
var err error
|
||||
//User input string
|
||||
if w.noise.StrNoise != "" {
|
||||
noise = []byte(w.noise.StrNoise)
|
||||
} else {
|
||||
//Random noise
|
||||
noise, err = GenerateRandomBytes(randBetween(int64(w.noise.LengthMin),
|
||||
int64(w.noise.LengthMax)))
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
w.Writer.WriteMultiBuffer(buf.MultiBuffer{buf.FromBytes(noise)})
|
||||
|
||||
if w.noise.DelayMin != 0 {
|
||||
time.Sleep(time.Duration(randBetween(int64(w.noise.DelayMin), int64(w.noise.DelayMax))) * time.Millisecond)
|
||||
}
|
||||
|
||||
}
|
||||
return w.Writer.WriteMultiBuffer(mb)
|
||||
}
|
||||
|
||||
type FragmentWriter struct {
|
||||
fragment *Fragment
|
||||
writer io.Writer
|
||||
@@ -402,6 +454,7 @@ func (f *FragmentWriter) Write(b []byte) (int, error) {
|
||||
}
|
||||
data := b[5:recordLen]
|
||||
buf := make([]byte, 1024)
|
||||
var hello []byte
|
||||
for from := 0; ; {
|
||||
to := from + int(randBetween(int64(f.fragment.LengthMin), int64(f.fragment.LengthMax)))
|
||||
if to > len(data) {
|
||||
@@ -413,12 +466,22 @@ func (f *FragmentWriter) Write(b []byte) (int, error) {
|
||||
from = to
|
||||
buf[3] = byte(l >> 8)
|
||||
buf[4] = byte(l)
|
||||
_, err := f.writer.Write(buf[:5+l])
|
||||
time.Sleep(time.Duration(randBetween(int64(f.fragment.IntervalMin), int64(f.fragment.IntervalMax))) * time.Millisecond)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
if f.fragment.IntervalMax == 0 { // combine fragmented tlshello if interval is 0
|
||||
hello = append(hello, buf[:5+l]...)
|
||||
} else {
|
||||
_, err := f.writer.Write(buf[:5+l])
|
||||
time.Sleep(time.Duration(randBetween(int64(f.fragment.IntervalMin), int64(f.fragment.IntervalMax))) * time.Millisecond)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
if from == len(data) {
|
||||
if len(hello) > 0 {
|
||||
_, err := f.writer.Write(hello)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
if len(b) > recordLen {
|
||||
n, err := f.writer.Write(b[recordLen:])
|
||||
if err != nil {
|
||||
@@ -458,3 +521,13 @@ func randBetween(left int64, right int64) int64 {
|
||||
bigInt, _ := rand.Int(rand.Reader, big.NewInt(right-left))
|
||||
return left + bigInt.Int64()
|
||||
}
|
||||
func GenerateRandomBytes(n int64) ([]byte, error) {
|
||||
b := make([]byte, n)
|
||||
_, err := rand.Read(b)
|
||||
// Note that err == nil only if we read len(b) bytes.
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return b, nil
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: proxy/http/config.proto
|
||||
|
||||
@@ -322,7 +322,7 @@ func file_proxy_http_config_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_proxy_http_config_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
|
||||
var file_proxy_http_config_proto_goTypes = []interface{}{
|
||||
var file_proxy_http_config_proto_goTypes = []any{
|
||||
(*Account)(nil), // 0: xray.proxy.http.Account
|
||||
(*ServerConfig)(nil), // 1: xray.proxy.http.ServerConfig
|
||||
(*Header)(nil), // 2: xray.proxy.http.Header
|
||||
@@ -347,7 +347,7 @@ func file_proxy_http_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_proxy_http_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_http_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Account); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -359,7 +359,7 @@ func file_proxy_http_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proxy_http_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_http_config_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ServerConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -371,7 +371,7 @@ func file_proxy_http_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proxy_http_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_http_config_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Header); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -383,7 +383,7 @@ func file_proxy_http_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proxy_http_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_http_config_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ClientConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -2,6 +2,7 @@ package http
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"io"
|
||||
@@ -83,14 +84,28 @@ type readerOnly struct {
|
||||
}
|
||||
|
||||
func (s *Server) Process(ctx context.Context, network net.Network, conn stat.Connection, dispatcher routing.Dispatcher) error {
|
||||
return s.ProcessWithFirstbyte(ctx, network, conn, dispatcher)
|
||||
}
|
||||
|
||||
// Firstbyte is for forwarded conn from SOCKS inbound
|
||||
// Because it needs first byte to choose protocol
|
||||
// We need to add it back
|
||||
// Other parts are the same as the process function
|
||||
func (s *Server) ProcessWithFirstbyte(ctx context.Context, network net.Network, conn stat.Connection, dispatcher routing.Dispatcher, firstbyte ...byte) error {
|
||||
inbound := session.InboundFromContext(ctx)
|
||||
inbound.Name = "http"
|
||||
inbound.CanSpliceCopy = 2
|
||||
inbound.User = &protocol.MemoryUser{
|
||||
Level: s.config.UserLevel,
|
||||
}
|
||||
|
||||
reader := bufio.NewReaderSize(readerOnly{conn}, buf.Size)
|
||||
var reader *bufio.Reader
|
||||
if len(firstbyte) > 0 {
|
||||
readerWithoutFirstbyte := bufio.NewReaderSize(readerOnly{conn}, buf.Size)
|
||||
multiReader := io.MultiReader(bytes.NewReader(firstbyte), readerWithoutFirstbyte)
|
||||
reader = bufio.NewReaderSize(multiReader, buf.Size)
|
||||
} else {
|
||||
reader = bufio.NewReaderSize(readerOnly{conn}, buf.Size)
|
||||
}
|
||||
|
||||
Start:
|
||||
if err := conn.SetReadDeadline(time.Now().Add(s.policy().Timeouts.Handshake)); err != nil {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: proxy/loopback/config.proto
|
||||
|
||||
@@ -98,7 +98,7 @@ func file_proxy_loopback_config_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_proxy_loopback_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_proxy_loopback_config_proto_goTypes = []interface{}{
|
||||
var file_proxy_loopback_config_proto_goTypes = []any{
|
||||
(*Config)(nil), // 0: xray.proxy.loopback.Config
|
||||
}
|
||||
var file_proxy_loopback_config_proto_depIdxs = []int32{
|
||||
@@ -115,7 +115,7 @@ func file_proxy_loopback_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_proxy_loopback_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_loopback_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -319,7 +319,7 @@ func XtlsPadding(b *buf.Buffer, command byte, userUUID *[]byte, longPadding bool
|
||||
|
||||
// XtlsUnpadding remove padding and parse command
|
||||
func XtlsUnpadding(b *buf.Buffer, s *TrafficState, ctx context.Context) *buf.Buffer {
|
||||
if s.RemainingCommand == -1 && s.RemainingContent == -1 && s.RemainingPadding == -1 { // inital state
|
||||
if s.RemainingCommand == -1 && s.RemainingContent == -1 && s.RemainingPadding == -1 { // initial state
|
||||
if b.Len() >= 21 && bytes.Equal(s.UserUUID, b.BytesTo(16)) {
|
||||
b.Advance(16)
|
||||
s.RemainingCommand = 5
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: proxy/shadowsocks/config.proto
|
||||
|
||||
@@ -309,7 +309,7 @@ func file_proxy_shadowsocks_config_proto_rawDescGZIP() []byte {
|
||||
|
||||
var file_proxy_shadowsocks_config_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_proxy_shadowsocks_config_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_proxy_shadowsocks_config_proto_goTypes = []interface{}{
|
||||
var file_proxy_shadowsocks_config_proto_goTypes = []any{
|
||||
(CipherType)(0), // 0: xray.proxy.shadowsocks.CipherType
|
||||
(*Account)(nil), // 1: xray.proxy.shadowsocks.Account
|
||||
(*ServerConfig)(nil), // 2: xray.proxy.shadowsocks.ServerConfig
|
||||
@@ -336,7 +336,7 @@ func file_proxy_shadowsocks_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_proxy_shadowsocks_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_shadowsocks_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Account); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -348,7 +348,7 @@ func file_proxy_shadowsocks_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proxy_shadowsocks_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_shadowsocks_config_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ServerConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -360,7 +360,7 @@ func file_proxy_shadowsocks_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proxy_shadowsocks_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_shadowsocks_config_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ClientConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: proxy/shadowsocks_2022/config.proto
|
||||
|
||||
@@ -566,7 +566,7 @@ func file_proxy_shadowsocks_2022_config_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_proxy_shadowsocks_2022_config_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
|
||||
var file_proxy_shadowsocks_2022_config_proto_goTypes = []interface{}{
|
||||
var file_proxy_shadowsocks_2022_config_proto_goTypes = []any{
|
||||
(*ServerConfig)(nil), // 0: xray.proxy.shadowsocks_2022.ServerConfig
|
||||
(*MultiUserServerConfig)(nil), // 1: xray.proxy.shadowsocks_2022.MultiUserServerConfig
|
||||
(*RelayDestination)(nil), // 2: xray.proxy.shadowsocks_2022.RelayDestination
|
||||
@@ -597,7 +597,7 @@ func file_proxy_shadowsocks_2022_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_proxy_shadowsocks_2022_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_shadowsocks_2022_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ServerConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -609,7 +609,7 @@ func file_proxy_shadowsocks_2022_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proxy_shadowsocks_2022_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_shadowsocks_2022_config_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*MultiUserServerConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -621,7 +621,7 @@ func file_proxy_shadowsocks_2022_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proxy_shadowsocks_2022_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_shadowsocks_2022_config_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*RelayDestination); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -633,7 +633,7 @@ func file_proxy_shadowsocks_2022_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proxy_shadowsocks_2022_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_shadowsocks_2022_config_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*RelayServerConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -645,7 +645,7 @@ func file_proxy_shadowsocks_2022_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proxy_shadowsocks_2022_config_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_shadowsocks_2022_config_proto_msgTypes[4].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*User); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -657,7 +657,7 @@ func file_proxy_shadowsocks_2022_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proxy_shadowsocks_2022_config_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_shadowsocks_2022_config_proto_msgTypes[5].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ClientConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: proxy/socks/config.proto
|
||||
|
||||
@@ -395,7 +395,7 @@ func file_proxy_socks_config_proto_rawDescGZIP() []byte {
|
||||
|
||||
var file_proxy_socks_config_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
|
||||
var file_proxy_socks_config_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||
var file_proxy_socks_config_proto_goTypes = []interface{}{
|
||||
var file_proxy_socks_config_proto_goTypes = []any{
|
||||
(AuthType)(0), // 0: xray.proxy.socks.AuthType
|
||||
(Version)(0), // 1: xray.proxy.socks.Version
|
||||
(*Account)(nil), // 2: xray.proxy.socks.Account
|
||||
@@ -424,7 +424,7 @@ func file_proxy_socks_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_proxy_socks_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_socks_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Account); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -436,7 +436,7 @@ func file_proxy_socks_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proxy_socks_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_socks_config_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ServerConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -448,7 +448,7 @@ func file_proxy_socks_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proxy_socks_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_socks_config_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ClientConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -74,7 +74,7 @@ func (s *ServerSession) handshake4(cmd byte, reader io.Reader, writer io.Writer)
|
||||
if err != nil {
|
||||
return nil, errors.New("failed to read domain for socks 4a").Base(err)
|
||||
}
|
||||
address = net.DomainAddress(domain)
|
||||
address = net.ParseAddress(domain)
|
||||
}
|
||||
|
||||
switch cmd {
|
||||
|
@@ -19,6 +19,7 @@ import (
|
||||
"github.com/xtls/xray-core/features"
|
||||
"github.com/xtls/xray-core/features/policy"
|
||||
"github.com/xtls/xray-core/features/routing"
|
||||
"github.com/xtls/xray-core/proxy/http"
|
||||
"github.com/xtls/xray-core/transport/internet/stat"
|
||||
"github.com/xtls/xray-core/transport/internet/udp"
|
||||
)
|
||||
@@ -29,6 +30,7 @@ type Server struct {
|
||||
policyManager policy.Manager
|
||||
cone bool
|
||||
udpFilter *UDPFilter
|
||||
httpServer *http.Server
|
||||
}
|
||||
|
||||
// NewServer creates a new Server object.
|
||||
@@ -39,9 +41,14 @@ func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) {
|
||||
policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager),
|
||||
cone: ctx.Value("cone").(bool),
|
||||
}
|
||||
httpConfig := &http.ServerConfig{
|
||||
UserLevel: config.UserLevel,
|
||||
}
|
||||
if config.AuthType == AuthType_PASSWORD {
|
||||
httpConfig.Accounts = config.Accounts
|
||||
s.udpFilter = new(UDPFilter) // We only use this when auth is enabled
|
||||
}
|
||||
s.httpServer, _ = http.NewServer(ctx, httpConfig)
|
||||
return s, nil
|
||||
}
|
||||
|
||||
@@ -77,7 +84,13 @@ func (s *Server) Process(ctx context.Context, network net.Network, conn stat.Con
|
||||
|
||||
switch network {
|
||||
case net.Network_TCP:
|
||||
return s.processTCP(ctx, conn, dispatcher)
|
||||
firstbyte := make([]byte, 1)
|
||||
conn.Read(firstbyte)
|
||||
if firstbyte[0] != 5 && firstbyte[0] != 4 { // Check if it is Socks5/4/4a
|
||||
errors.LogDebug(ctx, "Not Socks request, try to parse as HTTP request")
|
||||
return s.httpServer.ProcessWithFirstbyte(ctx, network, conn, dispatcher, firstbyte...)
|
||||
}
|
||||
return s.processTCP(ctx, conn, dispatcher, firstbyte)
|
||||
case net.Network_UDP:
|
||||
return s.handleUDPPayload(ctx, conn, dispatcher)
|
||||
default:
|
||||
@@ -85,7 +98,7 @@ func (s *Server) Process(ctx context.Context, network net.Network, conn stat.Con
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) processTCP(ctx context.Context, conn stat.Connection, dispatcher routing.Dispatcher) error {
|
||||
func (s *Server) processTCP(ctx context.Context, conn stat.Connection, dispatcher routing.Dispatcher, firstbyte []byte) error {
|
||||
plcy := s.policy()
|
||||
if err := conn.SetReadDeadline(time.Now().Add(plcy.Timeouts.Handshake)); err != nil {
|
||||
errors.LogInfoInner(ctx, err, "failed to set deadline")
|
||||
@@ -103,7 +116,13 @@ func (s *Server) processTCP(ctx context.Context, conn stat.Connection, dispatche
|
||||
localAddress: net.IPAddress(conn.LocalAddr().(*net.TCPAddr).IP),
|
||||
}
|
||||
|
||||
reader := &buf.BufferedReader{Reader: buf.NewReader(conn)}
|
||||
// Firstbyte is for forwarded conn from SOCKS inbound
|
||||
// Because it needs first byte to choose protocol
|
||||
// We need to add it back
|
||||
reader := &buf.BufferedReader{
|
||||
Reader: buf.NewReader(conn),
|
||||
Buffer: buf.MultiBuffer{buf.FromBytes(firstbyte)},
|
||||
}
|
||||
request, err := svrSession.Handshake(reader, conn)
|
||||
if err != nil {
|
||||
if inbound.Source.IsValid() {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: proxy/trojan/config.proto
|
||||
|
||||
@@ -312,7 +312,7 @@ func file_proxy_trojan_config_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_proxy_trojan_config_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||
var file_proxy_trojan_config_proto_goTypes = []interface{}{
|
||||
var file_proxy_trojan_config_proto_goTypes = []any{
|
||||
(*Account)(nil), // 0: xray.proxy.trojan.Account
|
||||
(*Fallback)(nil), // 1: xray.proxy.trojan.Fallback
|
||||
(*ClientConfig)(nil), // 2: xray.proxy.trojan.ClientConfig
|
||||
@@ -337,7 +337,7 @@ func file_proxy_trojan_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_proxy_trojan_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_trojan_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Account); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -349,7 +349,7 @@ func file_proxy_trojan_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proxy_trojan_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_trojan_config_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Fallback); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -361,7 +361,7 @@ func file_proxy_trojan_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proxy_trojan_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_trojan_config_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ClientConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -373,7 +373,7 @@ func file_proxy_trojan_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proxy_trojan_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_trojan_config_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ServerConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: proxy/vless/account.proto
|
||||
|
||||
@@ -118,7 +118,7 @@ func file_proxy_vless_account_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_proxy_vless_account_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_proxy_vless_account_proto_goTypes = []interface{}{
|
||||
var file_proxy_vless_account_proto_goTypes = []any{
|
||||
(*Account)(nil), // 0: xray.proxy.vless.Account
|
||||
}
|
||||
var file_proxy_vless_account_proto_depIdxs = []int32{
|
||||
@@ -135,7 +135,7 @@ func file_proxy_vless_account_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_proxy_vless_account_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_vless_account_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Account); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: proxy/vless/encoding/addons.proto
|
||||
|
||||
@@ -108,7 +108,7 @@ func file_proxy_vless_encoding_addons_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_proxy_vless_encoding_addons_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_proxy_vless_encoding_addons_proto_goTypes = []interface{}{
|
||||
var file_proxy_vless_encoding_addons_proto_goTypes = []any{
|
||||
(*Addons)(nil), // 0: xray.proxy.vless.encoding.Addons
|
||||
}
|
||||
var file_proxy_vless_encoding_addons_proto_depIdxs = []int32{
|
||||
@@ -125,7 +125,7 @@ func file_proxy_vless_encoding_addons_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_proxy_vless_encoding_addons_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_vless_encoding_addons_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Addons); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: proxy/vless/inbound/config.proto
|
||||
|
||||
@@ -223,7 +223,7 @@ func file_proxy_vless_inbound_config_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_proxy_vless_inbound_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_proxy_vless_inbound_config_proto_goTypes = []interface{}{
|
||||
var file_proxy_vless_inbound_config_proto_goTypes = []any{
|
||||
(*Fallback)(nil), // 0: xray.proxy.vless.inbound.Fallback
|
||||
(*Config)(nil), // 1: xray.proxy.vless.inbound.Config
|
||||
(*protocol.User)(nil), // 2: xray.common.protocol.User
|
||||
@@ -244,7 +244,7 @@ func file_proxy_vless_inbound_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_proxy_vless_inbound_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_vless_inbound_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Fallback); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -256,7 +256,7 @@ func file_proxy_vless_inbound_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proxy_vless_inbound_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_vless_inbound_config_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: proxy/vless/outbound/config.proto
|
||||
|
||||
@@ -104,7 +104,7 @@ func file_proxy_vless_outbound_config_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_proxy_vless_outbound_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_proxy_vless_outbound_config_proto_goTypes = []interface{}{
|
||||
var file_proxy_vless_outbound_config_proto_goTypes = []any{
|
||||
(*Config)(nil), // 0: xray.proxy.vless.outbound.Config
|
||||
(*protocol.ServerEndpoint)(nil), // 1: xray.common.protocol.ServerEndpoint
|
||||
}
|
||||
@@ -123,7 +123,7 @@ func file_proxy_vless_outbound_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_proxy_vless_outbound_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_vless_outbound_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: proxy/vmess/account.proto
|
||||
|
||||
@@ -126,7 +126,7 @@ func file_proxy_vmess_account_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_proxy_vmess_account_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_proxy_vmess_account_proto_goTypes = []interface{}{
|
||||
var file_proxy_vmess_account_proto_goTypes = []any{
|
||||
(*Account)(nil), // 0: xray.proxy.vmess.Account
|
||||
(*protocol.SecurityConfig)(nil), // 1: xray.common.protocol.SecurityConfig
|
||||
}
|
||||
@@ -145,7 +145,7 @@ func file_proxy_vmess_account_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_proxy_vmess_account_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_vmess_account_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Account); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: proxy/vmess/inbound/config.proto
|
||||
|
||||
@@ -226,7 +226,7 @@ func file_proxy_vmess_inbound_config_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_proxy_vmess_inbound_config_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_proxy_vmess_inbound_config_proto_goTypes = []interface{}{
|
||||
var file_proxy_vmess_inbound_config_proto_goTypes = []any{
|
||||
(*DetourConfig)(nil), // 0: xray.proxy.vmess.inbound.DetourConfig
|
||||
(*DefaultConfig)(nil), // 1: xray.proxy.vmess.inbound.DefaultConfig
|
||||
(*Config)(nil), // 2: xray.proxy.vmess.inbound.Config
|
||||
@@ -249,7 +249,7 @@ func file_proxy_vmess_inbound_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_proxy_vmess_inbound_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_vmess_inbound_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*DetourConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -261,7 +261,7 @@ func file_proxy_vmess_inbound_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proxy_vmess_inbound_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_vmess_inbound_config_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*DefaultConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -273,7 +273,7 @@ func file_proxy_vmess_inbound_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proxy_vmess_inbound_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_vmess_inbound_config_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: proxy/vmess/outbound/config.proto
|
||||
|
||||
@@ -105,7 +105,7 @@ func file_proxy_vmess_outbound_config_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_proxy_vmess_outbound_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_proxy_vmess_outbound_config_proto_goTypes = []interface{}{
|
||||
var file_proxy_vmess_outbound_config_proto_goTypes = []any{
|
||||
(*Config)(nil), // 0: xray.proxy.vmess.outbound.Config
|
||||
(*protocol.ServerEndpoint)(nil), // 1: xray.common.protocol.ServerEndpoint
|
||||
}
|
||||
@@ -124,7 +124,7 @@ func file_proxy_vmess_outbound_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_proxy_vmess_outbound_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_vmess_outbound_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: proxy/wireguard/config.proto
|
||||
|
||||
@@ -334,7 +334,7 @@ func file_proxy_wireguard_config_proto_rawDescGZIP() []byte {
|
||||
|
||||
var file_proxy_wireguard_config_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_proxy_wireguard_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_proxy_wireguard_config_proto_goTypes = []interface{}{
|
||||
var file_proxy_wireguard_config_proto_goTypes = []any{
|
||||
(DeviceConfig_DomainStrategy)(0), // 0: xray.proxy.wireguard.DeviceConfig.DomainStrategy
|
||||
(*PeerConfig)(nil), // 1: xray.proxy.wireguard.PeerConfig
|
||||
(*DeviceConfig)(nil), // 2: xray.proxy.wireguard.DeviceConfig
|
||||
@@ -355,7 +355,7 @@ func file_proxy_wireguard_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_proxy_wireguard_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_wireguard_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*PeerConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -367,7 +367,7 @@ func file_proxy_wireguard_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proxy_wireguard_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proxy_wireguard_config_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*DeviceConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -200,6 +200,9 @@ func createKernelTun(localAddresses []netip.Addr, mtu int, handler promiscuousMo
|
||||
r := netlink.NewRule()
|
||||
r.Table, r.Family, r.Src = ipv6TableIndex, unix.AF_INET6, addr.IPNet
|
||||
out.rules = append(out.rules, r)
|
||||
r = netlink.NewRule()
|
||||
r.Table, r.Family, r.OifName = ipv6TableIndex, unix.AF_INET6, n
|
||||
out.rules = append(out.rules, r)
|
||||
}
|
||||
|
||||
for _, addr := range out.linkAddrs {
|
||||
|
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/xtls/xray-core/proxy/blackhole"
|
||||
"github.com/xtls/xray-core/proxy/dokodemo"
|
||||
"github.com/xtls/xray-core/proxy/freedom"
|
||||
"github.com/xtls/xray-core/proxy/http"
|
||||
"github.com/xtls/xray-core/proxy/socks"
|
||||
"github.com/xtls/xray-core/testing/servers/tcp"
|
||||
"github.com/xtls/xray-core/testing/servers/udp"
|
||||
@@ -102,6 +103,87 @@ func TestSocksBridgeTCP(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSocksWithHttpRequest(t *testing.T) {
|
||||
tcpServer := tcp.Server{
|
||||
MsgProcessor: xor,
|
||||
}
|
||||
dest, err := tcpServer.Start()
|
||||
common.Must(err)
|
||||
defer tcpServer.Close()
|
||||
|
||||
serverPort := tcp.PickPort()
|
||||
serverConfig := &core.Config{
|
||||
Inbound: []*core.InboundHandlerConfig{
|
||||
{
|
||||
ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{
|
||||
PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}},
|
||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||
}),
|
||||
ProxySettings: serial.ToTypedMessage(&socks.ServerConfig{
|
||||
AuthType: socks.AuthType_PASSWORD,
|
||||
Accounts: map[string]string{
|
||||
"Test Account": "Test Password",
|
||||
},
|
||||
Address: net.NewIPOrDomain(net.LocalHostIP),
|
||||
UdpEnabled: false,
|
||||
}),
|
||||
},
|
||||
},
|
||||
Outbound: []*core.OutboundHandlerConfig{
|
||||
{
|
||||
ProxySettings: serial.ToTypedMessage(&freedom.Config{}),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
clientPort := tcp.PickPort()
|
||||
clientConfig := &core.Config{
|
||||
Inbound: []*core.InboundHandlerConfig{
|
||||
{
|
||||
ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{
|
||||
PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(clientPort)}},
|
||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||
}),
|
||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||
Address: net.NewIPOrDomain(dest.Address),
|
||||
Port: uint32(dest.Port),
|
||||
NetworkList: &net.NetworkList{
|
||||
Network: []net.Network{net.Network_TCP},
|
||||
},
|
||||
}),
|
||||
},
|
||||
},
|
||||
Outbound: []*core.OutboundHandlerConfig{
|
||||
{
|
||||
ProxySettings: serial.ToTypedMessage(&http.ClientConfig{
|
||||
Server: []*protocol.ServerEndpoint{
|
||||
{
|
||||
Address: net.NewIPOrDomain(net.LocalHostIP),
|
||||
Port: uint32(serverPort),
|
||||
User: []*protocol.User{
|
||||
{
|
||||
Account: serial.ToTypedMessage(&http.Account{
|
||||
Username: "Test Account",
|
||||
Password: "Test Password",
|
||||
}),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
common.Must(err)
|
||||
defer CloseAllServers(servers)
|
||||
|
||||
if err := testTCPConn(clientPort, 1024, time.Second*2)(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSocksBridageUDP(t *testing.T) {
|
||||
udpServer := udp.Server{
|
||||
MsgProcessor: xor,
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: transport/global/config.proto
|
||||
|
||||
@@ -109,7 +109,7 @@ func file_transport_global_config_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_transport_global_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_transport_global_config_proto_goTypes = []interface{}{
|
||||
var file_transport_global_config_proto_goTypes = []any{
|
||||
(*Config)(nil), // 0: xray.transport.Config
|
||||
(*internet.TransportConfig)(nil), // 1: xray.transport.internet.TransportConfig
|
||||
}
|
||||
@@ -128,7 +128,7 @@ func file_transport_global_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_transport_global_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_transport_global_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: transport/internet/config.proto
|
||||
|
||||
@@ -863,7 +863,7 @@ func file_transport_internet_config_proto_rawDescGZIP() []byte {
|
||||
|
||||
var file_transport_internet_config_proto_enumTypes = make([]protoimpl.EnumInfo, 3)
|
||||
var file_transport_internet_config_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
|
||||
var file_transport_internet_config_proto_goTypes = []interface{}{
|
||||
var file_transport_internet_config_proto_goTypes = []any{
|
||||
(TransportProtocol)(0), // 0: xray.transport.internet.TransportProtocol
|
||||
(DomainStrategy)(0), // 1: xray.transport.internet.DomainStrategy
|
||||
(SocketConfig_TProxyMode)(0), // 2: xray.transport.internet.SocketConfig.TProxyMode
|
||||
@@ -897,7 +897,7 @@ func file_transport_internet_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_transport_internet_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_transport_internet_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*TransportConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -909,7 +909,7 @@ func file_transport_internet_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_transport_internet_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_transport_internet_config_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*StreamConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -921,7 +921,7 @@ func file_transport_internet_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_transport_internet_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_transport_internet_config_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ProxyConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -933,7 +933,7 @@ func file_transport_internet_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_transport_internet_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_transport_internet_config_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*CustomSockopt); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -945,7 +945,7 @@ func file_transport_internet_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_transport_internet_config_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_transport_internet_config_proto_msgTypes[4].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*SocketConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -111,7 +111,7 @@ func canLookupIP(ctx context.Context, dst net.Destination, sockopt *SocketConfig
|
||||
}
|
||||
|
||||
func redirect(ctx context.Context, dst net.Destination, obt string) net.Conn {
|
||||
errors.LogInfo(ctx, "redirecting request " + dst.String() + " to " + obt)
|
||||
errors.LogInfo(ctx, "redirecting request "+dst.String()+" to "+obt)
|
||||
h := obm.GetHandler(obt)
|
||||
outbounds := session.OutboundsFromContext(ctx)
|
||||
ctx = session.ContextWithOutbounds(ctx, append(outbounds, &session.Outbound{
|
||||
@@ -123,10 +123,16 @@ func redirect(ctx context.Context, dst net.Destination, obt string) net.Conn {
|
||||
ur, uw := pipe.New(pipe.OptionsFromContext(ctx)...)
|
||||
dr, dw := pipe.New(pipe.OptionsFromContext(ctx)...)
|
||||
|
||||
go h.Dispatch(ctx, &transport.Link{Reader: ur, Writer: dw})
|
||||
go h.Dispatch(context.WithoutCancel(ctx), &transport.Link{Reader: ur, Writer: dw})
|
||||
var readerOpt cnc.ConnectionOption
|
||||
if dst.Network == net.Network_TCP {
|
||||
readerOpt = cnc.ConnectionOutputMulti(dr)
|
||||
} else {
|
||||
readerOpt = cnc.ConnectionOutputMultiUDP(dr)
|
||||
}
|
||||
nc := cnc.NewConnection(
|
||||
cnc.ConnectionInputMulti(uw),
|
||||
cnc.ConnectionOutputMulti(dr),
|
||||
readerOpt,
|
||||
cnc.ConnectionOnClose(common.ChainedClosable{uw, dw}),
|
||||
)
|
||||
return nc
|
||||
@@ -150,7 +156,7 @@ func DialSystem(ctx context.Context, dest net.Destination, sockopt *SocketConfig
|
||||
ips, err := lookupIP(dest.Address.String(), sockopt.DomainStrategy, src)
|
||||
if err == nil && len(ips) > 0 {
|
||||
dest.Address = net.IPAddress(ips[dice.Roll(len(ips))])
|
||||
errors.LogInfo(ctx, "replace destination with " + dest.String())
|
||||
errors.LogInfo(ctx, "replace destination with "+dest.String())
|
||||
} else if err != nil {
|
||||
errors.LogWarningInner(ctx, err, "failed to resolve ip")
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: transport/internet/domainsocket/config.proto
|
||||
|
||||
@@ -129,7 +129,7 @@ func file_transport_internet_domainsocket_config_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_transport_internet_domainsocket_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_transport_internet_domainsocket_config_proto_goTypes = []interface{}{
|
||||
var file_transport_internet_domainsocket_config_proto_goTypes = []any{
|
||||
(*Config)(nil), // 0: xray.transport.internet.domainsocket.Config
|
||||
}
|
||||
var file_transport_internet_domainsocket_config_proto_depIdxs = []int32{
|
||||
@@ -146,7 +146,7 @@ func file_transport_internet_domainsocket_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_transport_internet_domainsocket_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_transport_internet_domainsocket_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: transport/internet/grpc/config.proto
|
||||
|
||||
@@ -170,7 +170,7 @@ func file_transport_internet_grpc_config_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_transport_internet_grpc_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_transport_internet_grpc_config_proto_goTypes = []interface{}{
|
||||
var file_transport_internet_grpc_config_proto_goTypes = []any{
|
||||
(*Config)(nil), // 0: xray.transport.internet.grpc.encoding.Config
|
||||
}
|
||||
var file_transport_internet_grpc_config_proto_depIdxs = []int32{
|
||||
@@ -187,7 +187,7 @@ func file_transport_internet_grpc_config_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_transport_internet_grpc_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_transport_internet_grpc_config_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -34,7 +34,7 @@ func (c *gRPCServiceClient) TunCustomName(ctx context.Context, name, tun string,
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &gRPCServiceTunClient{stream}
|
||||
x := &grpc.GenericClientStream[Hunk, Hunk]{ClientStream: stream}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ func (c *gRPCServiceClient) TunMultiCustomName(ctx context.Context, name, tunMul
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &gRPCServiceTunMultiClient{stream}
|
||||
x := &grpc.GenericClientStream[MultiHunk, MultiHunk]{ClientStream: stream}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.0
|
||||
// source: transport/internet/grpc/encoding/stream.proto
|
||||
|
||||
@@ -161,7 +161,7 @@ func file_transport_internet_grpc_encoding_stream_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_transport_internet_grpc_encoding_stream_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_transport_internet_grpc_encoding_stream_proto_goTypes = []interface{}{
|
||||
var file_transport_internet_grpc_encoding_stream_proto_goTypes = []any{
|
||||
(*Hunk)(nil), // 0: xray.transport.internet.grpc.encoding.Hunk
|
||||
(*MultiHunk)(nil), // 1: xray.transport.internet.grpc.encoding.MultiHunk
|
||||
}
|
||||
@@ -183,7 +183,7 @@ func file_transport_internet_grpc_encoding_stream_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_transport_internet_grpc_encoding_stream_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_transport_internet_grpc_encoding_stream_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Hunk); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -195,7 +195,7 @@ func file_transport_internet_grpc_encoding_stream_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_transport_internet_grpc_encoding_stream_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_transport_internet_grpc_encoding_stream_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*MultiHunk); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.3.0
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc v5.27.0
|
||||
// source: transport/internet/grpc/encoding/stream.proto
|
||||
|
||||
@@ -15,8 +15,8 @@ import (
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
GRPCService_Tun_FullMethodName = "/xray.transport.internet.grpc.encoding.GRPCService/Tun"
|
||||
@@ -27,8 +27,8 @@ const (
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type GRPCServiceClient interface {
|
||||
Tun(ctx context.Context, opts ...grpc.CallOption) (GRPCService_TunClient, error)
|
||||
TunMulti(ctx context.Context, opts ...grpc.CallOption) (GRPCService_TunMultiClient, error)
|
||||
Tun(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[Hunk, Hunk], error)
|
||||
TunMulti(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[MultiHunk, MultiHunk], error)
|
||||
}
|
||||
|
||||
type gRPCServiceClient struct {
|
||||
@@ -39,88 +39,56 @@ func NewGRPCServiceClient(cc grpc.ClientConnInterface) GRPCServiceClient {
|
||||
return &gRPCServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *gRPCServiceClient) Tun(ctx context.Context, opts ...grpc.CallOption) (GRPCService_TunClient, error) {
|
||||
stream, err := c.cc.NewStream(ctx, &GRPCService_ServiceDesc.Streams[0], GRPCService_Tun_FullMethodName, opts...)
|
||||
func (c *gRPCServiceClient) Tun(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[Hunk, Hunk], error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
stream, err := c.cc.NewStream(ctx, &GRPCService_ServiceDesc.Streams[0], GRPCService_Tun_FullMethodName, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &gRPCServiceTunClient{stream}
|
||||
x := &grpc.GenericClientStream[Hunk, Hunk]{ClientStream: stream}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
type GRPCService_TunClient interface {
|
||||
Send(*Hunk) error
|
||||
Recv() (*Hunk, error)
|
||||
grpc.ClientStream
|
||||
}
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type GRPCService_TunClient = grpc.BidiStreamingClient[Hunk, Hunk]
|
||||
|
||||
type gRPCServiceTunClient struct {
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
func (x *gRPCServiceTunClient) Send(m *Hunk) error {
|
||||
return x.ClientStream.SendMsg(m)
|
||||
}
|
||||
|
||||
func (x *gRPCServiceTunClient) Recv() (*Hunk, error) {
|
||||
m := new(Hunk)
|
||||
if err := x.ClientStream.RecvMsg(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (c *gRPCServiceClient) TunMulti(ctx context.Context, opts ...grpc.CallOption) (GRPCService_TunMultiClient, error) {
|
||||
stream, err := c.cc.NewStream(ctx, &GRPCService_ServiceDesc.Streams[1], GRPCService_TunMulti_FullMethodName, opts...)
|
||||
func (c *gRPCServiceClient) TunMulti(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[MultiHunk, MultiHunk], error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
stream, err := c.cc.NewStream(ctx, &GRPCService_ServiceDesc.Streams[1], GRPCService_TunMulti_FullMethodName, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &gRPCServiceTunMultiClient{stream}
|
||||
x := &grpc.GenericClientStream[MultiHunk, MultiHunk]{ClientStream: stream}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
type GRPCService_TunMultiClient interface {
|
||||
Send(*MultiHunk) error
|
||||
Recv() (*MultiHunk, error)
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
type gRPCServiceTunMultiClient struct {
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
func (x *gRPCServiceTunMultiClient) Send(m *MultiHunk) error {
|
||||
return x.ClientStream.SendMsg(m)
|
||||
}
|
||||
|
||||
func (x *gRPCServiceTunMultiClient) Recv() (*MultiHunk, error) {
|
||||
m := new(MultiHunk)
|
||||
if err := x.ClientStream.RecvMsg(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type GRPCService_TunMultiClient = grpc.BidiStreamingClient[MultiHunk, MultiHunk]
|
||||
|
||||
// GRPCServiceServer is the server API for GRPCService service.
|
||||
// All implementations must embed UnimplementedGRPCServiceServer
|
||||
// for forward compatibility
|
||||
// for forward compatibility.
|
||||
type GRPCServiceServer interface {
|
||||
Tun(GRPCService_TunServer) error
|
||||
TunMulti(GRPCService_TunMultiServer) error
|
||||
Tun(grpc.BidiStreamingServer[Hunk, Hunk]) error
|
||||
TunMulti(grpc.BidiStreamingServer[MultiHunk, MultiHunk]) error
|
||||
mustEmbedUnimplementedGRPCServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedGRPCServiceServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedGRPCServiceServer struct {
|
||||
}
|
||||
// UnimplementedGRPCServiceServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedGRPCServiceServer struct{}
|
||||
|
||||
func (UnimplementedGRPCServiceServer) Tun(GRPCService_TunServer) error {
|
||||
func (UnimplementedGRPCServiceServer) Tun(grpc.BidiStreamingServer[Hunk, Hunk]) error {
|
||||
return status.Errorf(codes.Unimplemented, "method Tun not implemented")
|
||||
}
|
||||
func (UnimplementedGRPCServiceServer) TunMulti(GRPCService_TunMultiServer) error {
|
||||
func (UnimplementedGRPCServiceServer) TunMulti(grpc.BidiStreamingServer[MultiHunk, MultiHunk]) error {
|
||||
return status.Errorf(codes.Unimplemented, "method TunMulti not implemented")
|
||||
}
|
||||
func (UnimplementedGRPCServiceServer) mustEmbedUnimplementedGRPCServiceServer() {}
|
||||
func (UnimplementedGRPCServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeGRPCServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to GRPCServiceServer will
|
||||
@@ -130,60 +98,29 @@ type UnsafeGRPCServiceServer interface {
|
||||
}
|
||||
|
||||
func RegisterGRPCServiceServer(s grpc.ServiceRegistrar, srv GRPCServiceServer) {
|
||||
// If the following call pancis, it indicates UnimplementedGRPCServiceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&GRPCService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _GRPCService_Tun_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
return srv.(GRPCServiceServer).Tun(&gRPCServiceTunServer{stream})
|
||||
return srv.(GRPCServiceServer).Tun(&grpc.GenericServerStream[Hunk, Hunk]{ServerStream: stream})
|
||||
}
|
||||
|
||||
type GRPCService_TunServer interface {
|
||||
Send(*Hunk) error
|
||||
Recv() (*Hunk, error)
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
type gRPCServiceTunServer struct {
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
func (x *gRPCServiceTunServer) Send(m *Hunk) error {
|
||||
return x.ServerStream.SendMsg(m)
|
||||
}
|
||||
|
||||
func (x *gRPCServiceTunServer) Recv() (*Hunk, error) {
|
||||
m := new(Hunk)
|
||||
if err := x.ServerStream.RecvMsg(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type GRPCService_TunServer = grpc.BidiStreamingServer[Hunk, Hunk]
|
||||
|
||||
func _GRPCService_TunMulti_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
return srv.(GRPCServiceServer).TunMulti(&gRPCServiceTunMultiServer{stream})
|
||||
return srv.(GRPCServiceServer).TunMulti(&grpc.GenericServerStream[MultiHunk, MultiHunk]{ServerStream: stream})
|
||||
}
|
||||
|
||||
type GRPCService_TunMultiServer interface {
|
||||
Send(*MultiHunk) error
|
||||
Recv() (*MultiHunk, error)
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
type gRPCServiceTunMultiServer struct {
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
func (x *gRPCServiceTunMultiServer) Send(m *MultiHunk) error {
|
||||
return x.ServerStream.SendMsg(m)
|
||||
}
|
||||
|
||||
func (x *gRPCServiceTunMultiServer) Recv() (*MultiHunk, error) {
|
||||
m := new(MultiHunk)
|
||||
if err := x.ServerStream.RecvMsg(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type GRPCService_TunMultiServer = grpc.BidiStreamingServer[MultiHunk, MultiHunk]
|
||||
|
||||
// GRPCService_ServiceDesc is the grpc.ServiceDesc for GRPCService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user