Skip to content

Commit c72216c

Browse files
committed
Merge remote-tracking branch 'upstream/main'
# Conflicts: # core.go # go.mod # go.sum # v2ray.go
2 parents 06c4cce + 6ab329f commit c72216c

File tree

4 files changed

+30
-14
lines changed

4 files changed

+30
-14
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.17
44

55
require (
66
github.com/Dreamacro/clash v1.7.1
7+
github.com/golang/protobuf v1.5.2
78
github.com/miekg/dns v1.1.43
89
github.com/pkg/errors v0.9.1
910
github.com/sagernet/gomobile v0.0.0-20210905032500-701a995ff844
@@ -21,7 +22,7 @@ require (
2122
replace gvisor.dev/gvisor v0.0.0 => github.com/sagernet/gvisor v0.0.0-20211022025201-1cae8baac6b3
2223

2324
//replace github.com/xtls/xray-core v1.4.5 => ../Xray-core
24-
replace github.com/xtls/xray-core v1.5.0 => github.com/xtls/xray-core v1.5.1-0.20211022054941-db69818f3719
25+
replace github.com/xtls/xray-core v1.5.0 => github.com/xtls/xray-core v1.5.1-0.20211022092228-bbea20a8f112
2526

2627
replace github.com/Dreamacro/clash v1.7.1 => github.com/sagernet/clash v1.6.5-0.20210913182617-681dd3780179
2728

@@ -37,7 +38,6 @@ require (
3738
github.com/geeksbaek/seed v0.0.0-20180909040025-2a7f5fb92e22 // indirect
3839
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
3940
github.com/gofrs/uuid v4.1.0+incompatible // indirect
40-
github.com/golang/protobuf v1.5.2 // indirect
4141
github.com/google/btree v1.0.1 // indirect
4242
github.com/gorilla/websocket v1.4.2 // indirect
4343
github.com/kierdavis/cfb8 v0.0.0-20180105024805-3a17c36ee2f8 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,8 +686,8 @@ github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:
686686
github.com/xtls/go v0.0.0-20201118062508-3632bf3b7499/go.mod h1:5TB2+k58gx4A4g2Nf5miSHNDF6CuAzHKpWBooLAshTs=
687687
github.com/xtls/go v0.0.0-20210920065950-d4af136d3672 h1:4mkzGhKqt3JO1BWYjtD3iRFyAx4ow67hmSqOcGjuxqQ=
688688
github.com/xtls/go v0.0.0-20210920065950-d4af136d3672/go.mod h1:YGGVbz9cOxyKFUmhW7LGaLZaMA0cPlHJinvAmVxEMSU=
689-
github.com/xtls/xray-core v1.5.1-0.20211022054941-db69818f3719 h1:FX71ANRcMGcEGTWgJyRicGkNdA6E8ZQzZXzpbnNnDsk=
690-
github.com/xtls/xray-core v1.5.1-0.20211022054941-db69818f3719/go.mod h1:t5GTnutkWucuqQoAg81vNoGbq8JY6AxOgd2F0xenA0E=
689+
github.com/xtls/xray-core v1.5.1-0.20211022092228-bbea20a8f112 h1:YF8X1QNYWbpf3PAHhkgyKcCL/B64x2VAPAK1PHfHahU=
690+
github.com/xtls/xray-core v1.5.1-0.20211022092228-bbea20a8f112/go.mod h1:t5GTnutkWucuqQoAg81vNoGbq8JY6AxOgd2F0xenA0E=
691691
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
692692
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
693693
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=

observatory.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package libcore
22

3-
/*import (
3+
import (
44
"github.com/golang/protobuf/proto"
55
"github.com/pkg/errors"
6-
"github.com/v2fly/v2ray-core/v4/app/observatory"
6+
"github.com/xtls/xray-core/app/observatory"
77
)
88

99
func (instance *V2RayInstance) GetObservatoryStatus() ([]byte, error) {
@@ -17,7 +17,7 @@ func (instance *V2RayInstance) GetObservatoryStatus() ([]byte, error) {
1717
return proto.Marshal(resp)
1818
}
1919

20-
func (instance *V2RayInstance) UpdateStatus(outbound string, status []byte) error {
20+
func (instance *V2RayInstance) UpdateStatus(status []byte) error {
2121
if instance.observatory == nil {
2222
return errors.New("observatory unavailable")
2323
}
@@ -26,7 +26,21 @@ func (instance *V2RayInstance) UpdateStatus(outbound string, status []byte) erro
2626
if err != nil {
2727
return err
2828
}
29-
instance.observatory.UpdateStatus(outbound, s)
29+
instance.observatory.UpdateStatus(s)
3030
return err
3131
}
32-
*/
32+
33+
type StatusUpdateListener interface {
34+
OnUpdate(status []byte)
35+
}
36+
37+
func (instance *V2RayInstance) SetStatusUpdateListener(listener StatusUpdateListener) {
38+
if listener == nil {
39+
instance.observatory.StatusUpdate = nil
40+
} else {
41+
instance.observatory.StatusUpdate = func(result *observatory.OutboundStatus) {
42+
status, _ := proto.Marshal(result)
43+
listener.OnUpdate(status)
44+
}
45+
}
46+
}

v2ray.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"errors"
66
"fmt"
7+
"github.com/xtls/xray-core/app/observatory"
78
"github.com/xtls/xray-core/common"
89
"github.com/xtls/xray-core/common/buf"
910
"github.com/xtls/xray-core/common/net"
@@ -12,6 +13,7 @@ import (
1213
"github.com/xtls/xray-core/common/signal"
1314
"github.com/xtls/xray-core/core"
1415
"github.com/xtls/xray-core/features/dns"
16+
"github.com/xtls/xray-core/features/extension"
1517
"github.com/xtls/xray-core/features/routing"
1618
"github.com/xtls/xray-core/features/stats"
1719
"github.com/xtls/xray-core/infra/conf/serial"
@@ -32,9 +34,9 @@ type V2RayInstance struct {
3234
started bool
3335
core *core.Instance
3436
statsManager stats.Manager
35-
//observatory *observatory.Observer
36-
dispatcher routing.Dispatcher
37-
dnsClient dns.Client
37+
observatory *observatory.Observer
38+
dispatcher routing.Dispatcher
39+
dnsClient dns.Client
3840
}
3941

4042
func NewV2rayInstance() *V2RayInstance {
@@ -71,10 +73,10 @@ func (instance *V2RayInstance) LoadConfig(content string) error {
7173
instance.dispatcher = c.GetFeature(routing.DispatcherType()).(routing.Dispatcher)
7274
instance.dnsClient = c.GetFeature(dns.ClientType()).(dns.Client)
7375

74-
/*o := c.GetFeature(extension.ObservatoryType())
76+
o := c.GetFeature(extension.ObservatoryType())
7577
if o != nil {
7678
instance.observatory = o.(*observatory.Observer)
77-
}*/
79+
}
7880
return nil
7981
}
8082

0 commit comments

Comments
 (0)