Add TCP MultiPath support

This commit is contained in:
世界
2023-08-08 16:14:03 +08:00
parent a26f816441
commit 8bd3b4e318
33 changed files with 225 additions and 43 deletions

View File

@@ -31,7 +31,7 @@ type Service struct {
clockOffset time.Duration
}
func NewService(ctx context.Context, router adapter.Router, logger logger.Logger, options option.NTPOptions) *Service {
func NewService(ctx context.Context, router adapter.Router, logger logger.Logger, options option.NTPOptions) (*Service, error) {
ctx, cancel := common.ContextWithCancelCause(ctx)
server := options.ServerOptions.Build()
if server.Port == 0 {
@@ -43,15 +43,19 @@ func NewService(ctx context.Context, router adapter.Router, logger logger.Logger
} else {
interval = 30 * time.Minute
}
outboundDialer, err := dialer.New(router, options.DialerOptions)
if err != nil {
return nil, err
}
return &Service{
ctx: ctx,
cancel: cancel,
server: server,
writeToSystem: options.WriteToSystem,
dialer: dialer.New(router, options.DialerOptions),
dialer: outboundDialer,
logger: logger,
ticker: time.NewTicker(interval),
}
}, nil
}
func (s *Service) Start() error {