Skip to content

Commit f7fe125

Browse files
committed
update xray-core v25.12.8
1 parent db05ba0 commit f7fe125

9 files changed

Lines changed: 57 additions & 11 deletions

File tree

common/task/task.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type Task struct {
1212
Name string
1313
Interval time.Duration
1414
Execute func() error
15+
Reload func()
1516
Access sync.RWMutex
1617
Running bool
1718
Stop chan struct{}
@@ -48,7 +49,7 @@ func (t *Task) Start(first bool) error {
4849

4950
if err := t.ExecuteWithTimeout(); err != nil {
5051
log.Errorf("Task %s execution error: %v", t.Name, err)
51-
t.safeStop()
52+
t.Reload()
5253
return
5354
}
5455
}
@@ -69,7 +70,7 @@ func (t *Task) ExecuteWithTimeout() error {
6970
select {
7071
case <-ctx.Done():
7172
log.Errorf("Task %s execution timed out", t.Name)
72-
return nil
73+
return ctx.Err()
7374
case err := <-done:
7475
return err
7576
}

core/inbound.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ import (
1818
coreConf "github.com/xtls/xray-core/infra/conf"
1919
)
2020

21+
type NetworkSettingsProxyProtocol struct {
22+
AcceptProxyProtocol bool `json:"acceptProxyProtocol"`
23+
}
24+
2125
func (v *V2Core) removeInbound(tag string) error {
2226
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
2327
defer cancel()
@@ -67,6 +71,28 @@ func buildInbound(nodeInfo *panel.NodeInfo, tag string) (*core.InboundHandlerCon
6771
return nil, err
6872
}
6973
// Set network protocol
74+
if len(nodeInfo.Common.NetworkSettings) > 0 {
75+
n := &NetworkSettingsProxyProtocol{}
76+
err := json.Unmarshal(nodeInfo.Common.NetworkSettings, n)
77+
if err != nil {
78+
return nil, fmt.Errorf("unmarshal network settings error: %s", err)
79+
}
80+
if n.AcceptProxyProtocol {
81+
if in.StreamSetting == nil {
82+
t := coreConf.TransportProtocol(nodeInfo.Common.Network)
83+
in.StreamSetting = &coreConf.StreamConfig{
84+
Network: &t,
85+
SocketSettings: &coreConf.SocketConfig{
86+
AcceptProxyProtocol: n.AcceptProxyProtocol,
87+
},
88+
}
89+
} else {
90+
in.StreamSetting.SocketSettings = &coreConf.SocketConfig{
91+
AcceptProxyProtocol: n.AcceptProxyProtocol,
92+
}
93+
}
94+
}
95+
}
7096
// Set server port
7197
in.PortList = &coreConf.PortList{
7298
Range: []coreConf.PortRange{

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
github.com/spf13/cobra v1.9.1
1414
github.com/spf13/viper v1.19.0
1515
github.com/vmihailenco/msgpack/v5 v5.4.1
16-
github.com/xtls/xray-core v1.251202.0
16+
github.com/xtls/xray-core v1.251208.0
1717
golang.org/x/sys v0.38.0
1818
google.golang.org/protobuf v1.36.10
1919
)
@@ -234,4 +234,4 @@ require (
234234
lukechampine.com/blake3 v1.4.1 // indirect
235235
)
236236

237-
replace github.com/xtls/xray-core v1.251202.0 => github.com/wyx2685/xray-core v0.0.0-20251202200223-63db1dc9e9e2
237+
replace github.com/xtls/xray-core v1.251208.0 => github.com/wyx2685/xray-core v0.0.0-20251208163142-59b3434a00d2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -955,8 +955,8 @@ github.com/volcengine/volc-sdk-golang v1.0.216 h1:+wAq8RvxpGECveRJaAXZFpzrZoQ33W
955955
github.com/volcengine/volc-sdk-golang v1.0.216/go.mod h1:zHJlaqiMbIB+0mcrsZPTwOb3FB7S/0MCfqlnO8R7hlM=
956956
github.com/vultr/govultr/v3 v3.21.1 h1:0cnA8fXiqayPGbAlNHaW+5oCQjpDNkkAm3Nt3LOHplM=
957957
github.com/vultr/govultr/v3 v3.21.1/go.mod h1:9WwnWGCKnwDlNjHjtt+j+nP+0QWq6hQXzaHgddqrLWY=
958-
github.com/wyx2685/xray-core v0.0.0-20251202200223-63db1dc9e9e2 h1:22XxgTBYlo0QLuB8frtd+MH1+g1Q6r2UgQ4mYt/7Sp8=
959-
github.com/wyx2685/xray-core v0.0.0-20251202200223-63db1dc9e9e2/go.mod h1:yTB/iXzdo38F+nUYbjD5Eys88SP6N2zd0jyEmrBB37U=
958+
github.com/wyx2685/xray-core v0.0.0-20251208163142-59b3434a00d2 h1:hO5DdlI870ebrE12LeRoT+RWi5jcy9hmsK4m2A2SHpM=
959+
github.com/wyx2685/xray-core v0.0.0-20251208163142-59b3434a00d2/go.mod h1:yTB/iXzdo38F+nUYbjD5Eys88SP6N2zd0jyEmrBB37U=
960960
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
961961
github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs=
962962
github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4=

node/controller.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
log "github.com/sirupsen/logrus"
88
panel "github.com/wyx2685/v2node/api/v2board"
99
"github.com/wyx2685/v2node/common/task"
10+
"github.com/wyx2685/v2node/conf"
1011
"github.com/wyx2685/v2node/core"
1112
"github.com/wyx2685/v2node/limiter"
1213
)
@@ -18,17 +19,19 @@ type Controller struct {
1819
limiter *limiter.Limiter
1920
userList []panel.UserInfo
2021
aliveMap map[int]int
22+
conf *conf.NodeConfig
2123
info *panel.NodeInfo
2224
nodeInfoMonitorPeriodic *task.Task
2325
userReportPeriodic *task.Task
2426
renewCertPeriodic *task.Task
2527
}
2628

2729
// NewController return a Node controller with default parameters.
28-
func NewController(api *panel.Client, info *panel.NodeInfo) *Controller {
30+
func NewController(api *panel.Client, conf *conf.NodeConfig, info *panel.NodeInfo) *Controller {
2931
controller := &Controller{
3032
apiClient: api,
3133
info: info,
34+
conf: conf,
3235
}
3336
return controller
3437
}

node/node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func New(nodes []conf.NodeConfig) (*Node, error) {
2828
if err != nil {
2929
return nil, err
3030
}
31-
n.controllers[i] = NewController(p, info)
31+
n.controllers[i] = NewController(p, &node, info)
3232
n.NodeInfos[i] = info
3333
}
3434
return n, nil

node/task.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ func (c *Controller) startTasks(node *panel.NodeInfo) {
1515
Name: "nodeInfoMonitor",
1616
Interval: node.PullInterval,
1717
Execute: c.nodeInfoMonitor,
18+
Reload: c.reloadTask,
1819
}
1920
// fetch user list task
2021
c.userReportPeriodic = &task.Task{
2122
Name: "reportUserTrafficTask",
2223
Interval: node.PushInterval,
2324
Execute: c.reportUserTrafficTask,
25+
Reload: c.reloadTask,
2426
}
2527
log.WithField("tag", c.tag).Info("Start monitor node status")
2628
// delay to start nodeInfoMonitor
@@ -35,6 +37,7 @@ func (c *Controller) startTasks(node *panel.NodeInfo) {
3537
Name: "renewCertTask",
3638
Interval: time.Hour * 24,
3739
Execute: c.renewCertTask,
40+
Reload: c.reloadTask,
3841
}
3942
log.WithField("tag", c.tag).Info("Start renew cert")
4043
// delay to start renewCert
@@ -43,8 +46,21 @@ func (c *Controller) startTasks(node *panel.NodeInfo) {
4346
}
4447
}
4548

46-
func (c *Controller) nodeInfoMonitor() (err error) {
49+
func (c *Controller) reloadTask() {
50+
newClient, err := panel.New(c.conf)
51+
if err != nil {
52+
log.Panic("Tasks reload failed")
53+
}
54+
c.apiClient = newClient
55+
c.nodeInfoMonitorPeriodic.Close()
56+
c.userReportPeriodic.Close()
57+
if c.renewCertPeriodic != nil {
58+
c.renewCertPeriodic.Close()
59+
}
60+
c.startTasks(c.info)
61+
}
4762

63+
func (c *Controller) nodeInfoMonitor() (err error) {
4864
// get node info
4965
newN, err := c.apiClient.GetNodeInfo()
5066
if err != nil {

script/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ generate_v2node_config() {
236236
"ApiHost": "${api_host}",
237237
"NodeID": ${node_id},
238238
"ApiKey": "${api_key}",
239-
"Timeout": 30
239+
"Timeout": 15
240240
}
241241
]
242242
}

script/v2node.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ generate_v2node_config() {
438438
"ApiHost": "${api_host}",
439439
"NodeID": ${node_id},
440440
"ApiKey": "${api_key}",
441-
"Timeout": 30
441+
"Timeout": 15
442442
}
443443
]
444444
}

0 commit comments

Comments
 (0)