Skip to content

Commit 4c3eebc

Browse files
committed
chore(deps): bump sentinel-go-sdk to commit 0b770c8bbbff
1 parent a936d89 commit 4c3eebc

File tree

8 files changed

+47
-68
lines changed

8 files changed

+47
-68
lines changed

.golangci.yaml

Lines changed: 0 additions & 25 deletions
This file was deleted.

cmd/init.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package cmd
22

33
import (
4-
"context"
54
"fmt"
65
"os"
76
"path/filepath"
@@ -42,9 +41,6 @@ func NewInitCmd(cfg *config.Config) *cobra.Command {
4241
If a configuration file already exists, this command will abort unless the "force" flag
4342
is set to overwrite the existing configuration.`,
4443
RunE: func(cmd *cobra.Command, args []string) error {
45-
ctx, cancel := context.WithCancel(cmd.Context())
46-
defer cancel()
47-
4844
// Create the home directory if it doesn't exist
4945
homeDir := viper.GetString("home")
5046
if err := os.MkdirAll(homeDir, 0755); err != nil {
@@ -99,11 +95,11 @@ is set to overwrite the existing configuration.`,
9995
// Initialize the appropriate server service based on the configured type
10096
switch serviceType {
10197
case types.ServiceTypeV2Ray:
102-
service = v2ray.NewServer(ctx, "v2ray", homeDir, cfg.Services[types.ServiceTypeV2Ray].(*v2ray.ServerConfig))
98+
service = v2ray.NewServer("v2ray", homeDir, cfg.Services[types.ServiceTypeV2Ray].(*v2ray.ServerConfig))
10399
case types.ServiceTypeWireGuard:
104-
service = wireguard.NewServer(ctx, "wireguard", homeDir, cfg.Services[types.ServiceTypeWireGuard].(*wireguard.ServerConfig))
100+
service = wireguard.NewServer("wireguard", homeDir, cfg.Services[types.ServiceTypeWireGuard].(*wireguard.ServerConfig))
105101
case types.ServiceTypeOpenVPN:
106-
service = openvpn.NewServer(ctx, "openvpn", homeDir, cfg.Services[types.ServiceTypeOpenVPN].(*openvpn.ServerConfig))
102+
service = openvpn.NewServer("openvpn", homeDir, cfg.Services[types.ServiceTypeOpenVPN].(*openvpn.ServerConfig))
107103
default:
108104
return fmt.Errorf("unsupported service type %q", serviceType)
109105
}

cmd/start.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ explicitly starts the node, and handles SIGINT/SIGTERM for graceful shutdown.`,
4040
homeDir := viper.GetString("home")
4141

4242
// Create and initialize the node with the configured context
43-
n := node.New(ctx, "node")
43+
n := node.New("node")
4444

4545
log.Info("Setting up node")
46-
if err := n.Setup(homeDir, cmd.InOrStdin(), cfg); err != nil {
46+
if err := n.Setup(ctx, homeDir, cmd.InOrStdin(), cfg); err != nil {
4747
return fmt.Errorf("setting up node: %w", err)
4848
}
4949

@@ -53,12 +53,13 @@ explicitly starts the node, and handles SIGINT/SIGTERM for graceful shutdown.`,
5353
// Goroutine to start and wait on the node
5454
eg.Go(func() error {
5555
log.Info("Starting node")
56-
if err := n.Start(); err != nil {
56+
ctx, err := n.Start(ctx)
57+
if err != nil {
5758
return fmt.Errorf("starting node: %w", err)
5859
}
5960

6061
log.Info("Node started successfully")
61-
if err := n.Wait(); err != nil {
62+
if err := n.Wait(ctx); err != nil {
6263
return fmt.Errorf("waiting node: %w", err)
6364
}
6465

@@ -71,10 +72,11 @@ explicitly starts the node, and handles SIGINT/SIGTERM for graceful shutdown.`,
7172

7273
log.Info("Stopping node")
7374
if err := n.Stop(); err != nil {
74-
return app.NewErrShutdown(err)
75+
return app.NewErrShutdown(fmt.Errorf("stopping node: %w", err))
7576
}
7677

7778
log.Info("Node stopped successfully")
79+
7880
return nil
7981
})
8082

core/setup.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ func (c *Context) SetupService(ctx context.Context, cfg *config.Config) error {
9999
// Initialize the appropriate server service based on the configured type
100100
switch st {
101101
case types.ServiceTypeV2Ray:
102-
s = v2ray.NewServer(ctx, "v2ray", c.HomeDir(), cfg.Services[types.ServiceTypeV2Ray].(*v2ray.ServerConfig))
102+
s = v2ray.NewServer("v2ray", c.HomeDir(), cfg.Services[types.ServiceTypeV2Ray].(*v2ray.ServerConfig))
103103
case types.ServiceTypeWireGuard:
104-
s = wireguard.NewServer(ctx, "wireguard", c.HomeDir(), cfg.Services[types.ServiceTypeWireGuard].(*wireguard.ServerConfig))
104+
s = wireguard.NewServer("wireguard", c.HomeDir(), cfg.Services[types.ServiceTypeWireGuard].(*wireguard.ServerConfig))
105105
case types.ServiceTypeOpenVPN:
106-
s = openvpn.NewServer(ctx, "openvpn", c.HomeDir(), cfg.Services[types.ServiceTypeOpenVPN].(*openvpn.ServerConfig))
106+
s = openvpn.NewServer("openvpn", c.HomeDir(), cfg.Services[types.ServiceTypeOpenVPN].(*openvpn.ServerConfig))
107107
default:
108108
return fmt.Errorf("unsupported service type %q", st)
109109
}
@@ -118,7 +118,7 @@ func (c *Context) SetupService(ctx context.Context, cfg *config.Config) error {
118118
return fmt.Errorf("service %q is already running", st)
119119
}
120120

121-
if err := s.Setup(); err != nil {
121+
if err := s.Setup(ctx); err != nil {
122122
return err
123123
}
124124

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/cosmos/cosmos-sdk v0.47.17
88
github.com/gin-contrib/cors v1.7.6
99
github.com/gin-gonic/gin v1.10.1
10-
github.com/sentinel-official/sentinel-go-sdk v1.0.0-rc.6.0.20250906120819-b37c50d18c9c
10+
github.com/sentinel-official/sentinel-go-sdk v1.0.0-rc.6.0.20250907043146-0b770c8bbbff
1111
github.com/sentinel-official/sentinelhub/v12 v12.0.0-rc.11
1212
github.com/spf13/cobra v1.10.1
1313
github.com/spf13/pflag v1.0.10

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,8 @@ github.com/secure-io/siv-go v0.0.0-20180922214919-5ff40651e2c4 h1:zOjq+1/uLzn/Xo
512512
github.com/secure-io/siv-go v0.0.0-20180922214919-5ff40651e2c4/go.mod h1:aI+8yClBW+1uovkHw6HM01YXnYB8vohtB9C83wzx34E=
513513
github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb h1:XfLJSPIOUX+osiMraVgIrMR27uMXnRJWGm1+GL8/63U=
514514
github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb/go.mod h1:bR6DqgcAl1zTcOX8/pE2Qkj9XO00eCNqmKb7lXP8EAg=
515-
github.com/sentinel-official/sentinel-go-sdk v1.0.0-rc.6.0.20250906120819-b37c50d18c9c h1:Q7s7BGAzr7LwS9j5pX5/gjdmcbbfj2zqeH4ZmT/SzJ0=
516-
github.com/sentinel-official/sentinel-go-sdk v1.0.0-rc.6.0.20250906120819-b37c50d18c9c/go.mod h1:dgPFIfSccQ1th9xdwUGnMsdatGpYTA6p13SEbSX4UB8=
515+
github.com/sentinel-official/sentinel-go-sdk v1.0.0-rc.6.0.20250907043146-0b770c8bbbff h1:pbaC4XanYAOA5zclDa2SfLDX0/jhnt4VwATC2yGT0ns=
516+
github.com/sentinel-official/sentinel-go-sdk v1.0.0-rc.6.0.20250907043146-0b770c8bbbff/go.mod h1:Gq0+WlluP3Kg495B4mqgrUVn30m0YBGV8Nyu01A5V34=
517517
github.com/sentinel-official/sentinelhub/v12 v12.0.0-rc.11 h1:B3ylnKZSLP9aDYnS2f98Gx/QTohPuD36tjl75kYJSMs=
518518
github.com/sentinel-official/sentinelhub/v12 v12.0.0-rc.11/go.mod h1:LXcOAEffAn4Pw58xhoYN9j8ZVuM02OCgPNTI6lkGG2E=
519519
github.com/shirou/gopsutil/v4 v4.25.8 h1:NnAsw9lN7587WHxjJA9ryDnqhJpFH6A+wagYWTOH970=

node/node.go

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ type Node struct {
2424
}
2525

2626
// New creates a new Node with the provided context.
27-
func New(ctx context.Context, name string) *Node {
27+
func New(name string) *Node {
2828
return &Node{
29-
Manager: process.NewManager(ctx, name),
29+
Manager: process.NewManager(name),
3030
}
3131
}
3232

@@ -120,12 +120,13 @@ func (n *Node) UpdateDetails(ctx context.Context) error {
120120
}
121121

122122
log.Info("Node details updated successfully", "addr", n.Context().NodeAddr())
123+
123124
return nil
124125
}
125126

126127
// Start initializes the Node's services, scheduler, and API server.
127-
func (n *Node) Start() error {
128-
return n.Manager.Start(func(ctx context.Context) error {
128+
func (n *Node) Start(parent context.Context) (context.Context, error) {
129+
return n.Manager.Start(parent, func(ctx context.Context) error {
129130
if err := n.Register(ctx); err != nil {
130131
return fmt.Errorf("registering node: %w", err)
131132
}
@@ -134,29 +135,35 @@ func (n *Node) Start() error {
134135
return fmt.Errorf("updating details: %w", err)
135136
}
136137

138+
var (
139+
serviceCtx context.Context
140+
schedulerCtx context.Context
141+
serverCtx context.Context
142+
)
143+
137144
sg := &errgroup.Group{}
138145

139-
sg.Go(func() error {
146+
sg.Go(func() (err error) {
140147
log.Info("Starting service")
141-
if err := n.Context().Service().Start(); err != nil {
148+
if serviceCtx, err = n.Context().Service().Start(ctx); err != nil {
142149
return fmt.Errorf("starting service: %w", err)
143150
}
144151

145152
return nil
146153
})
147154

148-
sg.Go(func() error {
155+
sg.Go(func() (err error) {
149156
log.Info("Starting scheduler")
150-
if err := n.Scheduler().Start(); err != nil {
157+
if schedulerCtx, err = n.Scheduler().Start(ctx); err != nil {
151158
return fmt.Errorf("starting scheduler: %w", err)
152159
}
153160

154161
return nil
155162
})
156163

157-
sg.Go(func() error {
164+
sg.Go(func() (err error) {
158165
log.Info("Starting API server")
159-
if err := n.Server().Start(); err != nil {
166+
if serverCtx, err = n.Server().Start(ctx); err != nil {
160167
return fmt.Errorf("starting API server: %w", err)
161168
}
162169

@@ -167,24 +174,24 @@ func (n *Node) Start() error {
167174
return err
168175
}
169176

170-
n.Go(func(ctx context.Context) error {
171-
if err := n.Context().Service().Wait(); err != nil {
177+
n.Go(ctx, func() error {
178+
if err := n.Context().Service().Wait(serviceCtx); err != nil {
172179
return fmt.Errorf("waiting service: %w", err)
173180
}
174181

175182
return nil
176183
})
177184

178-
n.Go(func(ctx context.Context) error {
179-
if err := n.Scheduler().Wait(); err != nil {
185+
n.Go(ctx, func() error {
186+
if err := n.Scheduler().Wait(schedulerCtx); err != nil {
180187
return fmt.Errorf("waiting scheduler: %w", err)
181188
}
182189

183190
return nil
184191
})
185192

186-
n.Go(func(ctx context.Context) error {
187-
if err := n.Server().Wait(); err != nil {
193+
n.Go(ctx, func() error {
194+
if err := n.Server().Wait(serverCtx); err != nil {
188195
return fmt.Errorf("waiting API server: %w", err)
189196
}
190197

@@ -196,8 +203,8 @@ func (n *Node) Start() error {
196203
}
197204

198205
// Wait blocks until all background goroutines launched exit.
199-
func (n *Node) Wait() error {
200-
return n.Manager.Wait(nil)
206+
func (n *Node) Wait(ctx context.Context) error {
207+
return n.Manager.Wait(ctx, nil)
201208
}
202209

203210
// Stop gracefully stops the Node's operations.

node/setup.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ func (n *Node) SetupScheduler(ctx context.Context, cfg *config.Config) error {
4040

4141
log.Info("Initializing scheduler")
4242

43-
s := cron.NewScheduler(ctx, "scheduler")
44-
if err := s.Setup(); err != nil {
43+
s := cron.NewScheduler("scheduler")
44+
if err := s.Setup(ctx); err != nil {
4545
return err
4646
}
4747

@@ -82,14 +82,13 @@ func (n *Node) SetupServer(ctx context.Context, _ *config.Config) error {
8282
log.Info("Initializing API server")
8383

8484
s := cmux.NewServer(
85-
ctx,
8685
"API-server",
8786
n.Context().APIListenAddr(),
8887
n.Context().TLSCertFile(),
8988
n.Context().TLSKeyFile(),
9089
router,
9190
)
92-
if err := s.Setup(); err != nil {
91+
if err := s.Setup(ctx); err != nil {
9392
return err
9493
}
9594

@@ -118,8 +117,8 @@ func (n *Node) SetupContext(ctx context.Context, homeDir string, input io.Reader
118117
}
119118

120119
// Setup sets up the context, scheduler and API server for the Node.
121-
func (n *Node) Setup(homeDir string, input io.Reader, cfg *config.Config) error {
122-
return n.Manager.Setup(func(ctx context.Context) error {
120+
func (n *Node) Setup(ctx context.Context, homeDir string, input io.Reader, cfg *config.Config) error {
121+
return n.Manager.Setup(ctx, func() error {
123122
log.Info("Setting up context")
124123
if err := n.SetupContext(ctx, homeDir, input, cfg); err != nil {
125124
return fmt.Errorf("setting up context: %w", err)

0 commit comments

Comments
 (0)