mirror of
https://github.com/XrayR-project/XrayR.git
synced 2025-08-08 10:21:47 +00:00
Compare commits
29 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
09f27ec1f1 | ||
![]() |
61b501de3d | ||
![]() |
9947d7e4f3 | ||
![]() |
a0e1491bb5 | ||
![]() |
b31bef02da | ||
![]() |
25594bf9e2 | ||
![]() |
1566ffd937 | ||
![]() |
5682ab37db | ||
![]() |
454afe5285 | ||
![]() |
807a7182bb | ||
![]() |
911d06bece | ||
![]() |
7f823007cb | ||
![]() |
943660ee56 | ||
![]() |
8195f72eaa | ||
![]() |
35a6585db1 | ||
![]() |
f0911f6239 | ||
![]() |
afc11dbb41 | ||
![]() |
e1b0cd3c79 | ||
![]() |
6ce4d4e7a2 | ||
![]() |
febeee6b2c | ||
![]() |
fbe57822ce | ||
![]() |
63697586a2 | ||
![]() |
6b6e2a03d8 | ||
![]() |
674445afae | ||
![]() |
bf29bd11c4 | ||
![]() |
40ba9b202b | ||
![]() |
39a09bea92 | ||
![]() |
5c0eea8d44 | ||
![]() |
69b0afcb35 |
18
.github/workflows/docker.yml
vendored
18
.github/workflows/docker.yml
vendored
@@ -2,8 +2,13 @@ name: Publish Docker image
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
tags:
|
||||
- 'v*'
|
||||
pull_request:
|
||||
branches:
|
||||
- 'master'
|
||||
jobs:
|
||||
push_to_registry:
|
||||
name: Push Docker image to Docker Hub
|
||||
@@ -13,13 +18,10 @@ jobs:
|
||||
uses: actions/checkout@v2
|
||||
-
|
||||
name: Docker meta
|
||||
id: docker_meta
|
||||
uses: crazy-max/ghaction-docker-meta@v1
|
||||
id: meta
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: crackair/xrayr
|
||||
tag-semver: |
|
||||
{{version}}
|
||||
{{major}}.{{minor}}
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
@@ -34,7 +36,7 @@ jobs:
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/arm/v7,linux/arm64,linux/amd64
|
||||
platforms: linux/arm/v7,linux/arm64,linux/amd64,linux/s390x
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.docker_meta.outputs.tags }}
|
||||
labels: ${{ steps.docker_meta.outputs.labels }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
3
.github/workflows/release.yml
vendored
3
.github/workflows/release.yml
vendored
@@ -113,7 +113,7 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ^1.17.2
|
||||
go-version: ^1.18
|
||||
|
||||
- name: Get project dependencies
|
||||
run: go mod download
|
||||
@@ -141,6 +141,7 @@ jobs:
|
||||
cp ${GITHUB_WORKSPACE}/main/dns.json ./build_assets/dns.json
|
||||
cp ${GITHUB_WORKSPACE}/main/route.json ./build_assets/route.json
|
||||
cp ${GITHUB_WORKSPACE}/main/custom_outbound.json ./build_assets/custom_outbound.json
|
||||
cp ${GITHUB_WORKSPACE}/main/custom_inbound.json ./build_assets/custom_inbound.json
|
||||
cp ${GITHUB_WORKSPACE}/main/rulelist ./build_assets/rulelist
|
||||
cp ${GITHUB_WORKSPACE}/main/config.yml.example ./build_assets/config.yml
|
||||
LIST=('geoip geoip geoip' 'domain-list-community dlc geosite')
|
||||
|
20
.github/workflows/sync.yml
vendored
Normal file
20
.github/workflows/sync.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
name: Sync to Gitlab
|
||||
|
||||
on:
|
||||
push:
|
||||
delete:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
to_gitlab:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: pixta-dev/repository-mirroring-action@v1
|
||||
with:
|
||||
target_repo_url:
|
||||
git@gitlab.com:xrayr-project/XrayR.git
|
||||
ssh_private_key:
|
||||
${{ secrets.SSH_PRIVATEKEY }}
|
@@ -1,5 +1,5 @@
|
||||
# Build go
|
||||
FROM golang:1.17-alpine AS builder
|
||||
FROM golang:1.18-alpine AS builder
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
ENV CGO_ENABLED=0
|
||||
|
@@ -52,7 +52,7 @@ A Xray backend framework that can easily support many panels.
|
||||
## 软件安装
|
||||
### 一键安装
|
||||
```
|
||||
bash <(curl -Ls https://raw.githubusercontent.com/XrayR-project/XrayR-release/master/install.sh)
|
||||
wget -N https://raw.githubusercontent.com/XrayR-project/XrayR-release/master/install.sh && bash install.sh
|
||||
```
|
||||
### 使用Docker部署软件
|
||||
[Docker部署教程](https://crackair.gitbook.io/xrayr-project/xrayr-xia-zai-he-an-zhuang/install/docker)
|
||||
|
@@ -1,8 +1,8 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.26.0
|
||||
// protoc-gen-go v1.28.0
|
||||
// protoc v3.19.4
|
||||
// source: config.proto
|
||||
// source: app/mydispatcher/config.proto
|
||||
|
||||
package mydispatcher
|
||||
|
||||
@@ -29,7 +29,7 @@ type SessionConfig struct {
|
||||
func (x *SessionConfig) Reset() {
|
||||
*x = SessionConfig{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_config_proto_msgTypes[0]
|
||||
mi := &file_app_mydispatcher_config_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -42,7 +42,7 @@ func (x *SessionConfig) String() string {
|
||||
func (*SessionConfig) ProtoMessage() {}
|
||||
|
||||
func (x *SessionConfig) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_config_proto_msgTypes[0]
|
||||
mi := &file_app_mydispatcher_config_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -55,7 +55,7 @@ func (x *SessionConfig) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use SessionConfig.ProtoReflect.Descriptor instead.
|
||||
func (*SessionConfig) Descriptor() ([]byte, []int) {
|
||||
return file_config_proto_rawDescGZIP(), []int{0}
|
||||
return file_app_mydispatcher_config_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
@@ -69,7 +69,7 @@ type Config struct {
|
||||
func (x *Config) Reset() {
|
||||
*x = Config{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_config_proto_msgTypes[1]
|
||||
mi := &file_app_mydispatcher_config_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -82,7 +82,7 @@ func (x *Config) String() string {
|
||||
func (*Config) ProtoMessage() {}
|
||||
|
||||
func (x *Config) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_config_proto_msgTypes[1]
|
||||
mi := &file_app_mydispatcher_config_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -95,7 +95,7 @@ func (x *Config) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use Config.ProtoReflect.Descriptor instead.
|
||||
func (*Config) Descriptor() ([]byte, []int) {
|
||||
return file_config_proto_rawDescGZIP(), []int{1}
|
||||
return file_app_mydispatcher_config_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *Config) GetSettings() *SessionConfig {
|
||||
@@ -105,45 +105,46 @@ func (x *Config) GetSettings() *SessionConfig {
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_config_proto protoreflect.FileDescriptor
|
||||
var File_app_mydispatcher_config_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_config_proto_rawDesc = []byte{
|
||||
0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x16,
|
||||
0x78, 0x72, 0x61, 0x79, 0x72, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6d, 0x79, 0x64, 0x69, 0x73, 0x70,
|
||||
0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x22, 0x15, 0x0a, 0x0d, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f,
|
||||
0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x22, 0x4b, 0x0a,
|
||||
0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x41, 0x0a, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69,
|
||||
0x6e, 0x67, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79,
|
||||
0x72, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6d, 0x79, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68,
|
||||
0x65, 0x72, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67,
|
||||
0x52, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x42, 0x67, 0x0a, 0x1a, 0x63, 0x6f,
|
||||
0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x72, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6d, 0x79, 0x64, 0x69,
|
||||
0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x50, 0x01, 0x5a, 0x2f, 0x67, 0x69, 0x74, 0x68,
|
||||
0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x58, 0x72, 0x61, 0x79, 0x52, 0x2d, 0x70, 0x72, 0x6f,
|
||||
0x6a, 0x65, 0x63, 0x74, 0x2f, 0x58, 0x72, 0x61, 0x79, 0x52, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x6d,
|
||||
0x79, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0xaa, 0x02, 0x15, 0x58, 0x72,
|
||||
0x61, 0x79, 0x52, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x4d, 0x79, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63,
|
||||
0x68, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
var file_app_mydispatcher_config_proto_rawDesc = []byte{
|
||||
0x0a, 0x1d, 0x61, 0x70, 0x70, 0x2f, 0x6d, 0x79, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68,
|
||||
0x65, 0x72, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
|
||||
0x16, 0x78, 0x72, 0x61, 0x79, 0x72, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6d, 0x79, 0x64, 0x69, 0x73,
|
||||
0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x22, 0x15, 0x0a, 0x0d, 0x53, 0x65, 0x73, 0x73, 0x69,
|
||||
0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x22, 0x4b,
|
||||
0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x41, 0x0a, 0x08, 0x73, 0x65, 0x74, 0x74,
|
||||
0x69, 0x6e, 0x67, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x72, 0x61,
|
||||
0x79, 0x72, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6d, 0x79, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63,
|
||||
0x68, 0x65, 0x72, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69,
|
||||
0x67, 0x52, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x42, 0x67, 0x0a, 0x1a, 0x63,
|
||||
0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x72, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6d, 0x79, 0x64,
|
||||
0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x50, 0x01, 0x5a, 0x2f, 0x67, 0x69, 0x74,
|
||||
0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x58, 0x72, 0x61, 0x79, 0x52, 0x2d, 0x70, 0x72,
|
||||
0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x58, 0x72, 0x61, 0x79, 0x52, 0x2f, 0x61, 0x70, 0x70, 0x2f,
|
||||
0x6d, 0x79, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0xaa, 0x02, 0x15, 0x58,
|
||||
0x72, 0x61, 0x79, 0x52, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x4d, 0x79, 0x69, 0x73, 0x70, 0x61, 0x74,
|
||||
0x63, 0x68, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_config_proto_rawDescOnce sync.Once
|
||||
file_config_proto_rawDescData = file_config_proto_rawDesc
|
||||
file_app_mydispatcher_config_proto_rawDescOnce sync.Once
|
||||
file_app_mydispatcher_config_proto_rawDescData = file_app_mydispatcher_config_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_config_proto_rawDescGZIP() []byte {
|
||||
file_config_proto_rawDescOnce.Do(func() {
|
||||
file_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_config_proto_rawDescData)
|
||||
func file_app_mydispatcher_config_proto_rawDescGZIP() []byte {
|
||||
file_app_mydispatcher_config_proto_rawDescOnce.Do(func() {
|
||||
file_app_mydispatcher_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_app_mydispatcher_config_proto_rawDescData)
|
||||
})
|
||||
return file_config_proto_rawDescData
|
||||
return file_app_mydispatcher_config_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_config_proto_goTypes = []interface{}{
|
||||
var file_app_mydispatcher_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_app_mydispatcher_config_proto_goTypes = []interface{}{
|
||||
(*SessionConfig)(nil), // 0: xrayr.app.mydispatcher.SessionConfig
|
||||
(*Config)(nil), // 1: xrayr.app.mydispatcher.Config
|
||||
}
|
||||
var file_config_proto_depIdxs = []int32{
|
||||
var file_app_mydispatcher_config_proto_depIdxs = []int32{
|
||||
0, // 0: xrayr.app.mydispatcher.Config.settings:type_name -> xrayr.app.mydispatcher.SessionConfig
|
||||
1, // [1:1] is the sub-list for method output_type
|
||||
1, // [1:1] is the sub-list for method input_type
|
||||
@@ -152,13 +153,13 @@ var file_config_proto_depIdxs = []int32{
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_config_proto_init() }
|
||||
func file_config_proto_init() {
|
||||
if File_config_proto != nil {
|
||||
func init() { file_app_mydispatcher_config_proto_init() }
|
||||
func file_app_mydispatcher_config_proto_init() {
|
||||
if File_app_mydispatcher_config_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_mydispatcher_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*SessionConfig); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -170,7 +171,7 @@ func file_config_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_app_mydispatcher_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Config); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -187,18 +188,18 @@ func file_config_proto_init() {
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_config_proto_rawDesc,
|
||||
RawDescriptor: file_app_mydispatcher_config_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 2,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_config_proto_goTypes,
|
||||
DependencyIndexes: file_config_proto_depIdxs,
|
||||
MessageInfos: file_config_proto_msgTypes,
|
||||
GoTypes: file_app_mydispatcher_config_proto_goTypes,
|
||||
DependencyIndexes: file_app_mydispatcher_config_proto_depIdxs,
|
||||
MessageInfos: file_app_mydispatcher_config_proto_msgTypes,
|
||||
}.Build()
|
||||
File_config_proto = out.File
|
||||
file_config_proto_rawDesc = nil
|
||||
file_config_proto_goTypes = nil
|
||||
file_config_proto_depIdxs = nil
|
||||
File_app_mydispatcher_config_proto = out.File
|
||||
file_app_mydispatcher_config_proto_rawDesc = nil
|
||||
file_app_mydispatcher_config_proto_goTypes = nil
|
||||
file_app_mydispatcher_config_proto_depIdxs = nil
|
||||
}
|
||||
|
@@ -95,7 +95,8 @@ type DefaultDispatcher struct {
|
||||
router routing.Router
|
||||
policy policy.Manager
|
||||
stats stats.Manager
|
||||
hosts dns.HostsLookup
|
||||
dns dns.Client
|
||||
fdns dns.FakeDNSEngine
|
||||
Limiter *limiter.Limiter
|
||||
RuleManager *rule.RuleManager
|
||||
}
|
||||
@@ -104,6 +105,9 @@ func init() {
|
||||
common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) {
|
||||
d := new(DefaultDispatcher)
|
||||
if err := core.RequireFeatures(ctx, func(om outbound.Manager, router routing.Router, pm policy.Manager, sm stats.Manager, dc dns.Client) error {
|
||||
core.RequireFeatures(ctx, func(fdns dns.FakeDNSEngine) {
|
||||
d.fdns = fdns
|
||||
})
|
||||
return d.Init(config.(*Config), om, router, pm, sm, dc)
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
@@ -113,16 +117,14 @@ func init() {
|
||||
}
|
||||
|
||||
// Init initializes DefaultDispatcher.
|
||||
func (d *DefaultDispatcher) Init(config *Config, om outbound.Manager, router routing.Router, pm policy.Manager, sm stats.Manager, dc dns.Client) error {
|
||||
func (d *DefaultDispatcher) Init(config *Config, om outbound.Manager, router routing.Router, pm policy.Manager, sm stats.Manager, dns dns.Client) error {
|
||||
d.ohm = om
|
||||
d.router = router
|
||||
d.policy = pm
|
||||
d.stats = sm
|
||||
d.Limiter = limiter.New()
|
||||
d.RuleManager = rule.New()
|
||||
if hosts, ok := dc.(dns.HostsLookup); ok {
|
||||
d.hosts = hosts
|
||||
}
|
||||
d.dns = dns
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -139,10 +141,77 @@ func (*DefaultDispatcher) Start() error {
|
||||
// Close implements common.Closable.
|
||||
func (*DefaultDispatcher) Close() error { return nil }
|
||||
|
||||
func (d *DefaultDispatcher) getLink(ctx context.Context) (*transport.Link, *transport.Link, error) {
|
||||
opt := pipe.OptionsFromContext(ctx)
|
||||
uplinkReader, uplinkWriter := pipe.New(opt...)
|
||||
downlinkReader, downlinkWriter := pipe.New(opt...)
|
||||
func (d *DefaultDispatcher) getLink(ctx context.Context, network net.Network, sniffing session.SniffingRequest) (*transport.Link, *transport.Link, error) {
|
||||
downOpt := pipe.OptionsFromContext(ctx)
|
||||
upOpt := downOpt
|
||||
|
||||
if network == net.Network_UDP {
|
||||
var ip2domain *sync.Map // net.IP.String() => domain, this map is used by server side when client turn on fakedns
|
||||
// Client will send domain address in the buffer.UDP.Address, server record all possible target IP addrs.
|
||||
// When target replies, server will restore the domain and send back to client.
|
||||
// Note: this map is not global but per connection context
|
||||
upOpt = append(upOpt, pipe.OnTransmission(func(mb buf.MultiBuffer) buf.MultiBuffer {
|
||||
for i, buffer := range mb {
|
||||
if buffer.UDP == nil {
|
||||
continue
|
||||
}
|
||||
addr := buffer.UDP.Address
|
||||
if addr.Family().IsIP() {
|
||||
if fkr0, ok := d.fdns.(dns.FakeDNSEngineRev0); ok && fkr0.IsIPInIPPool(addr) && sniffing.Enabled {
|
||||
domain := fkr0.GetDomainFromFakeDNS(addr)
|
||||
if len(domain) > 0 {
|
||||
buffer.UDP.Address = net.DomainAddress(domain)
|
||||
newError("[fakedns client] override with domain: ", domain, " for xUDP buffer at ", i).WriteToLog(session.ExportIDToError(ctx))
|
||||
} else {
|
||||
newError("[fakedns client] failed to find domain! :", addr.String(), " for xUDP buffer at ", i).AtWarning().WriteToLog(session.ExportIDToError(ctx))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ip2domain == nil {
|
||||
ip2domain = new(sync.Map)
|
||||
newError("[fakedns client] create a new map").WriteToLog(session.ExportIDToError(ctx))
|
||||
}
|
||||
domain := addr.Domain()
|
||||
ips, err := d.dns.LookupIP(domain, dns.IPOption{true, true, false})
|
||||
if err == nil {
|
||||
for _, ip := range ips {
|
||||
ip2domain.Store(ip.String(), domain)
|
||||
}
|
||||
newError("[fakedns client] candidate ip: "+fmt.Sprintf("%v", ips), " for xUDP buffer at ", i).WriteToLog(session.ExportIDToError(ctx))
|
||||
} else {
|
||||
newError("[fakedns client] failed to look up IP for ", domain, " for xUDP buffer at ", i).Base(err).WriteToLog(session.ExportIDToError(ctx))
|
||||
}
|
||||
}
|
||||
}
|
||||
return mb
|
||||
}))
|
||||
downOpt = append(downOpt, pipe.OnTransmission(func(mb buf.MultiBuffer) buf.MultiBuffer {
|
||||
for i, buffer := range mb {
|
||||
if buffer.UDP == nil {
|
||||
continue
|
||||
}
|
||||
addr := buffer.UDP.Address
|
||||
if addr.Family().IsIP() {
|
||||
if ip2domain == nil {
|
||||
continue
|
||||
}
|
||||
if domain, found := ip2domain.Load(addr.IP().String()); found {
|
||||
buffer.UDP.Address = net.DomainAddress(domain.(string))
|
||||
newError("[fakedns client] restore domain: ", domain.(string), " for xUDP buffer at ", i).WriteToLog(session.ExportIDToError(ctx))
|
||||
}
|
||||
} else {
|
||||
if fkr0, ok := d.fdns.(dns.FakeDNSEngineRev0); ok {
|
||||
fakeIp := fkr0.GetFakeIPForDomain(addr.Domain())
|
||||
buffer.UDP.Address = fakeIp[0]
|
||||
newError("[fakedns client] restore FakeIP: ", buffer.UDP, fmt.Sprintf("%v", fakeIp), " for xUDP buffer at ", i).WriteToLog(session.ExportIDToError(ctx))
|
||||
}
|
||||
}
|
||||
}
|
||||
return mb
|
||||
}))
|
||||
}
|
||||
uplinkReader, uplinkWriter := pipe.New(upOpt...)
|
||||
downlinkReader, downlinkWriter := pipe.New(downOpt...)
|
||||
|
||||
inboundLink := &transport.Link{
|
||||
Reader: downlinkReader,
|
||||
@@ -199,17 +268,13 @@ func (d *DefaultDispatcher) getLink(ctx context.Context) (*transport.Link, *tran
|
||||
return inboundLink, outboundLink, nil
|
||||
}
|
||||
|
||||
func shouldOverride(ctx context.Context, result SniffResult, request session.SniffingRequest, destination net.Destination) bool {
|
||||
func (d *DefaultDispatcher) shouldOverride(ctx context.Context, result SniffResult, request session.SniffingRequest, destination net.Destination) bool {
|
||||
domain := result.Domain()
|
||||
for _, d := range request.ExcludeForDomain {
|
||||
if strings.ToLower(domain) == d {
|
||||
return false
|
||||
}
|
||||
}
|
||||
var fakeDNSEngine dns.FakeDNSEngine
|
||||
core.RequireFeatures(ctx, func(fdns dns.FakeDNSEngine) {
|
||||
fakeDNSEngine = fdns
|
||||
})
|
||||
protocolString := result.Protocol()
|
||||
if resComp, ok := result.(SnifferResultComposite); ok {
|
||||
protocolString = resComp.ProtocolForDomainResult()
|
||||
@@ -218,7 +283,7 @@ func shouldOverride(ctx context.Context, result SniffResult, request session.Sni
|
||||
if strings.HasPrefix(protocolString, p) {
|
||||
return true
|
||||
}
|
||||
if fkr0, ok := fakeDNSEngine.(dns.FakeDNSEngineRev0); ok && protocolString != "bittorrent" && p == "fakedns" &&
|
||||
if fkr0, ok := d.fdns.(dns.FakeDNSEngineRev0); ok && protocolString != "bittorrent" && p == "fakedns" &&
|
||||
destination.Address.Family().IsIP() && fkr0.IsIPInIPPool(destination.Address) {
|
||||
newError("Using sniffer ", protocolString, " since the fake DNS missed").WriteToLog(session.ExportIDToError(ctx))
|
||||
return true
|
||||
@@ -242,17 +307,17 @@ func (d *DefaultDispatcher) Dispatch(ctx context.Context, destination net.Destin
|
||||
Target: destination,
|
||||
}
|
||||
ctx = session.ContextWithOutbound(ctx, ob)
|
||||
|
||||
inbound, outbound, err := d.getLink(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
content := session.ContentFromContext(ctx)
|
||||
if content == nil {
|
||||
content = new(session.Content)
|
||||
ctx = session.ContextWithContent(ctx, content)
|
||||
}
|
||||
|
||||
sniffingRequest := content.SniffingRequest
|
||||
inbound, outbound, err := d.getLink(ctx, destination.Network, sniffingRequest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch {
|
||||
case !sniffingRequest.Enabled:
|
||||
go d.routedDispatch(ctx, outbound, destination)
|
||||
@@ -261,7 +326,7 @@ func (d *DefaultDispatcher) Dispatch(ctx context.Context, destination net.Destin
|
||||
result, err := sniffer(ctx, nil, true)
|
||||
if err == nil {
|
||||
content.Protocol = result.Protocol()
|
||||
if shouldOverride(ctx, result, sniffingRequest, destination) {
|
||||
if d.shouldOverride(ctx, result, sniffingRequest, destination) {
|
||||
domain := result.Domain()
|
||||
newError("sniffed domain: ", domain).WriteToLog(session.ExportIDToError(ctx))
|
||||
destination.Address = net.ParseAddress(domain)
|
||||
@@ -283,7 +348,7 @@ func (d *DefaultDispatcher) Dispatch(ctx context.Context, destination net.Destin
|
||||
if err == nil {
|
||||
content.Protocol = result.Protocol()
|
||||
}
|
||||
if err == nil && shouldOverride(ctx, result, sniffingRequest, destination) {
|
||||
if err == nil && d.shouldOverride(ctx, result, sniffingRequest, destination) {
|
||||
domain := result.Domain()
|
||||
newError("sniffed domain: ", domain).WriteToLog(session.ExportIDToError(ctx))
|
||||
destination.Address = net.ParseAddress(domain)
|
||||
@@ -322,7 +387,7 @@ func (d *DefaultDispatcher) DispatchLink(ctx context.Context, destination net.De
|
||||
result, err := sniffer(ctx, nil, true)
|
||||
if err == nil {
|
||||
content.Protocol = result.Protocol()
|
||||
if shouldOverride(ctx, result, sniffingRequest, destination) {
|
||||
if d.shouldOverride(ctx, result, sniffingRequest, destination) {
|
||||
domain := result.Domain()
|
||||
newError("sniffed domain: ", domain).WriteToLog(session.ExportIDToError(ctx))
|
||||
destination.Address = net.ParseAddress(domain)
|
||||
@@ -344,7 +409,7 @@ func (d *DefaultDispatcher) DispatchLink(ctx context.Context, destination net.De
|
||||
if err == nil {
|
||||
content.Protocol = result.Protocol()
|
||||
}
|
||||
if err == nil && shouldOverride(ctx, result, sniffingRequest, destination) {
|
||||
if err == nil && d.shouldOverride(ctx, result, sniffingRequest, destination) {
|
||||
domain := result.Domain()
|
||||
newError("sniffed domain: ", domain).WriteToLog(session.ExportIDToError(ctx))
|
||||
destination.Address = net.ParseAddress(domain)
|
||||
@@ -408,8 +473,8 @@ func sniffer(ctx context.Context, cReader *cachedReader, metadataOnly bool) (Sni
|
||||
|
||||
func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport.Link, destination net.Destination) {
|
||||
ob := session.OutboundFromContext(ctx)
|
||||
if d.hosts != nil && destination.Address.Family().IsDomain() {
|
||||
proxied := d.hosts.LookupHosts(ob.Target.String())
|
||||
if hosts, ok := d.dns.(dns.HostsLookup); ok && destination.Address.Family().IsDomain() {
|
||||
proxied := hosts.LookupHosts(ob.Target.String())
|
||||
if proxied != nil {
|
||||
ro := ob.RouteTarget == destination
|
||||
destination.Address = *proxied
|
||||
@@ -438,10 +503,11 @@ func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport.
|
||||
|
||||
routingLink := routing_session.AsRoutingContext(ctx)
|
||||
inTag := routingLink.GetInboundTag()
|
||||
|
||||
isPickRoute := 0
|
||||
if forcedOutboundTag := session.GetForcedOutboundTagFromContext(ctx); forcedOutboundTag != "" {
|
||||
ctx = session.SetForcedOutboundTagToContext(ctx, "")
|
||||
if h := d.ohm.GetHandler(forcedOutboundTag); h != nil {
|
||||
isPickRoute = 1
|
||||
newError("taking platform initialized detour [", forcedOutboundTag, "] for [", destination, "]").WriteToLog(session.ExportIDToError(ctx))
|
||||
handler = h
|
||||
} else {
|
||||
@@ -451,13 +517,14 @@ func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport.
|
||||
return
|
||||
}
|
||||
} else if d.router != nil {
|
||||
if route, err := d.router.PickRoute(routing_session.AsRoutingContext(ctx)); err == nil {
|
||||
tag := route.GetOutboundTag()
|
||||
if h := d.ohm.GetHandler(tag); h != nil {
|
||||
newError("taking detour [", tag, "] for [", destination, "]").WriteToLog(session.ExportIDToError(ctx))
|
||||
if route, err := d.router.PickRoute(routingLink); err == nil {
|
||||
outTag := route.GetOutboundTag()
|
||||
if h := d.ohm.GetHandler(outTag); h != nil {
|
||||
isPickRoute = 2
|
||||
newError("taking detour [", outTag, "] for [", destination, "]").WriteToLog(session.ExportIDToError(ctx))
|
||||
handler = h
|
||||
} else {
|
||||
newError("non existing outTag: ", tag).AtWarning().WriteToLog(session.ExportIDToError(ctx))
|
||||
newError("non existing outTag: ", outTag).AtWarning().WriteToLog(session.ExportIDToError(ctx))
|
||||
}
|
||||
} else {
|
||||
newError("default route for ", destination).WriteToLog(session.ExportIDToError(ctx))
|
||||
@@ -482,7 +549,15 @@ func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport.
|
||||
|
||||
if accessMessage := log.AccessMessageFromContext(ctx); accessMessage != nil {
|
||||
if tag := handler.Tag(); tag != "" {
|
||||
accessMessage.Detour = tag
|
||||
if inTag == "" {
|
||||
accessMessage.Detour = tag
|
||||
} else if isPickRoute == 1 {
|
||||
accessMessage.Detour = inTag + " ==> " + tag
|
||||
} else if isPickRoute == 2 {
|
||||
accessMessage.Detour = inTag + " -> " + tag
|
||||
} else {
|
||||
accessMessage.Detour = inTag + " >> " + tag
|
||||
}
|
||||
}
|
||||
log.Record(accessMessage)
|
||||
}
|
||||
|
@@ -14,12 +14,13 @@ import (
|
||||
// newFakeDNSSniffer Create a Fake DNS metadata sniffer
|
||||
func newFakeDNSSniffer(ctx context.Context) (protocolSnifferWithMetadata, error) {
|
||||
var fakeDNSEngine dns.FakeDNSEngine
|
||||
err := core.RequireFeatures(ctx, func(fdns dns.FakeDNSEngine) {
|
||||
fakeDNSEngine = fdns
|
||||
})
|
||||
if err != nil {
|
||||
return protocolSnifferWithMetadata{}, err
|
||||
{
|
||||
fakeDNSEngineFeat := core.MustFromContext(ctx).GetFeature((*dns.FakeDNSEngine)(nil))
|
||||
if fakeDNSEngineFeat != nil {
|
||||
fakeDNSEngine = fakeDNSEngineFeat.(dns.FakeDNSEngine)
|
||||
}
|
||||
}
|
||||
|
||||
if fakeDNSEngine == nil {
|
||||
errNotInit := newError("FakeDNSEngine is not initialized, but such a sniffer is used").AtError()
|
||||
return protocolSnifferWithMetadata{}, errNotInit
|
||||
|
115
go.mod
115
go.mod
@@ -1,36 +1,36 @@
|
||||
module github.com/XrayR-project/XrayR
|
||||
|
||||
go 1.17
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/bitly/go-simplejson v0.5.0
|
||||
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect
|
||||
github.com/deckarep/golang-set v1.8.0
|
||||
github.com/fsnotify/fsnotify v1.5.4
|
||||
github.com/go-acme/lego/v4 v4.6.0
|
||||
github.com/go-acme/lego/v4 v4.7.0
|
||||
github.com/go-ole/go-ole v1.2.6 // indirect
|
||||
github.com/go-resty/resty/v2 v2.7.0
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/imdario/mergo v0.3.12
|
||||
github.com/imdario/mergo v0.3.13
|
||||
github.com/juju/ratelimit v1.0.1
|
||||
github.com/r3labs/diff/v2 v2.15.1
|
||||
github.com/shirou/gopsutil v3.21.11+incompatible
|
||||
github.com/spf13/viper v1.11.0
|
||||
github.com/stretchr/testify v1.7.1
|
||||
github.com/spf13/viper v1.12.0
|
||||
github.com/stretchr/testify v1.8.0
|
||||
github.com/tklauser/go-sysconf v0.3.10 // indirect
|
||||
github.com/urfave/cli v1.22.7
|
||||
github.com/xtls/xray-core v1.5.5
|
||||
golang.org/x/net v0.0.0-20220421235706-1d1ef9303861
|
||||
github.com/urfave/cli v1.22.9
|
||||
github.com/xtls/xray-core v1.5.9
|
||||
golang.org/x/net v0.0.0-20220708220712-1185a9018129
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/protobuf v1.28.0
|
||||
)
|
||||
|
||||
require (
|
||||
cloud.google.com/go/compute v1.5.0 // indirect
|
||||
github.com/Azure/azure-sdk-for-go v62.0.0+incompatible // indirect
|
||||
cloud.google.com/go/compute v1.6.1 // indirect
|
||||
github.com/Azure/azure-sdk-for-go v65.0.0+incompatible // indirect
|
||||
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
|
||||
github.com/Azure/go-autorest/autorest v0.11.24 // indirect
|
||||
github.com/Azure/go-autorest/autorest/adal v0.9.18 // indirect
|
||||
github.com/Azure/go-autorest/autorest v0.11.27 // indirect
|
||||
github.com/Azure/go-autorest/autorest/adal v0.9.20 // indirect
|
||||
github.com/Azure/go-autorest/autorest/azure/auth v0.5.11 // indirect
|
||||
github.com/Azure/go-autorest/autorest/azure/cli v0.4.5 // indirect
|
||||
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
|
||||
@@ -40,17 +40,17 @@ require (
|
||||
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
|
||||
github.com/OpenDNS/vegadns2client v0.0.0-20180418235048-a3fa4a771d87 // indirect
|
||||
github.com/akamai/AkamaiOPEN-edgegrid-golang v1.1.1 // indirect
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v1.61.1505 // indirect
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v1.61.1621 // indirect
|
||||
github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 // indirect
|
||||
github.com/aws/aws-sdk-go v1.43.12 // indirect
|
||||
github.com/aws/aws-sdk-go v1.44.26 // indirect
|
||||
github.com/boombuler/barcode v1.0.1 // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.1.2 // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
|
||||
github.com/cheekybits/genny v1.0.0 // indirect
|
||||
github.com/cloudflare/cloudflare-go v0.34.0 // indirect
|
||||
github.com/cloudflare/cloudflare-go v0.40.0 // indirect
|
||||
github.com/cpu/goacmedns v0.1.1 // indirect
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/deepmap/oapi-codegen v1.9.1 // indirect
|
||||
github.com/deepmap/oapi-codegen v1.11.0 // indirect
|
||||
github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 // indirect
|
||||
github.com/dimchansky/utfbom v1.1.1 // indirect
|
||||
github.com/dnsimple/dnsimple-go v0.71.1 // indirect
|
||||
@@ -61,39 +61,42 @@ require (
|
||||
github.com/go-errors/errors v1.4.2 // indirect
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
|
||||
github.com/gofrs/uuid v4.2.0+incompatible // indirect
|
||||
github.com/golang-jwt/jwt/v4 v4.3.0 // indirect
|
||||
github.com/golang-jwt/jwt/v4 v4.4.1 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
github.com/google/go-querystring v1.1.0 // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/googleapis/gax-go/v2 v2.3.0 // indirect
|
||||
github.com/gophercloud/gophercloud v0.24.0 // indirect
|
||||
github.com/gophercloud/utils v0.0.0-20220209210848-d0ab9f2a8909 // indirect
|
||||
github.com/googleapis/gax-go/v2 v2.4.0 // indirect
|
||||
github.com/gophercloud/gophercloud v0.25.0 // indirect
|
||||
github.com/gophercloud/utils v0.0.0-20220307143606-8e7800759d16 // indirect
|
||||
github.com/gorilla/websocket v1.5.0 // indirect
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||
github.com/hashicorp/go-retryablehttp v0.7.0 // indirect
|
||||
github.com/hashicorp/go-retryablehttp v0.7.1 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/iij/doapi v0.0.0-20190504054126-0bbf12d6d7df // indirect
|
||||
github.com/infobloxopen/infoblox-go-client v1.1.1 // indirect
|
||||
github.com/jarcoal/httpmock v1.1.0 // indirect
|
||||
github.com/jarcoal/httpmock v1.2.0 // indirect
|
||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.1.0 // indirect
|
||||
github.com/kolo/xmlrpc v0.0.0-20201022064351-38db28db192b // indirect
|
||||
github.com/labbsr0x/bindman-dns-webhook v1.0.2 // indirect
|
||||
github.com/labbsr0x/goh v1.0.1 // indirect
|
||||
github.com/linode/linodego v1.3.0 // indirect
|
||||
github.com/linode/linodego v1.6.0 // indirect
|
||||
github.com/liquidweb/go-lwApi v0.0.5 // indirect
|
||||
github.com/liquidweb/liquidweb-cli v0.6.10 // indirect
|
||||
github.com/liquidweb/liquidweb-go v1.6.3 // indirect
|
||||
github.com/lucas-clemente/quic-go v0.27.0 // indirect
|
||||
github.com/lucas-clemente/quic-go v0.28.0 // indirect
|
||||
github.com/magiconair/properties v1.8.6 // indirect
|
||||
github.com/marten-seemann/qtls-go1-16 v0.1.5 // indirect
|
||||
github.com/marten-seemann/qtls-go1-17 v0.1.1 // indirect
|
||||
github.com/marten-seemann/qtls-go1-18 v0.1.1 // indirect
|
||||
github.com/marten-seemann/qtls-go1-17 v0.1.2 // indirect
|
||||
github.com/marten-seemann/qtls-go1-18 v0.1.2 // indirect
|
||||
github.com/marten-seemann/qtls-go1-19 v0.1.0-beta.1 // indirect
|
||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||
github.com/miekg/dns v1.1.48 // indirect
|
||||
github.com/miekg/dns v1.1.50 // indirect
|
||||
github.com/mimuret/golang-iij-dpf v0.7.1 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/mitchellh/mapstructure v1.4.3 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/namedotcom/go v0.0.0-20180403034216-08470befbe04 // indirect
|
||||
@@ -110,59 +113,61 @@ require (
|
||||
github.com/ovh/go-ovh v1.1.0 // indirect
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
|
||||
github.com/pelletier/go-toml v1.9.5 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.0-beta.8 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
|
||||
github.com/pires/go-proxyproto v0.6.2 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/pquerna/otp v1.3.0 // indirect
|
||||
github.com/rainycape/memcache v0.0.0-20150622160815-1031fa0ce2f2 // indirect
|
||||
github.com/refraction-networking/utls v1.0.0 // indirect
|
||||
github.com/refraction-networking/utls v1.1.0 // indirect
|
||||
github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect
|
||||
github.com/rogpeppe/go-internal v1.8.1 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/sacloud/libsacloud v1.36.2 // indirect
|
||||
github.com/sagernet/sing v0.0.0-20220714145306-09b55ce4b6d0 // indirect
|
||||
github.com/sagernet/sing-shadowsocks v0.0.0-20220716012931-952ae62e05d7 // indirect
|
||||
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9 // indirect
|
||||
github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb // indirect
|
||||
github.com/sirupsen/logrus v1.8.1 // indirect
|
||||
github.com/smartystreets/go-aws-auth v0.0.0-20180515143844-0c1422d1fdb9 // indirect
|
||||
github.com/softlayer/softlayer-go v1.0.4 // indirect
|
||||
github.com/softlayer/softlayer-go v1.0.5 // indirect
|
||||
github.com/softlayer/xmlrpc v0.0.0-20200409220501-5f089df7cb7e // indirect
|
||||
github.com/spf13/afero v1.8.2 // indirect
|
||||
github.com/spf13/cast v1.4.1 // indirect
|
||||
github.com/spf13/cast v1.5.0 // indirect
|
||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/stretchr/objx v0.3.0 // indirect
|
||||
github.com/subosito/gotenv v1.2.0 // indirect
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.360 // indirect
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.360 // indirect
|
||||
github.com/tklauser/numcpus v0.4.0 // indirect
|
||||
github.com/transip/gotransip/v6 v6.14.0 // indirect
|
||||
github.com/stretchr/objx v0.4.0 // indirect
|
||||
github.com/subosito/gotenv v1.3.0 // indirect
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.412 // indirect
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.412 // indirect
|
||||
github.com/tklauser/numcpus v0.5.0 // indirect
|
||||
github.com/transip/gotransip/v6 v6.17.0 // indirect
|
||||
github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e // indirect
|
||||
github.com/vinyldns/go-vinyldns v0.9.16 // indirect
|
||||
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
|
||||
github.com/vultr/govultr/v2 v2.14.1 // indirect
|
||||
github.com/vultr/govultr/v2 v2.17.0 // indirect
|
||||
github.com/xtls/go v0.0.0-20210920065950-d4af136d3672 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.2 // indirect
|
||||
go.opencensus.io v0.23.0 // indirect
|
||||
go.starlark.net v0.0.0-20220328144851-d1966c6b9fcd // indirect
|
||||
go.starlark.net v0.0.0-20220714194419-4cadf0a12139 // indirect
|
||||
go.uber.org/ratelimit v0.2.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
|
||||
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
|
||||
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect
|
||||
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
|
||||
golang.org/x/oauth2 v0.0.0-20220524215830-622c5d57e401 // indirect
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 // indirect
|
||||
golang.org/x/tools v0.1.10 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
|
||||
google.golang.org/api v0.74.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20220422154200-b37d22cd5731 // indirect
|
||||
google.golang.org/grpc v1.46.0 // indirect
|
||||
gopkg.in/ini.v1 v1.66.4 // indirect
|
||||
gopkg.in/ns1/ns1-go.v2 v2.6.3 // indirect
|
||||
golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect
|
||||
golang.org/x/tools v0.1.11 // indirect
|
||||
google.golang.org/api v0.82.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20220715211116-798f69b842b9 // indirect
|
||||
google.golang.org/grpc v1.48.0 // indirect
|
||||
gopkg.in/ini.v1 v1.66.6 // indirect
|
||||
gopkg.in/ns1/ns1-go.v2 v2.6.5 // indirect
|
||||
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
lukechampine.com/blake3 v1.1.7 // indirect
|
||||
)
|
||||
|
||||
replace github.com/linode/linodego => github.com/linode/linodego v0.31.1
|
||||
|
@@ -1,7 +1,8 @@
|
||||
[
|
||||
{
|
||||
"tag": "IPv4_out",
|
||||
"protocol": "freedom"
|
||||
"protocol": "freedom",
|
||||
"settings": {}
|
||||
},
|
||||
{
|
||||
"tag": "IPv6_out",
|
||||
@@ -10,6 +11,16 @@
|
||||
"domainStrategy": "UseIPv6"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "socks5-warp",
|
||||
"protocol": "socks",
|
||||
"settings": {
|
||||
"servers": [{
|
||||
"address": "127.0.0.1",
|
||||
"port": 1080
|
||||
}]
|
||||
}
|
||||
},
|
||||
{
|
||||
"protocol": "blackhole",
|
||||
"tag": "block"
|
||||
|
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
// Required features. Can't remove unless there is replacements.
|
||||
// _ "github.com/xtls/xray-core/app/dispatcher"
|
||||
_ "github.com/XrayR-project/XrayR/app/mydispatcher"
|
||||
_ "github.com/xtls/xray-core/app/proxyman/inbound"
|
||||
_ "github.com/xtls/xray-core/app/proxyman/outbound"
|
||||
|
||||
@@ -17,6 +18,7 @@ import (
|
||||
// Other optional features.
|
||||
_ "github.com/xtls/xray-core/app/dns"
|
||||
_ "github.com/xtls/xray-core/app/log"
|
||||
_ "github.com/xtls/xray-core/app/metrics"
|
||||
_ "github.com/xtls/xray-core/app/policy"
|
||||
_ "github.com/xtls/xray-core/app/reverse"
|
||||
_ "github.com/xtls/xray-core/app/router"
|
||||
|
BIN
main/geoip.dat
BIN
main/geoip.dat
Binary file not shown.
46817
main/geosite.dat
46817
main/geosite.dat
File diff suppressed because one or more lines are too long
@@ -23,7 +23,7 @@ var (
|
||||
)
|
||||
|
||||
var (
|
||||
version = "0.8.0"
|
||||
version = "0.8.1"
|
||||
codename = "XrayR"
|
||||
intro = "A Xray backend that supports many panels"
|
||||
)
|
||||
|
@@ -15,12 +15,22 @@
|
||||
"bittorrent"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
"outboundTag": "socks5-warp",
|
||||
"domain": []
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
"outboundTag": "IPv6_out",
|
||||
"domain": [
|
||||
"geosite:netflix"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
"outboundTag": "IPv4_out",
|
||||
"network": "udp,tcp"
|
||||
}
|
||||
]
|
||||
}
|
@@ -2,6 +2,7 @@ package panel
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/XrayR-project/XrayR/app/mydispatcher"
|
||||
io "io/ioutil"
|
||||
"log"
|
||||
"sync"
|
||||
@@ -11,7 +12,6 @@ import (
|
||||
"github.com/XrayR-project/XrayR/api/proxypanel"
|
||||
"github.com/XrayR-project/XrayR/api/sspanel"
|
||||
"github.com/XrayR-project/XrayR/api/v2board"
|
||||
"github.com/XrayR-project/XrayR/app/mydispatcher"
|
||||
_ "github.com/XrayR-project/XrayR/main/distro/all"
|
||||
"github.com/XrayR-project/XrayR/service"
|
||||
"github.com/XrayR-project/XrayR/service/controller"
|
||||
|
@@ -5,30 +5,24 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/XrayR-project/XrayR/api"
|
||||
"github.com/XrayR-project/XrayR/app/mydispatcher"
|
||||
"github.com/xtls/xray-core/common/protocol"
|
||||
"github.com/xtls/xray-core/core"
|
||||
"github.com/xtls/xray-core/features/inbound"
|
||||
"github.com/xtls/xray-core/features/outbound"
|
||||
"github.com/xtls/xray-core/features/routing"
|
||||
"github.com/xtls/xray-core/features/stats"
|
||||
"github.com/xtls/xray-core/proxy"
|
||||
)
|
||||
|
||||
func (c *Controller) removeInbound(tag string) error {
|
||||
inboundManager := c.server.GetFeature(inbound.ManagerType()).(inbound.Manager)
|
||||
err := inboundManager.RemoveHandler(context.Background(), tag)
|
||||
err := c.ihm.RemoveHandler(context.Background(), tag)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Controller) removeOutbound(tag string) error {
|
||||
outboundManager := c.server.GetFeature(outbound.ManagerType()).(outbound.Manager)
|
||||
err := outboundManager.RemoveHandler(context.Background(), tag)
|
||||
err := c.ohm.RemoveHandler(context.Background(), tag)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Controller) addInbound(config *core.InboundHandlerConfig) error {
|
||||
inboundManager := c.server.GetFeature(inbound.ManagerType()).(inbound.Manager)
|
||||
rawHandler, err := core.CreateObject(c.server, config)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -37,14 +31,13 @@ func (c *Controller) addInbound(config *core.InboundHandlerConfig) error {
|
||||
if !ok {
|
||||
return fmt.Errorf("not an InboundHandler: %s", err)
|
||||
}
|
||||
if err := inboundManager.AddHandler(context.Background(), handler); err != nil {
|
||||
if err := c.ihm.AddHandler(context.Background(), handler); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Controller) addOutbound(config *core.OutboundHandlerConfig) error {
|
||||
outboundManager := c.server.GetFeature(outbound.ManagerType()).(outbound.Manager)
|
||||
rawHandler, err := core.CreateObject(c.server, config)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -53,26 +46,25 @@ func (c *Controller) addOutbound(config *core.OutboundHandlerConfig) error {
|
||||
if !ok {
|
||||
return fmt.Errorf("not an InboundHandler: %s", err)
|
||||
}
|
||||
if err := outboundManager.AddHandler(context.Background(), handler); err != nil {
|
||||
if err := c.ohm.AddHandler(context.Background(), handler); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Controller) addUsers(users []*protocol.User, tag string) error {
|
||||
inboundManager := c.server.GetFeature(inbound.ManagerType()).(inbound.Manager)
|
||||
handler, err := inboundManager.GetHandler(context.Background(), tag)
|
||||
handler, err := c.ihm.GetHandler(context.Background(), tag)
|
||||
if err != nil {
|
||||
return fmt.Errorf("No such inbound tag: %s", err)
|
||||
}
|
||||
inboundInstance, ok := handler.(proxy.GetInbound)
|
||||
if !ok {
|
||||
return fmt.Errorf("handler %s is not implement proxy.GetInbound", tag)
|
||||
return fmt.Errorf("handler %s has not implemented proxy.GetInbound", tag)
|
||||
}
|
||||
|
||||
userManager, ok := inboundInstance.GetInbound().(proxy.UserManager)
|
||||
if !ok {
|
||||
return fmt.Errorf("handler %s is not implement proxy.UserManager", err)
|
||||
return fmt.Errorf("handler %s has not implemented proxy.UserManager", tag)
|
||||
}
|
||||
for _, item := range users {
|
||||
mUser, err := item.ToMemoryUser()
|
||||
@@ -88,8 +80,7 @@ func (c *Controller) addUsers(users []*protocol.User, tag string) error {
|
||||
}
|
||||
|
||||
func (c *Controller) removeUsers(users []string, tag string) error {
|
||||
inboundManager := c.server.GetFeature(inbound.ManagerType()).(inbound.Manager)
|
||||
handler, err := inboundManager.GetHandler(context.Background(), tag)
|
||||
handler, err := c.ihm.GetHandler(context.Background(), tag)
|
||||
if err != nil {
|
||||
return fmt.Errorf("No such inbound tag: %s", err)
|
||||
}
|
||||
@@ -114,9 +105,8 @@ func (c *Controller) removeUsers(users []string, tag string) error {
|
||||
func (c *Controller) getTraffic(email string) (up int64, down int64) {
|
||||
upName := "user>>>" + email + ">>>traffic>>>uplink"
|
||||
downName := "user>>>" + email + ">>>traffic>>>downlink"
|
||||
statsManager := c.server.GetFeature(stats.ManagerType()).(stats.Manager)
|
||||
upCounter := statsManager.GetCounter(upName)
|
||||
downCounter := statsManager.GetCounter(downName)
|
||||
upCounter := c.stm.GetCounter(upName)
|
||||
downCounter := c.stm.GetCounter(downName)
|
||||
if upCounter != nil {
|
||||
up = upCounter.Value()
|
||||
upCounter.Set(0)
|
||||
@@ -130,35 +120,29 @@ func (c *Controller) getTraffic(email string) (up int64, down int64) {
|
||||
}
|
||||
|
||||
func (c *Controller) AddInboundLimiter(tag string, nodeSpeedLimit uint64, userList *[]api.UserInfo) error {
|
||||
dispather := c.server.GetFeature(routing.DispatcherType()).(*mydispatcher.DefaultDispatcher)
|
||||
err := dispather.Limiter.AddInboundLimiter(tag, nodeSpeedLimit, userList)
|
||||
err := c.dispatcher.Limiter.AddInboundLimiter(tag, nodeSpeedLimit, userList)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Controller) UpdateInboundLimiter(tag string, updatedUserList *[]api.UserInfo) error {
|
||||
dispather := c.server.GetFeature(routing.DispatcherType()).(*mydispatcher.DefaultDispatcher)
|
||||
err := dispather.Limiter.UpdateInboundLimiter(tag, updatedUserList)
|
||||
err := c.dispatcher.Limiter.UpdateInboundLimiter(tag, updatedUserList)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Controller) DeleteInboundLimiter(tag string) error {
|
||||
dispather := c.server.GetFeature(routing.DispatcherType()).(*mydispatcher.DefaultDispatcher)
|
||||
err := dispather.Limiter.DeleteInboundLimiter(tag)
|
||||
err := c.dispatcher.Limiter.DeleteInboundLimiter(tag)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Controller) GetOnlineDevice(tag string) (*[]api.OnlineUser, error) {
|
||||
dispather := c.server.GetFeature(routing.DispatcherType()).(*mydispatcher.DefaultDispatcher)
|
||||
return dispather.Limiter.GetOnlineDevice(tag)
|
||||
return c.dispatcher.Limiter.GetOnlineDevice(tag)
|
||||
}
|
||||
|
||||
func (c *Controller) UpdateRule(tag string, newRuleList []api.DetectRule) error {
|
||||
dispather := c.server.GetFeature(routing.DispatcherType()).(*mydispatcher.DefaultDispatcher)
|
||||
err := dispather.RuleManager.UpdateRule(tag, newRuleList)
|
||||
err := c.dispatcher.RuleManager.UpdateRule(tag, newRuleList)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Controller) GetDetectResult(tag string) (*[]api.DetectResult, error) {
|
||||
dispather := c.server.GetFeature(routing.DispatcherType()).(*mydispatcher.DefaultDispatcher)
|
||||
return dispather.RuleManager.GetDetectResult(tag)
|
||||
return c.dispatcher.RuleManager.GetDetectResult(tag)
|
||||
}
|
||||
|
@@ -8,11 +8,16 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/XrayR-project/XrayR/api"
|
||||
"github.com/XrayR-project/XrayR/app/mydispatcher"
|
||||
"github.com/XrayR-project/XrayR/common/legocmd"
|
||||
"github.com/XrayR-project/XrayR/common/serverstatus"
|
||||
"github.com/xtls/xray-core/common/protocol"
|
||||
"github.com/xtls/xray-core/common/task"
|
||||
"github.com/xtls/xray-core/core"
|
||||
"github.com/xtls/xray-core/features/inbound"
|
||||
"github.com/xtls/xray-core/features/outbound"
|
||||
"github.com/xtls/xray-core/features/routing"
|
||||
"github.com/xtls/xray-core/features/stats"
|
||||
)
|
||||
|
||||
type Controller struct {
|
||||
@@ -26,15 +31,23 @@ type Controller struct {
|
||||
nodeInfoMonitorPeriodic *task.Periodic
|
||||
userReportPeriodic *task.Periodic
|
||||
panelType string
|
||||
ihm inbound.Manager
|
||||
ohm outbound.Manager
|
||||
stm stats.Manager
|
||||
dispatcher *mydispatcher.DefaultDispatcher
|
||||
}
|
||||
|
||||
// New return a Controller service with default parameters.
|
||||
func New(server *core.Instance, api api.API, config *Config, panelType string) *Controller {
|
||||
controller := &Controller{
|
||||
server: server,
|
||||
config: config,
|
||||
apiClient: api,
|
||||
panelType: panelType,
|
||||
server: server,
|
||||
config: config,
|
||||
apiClient: api,
|
||||
panelType: panelType,
|
||||
ihm: server.GetFeature(inbound.ManagerType()).(inbound.Manager),
|
||||
ohm: server.GetFeature(outbound.ManagerType()).(outbound.Manager),
|
||||
stm: server.GetFeature(stats.ManagerType()).(stats.Manager),
|
||||
dispatcher: server.GetFeature(routing.DispatcherType()).(*mydispatcher.DefaultDispatcher),
|
||||
}
|
||||
return controller
|
||||
}
|
||||
|
Reference in New Issue
Block a user