mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-02-16 22:34:35 +00:00
Fix URLTest group early start
This commit is contained in:
parent
01f6e70bc5
commit
e911d4aa4b
|
@ -38,6 +38,7 @@ type URLTest struct {
|
||||||
tolerance uint16
|
tolerance uint16
|
||||||
group *URLTestGroup
|
group *URLTestGroup
|
||||||
interruptExternalConnections bool
|
interruptExternalConnections bool
|
||||||
|
started bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewURLTest(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.URLTestOutboundOptions) (*URLTest, error) {
|
func NewURLTest(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.URLTestOutboundOptions) (*URLTest, error) {
|
||||||
|
@ -83,6 +84,7 @@ func (s *URLTest) Start() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *URLTest) PostStart() error {
|
func (s *URLTest) PostStart() error {
|
||||||
|
s.started = true
|
||||||
go s.CheckOutbounds()
|
go s.CheckOutbounds()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -110,7 +112,9 @@ func (s *URLTest) CheckOutbounds() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *URLTest) DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error) {
|
func (s *URLTest) DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error) {
|
||||||
|
if s.started {
|
||||||
s.group.Start()
|
s.group.Start()
|
||||||
|
}
|
||||||
outbound := s.group.Select(network)
|
outbound := s.group.Select(network)
|
||||||
conn, err := outbound.DialContext(ctx, network, destination)
|
conn, err := outbound.DialContext(ctx, network, destination)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -122,7 +126,9 @@ func (s *URLTest) DialContext(ctx context.Context, network string, destination M
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *URLTest) ListenPacket(ctx context.Context, destination M.Socksaddr) (net.PacketConn, error) {
|
func (s *URLTest) ListenPacket(ctx context.Context, destination M.Socksaddr) (net.PacketConn, error) {
|
||||||
|
if s.started {
|
||||||
s.group.Start()
|
s.group.Start()
|
||||||
|
}
|
||||||
outbound := s.group.Select(N.NetworkUDP)
|
outbound := s.group.Select(N.NetworkUDP)
|
||||||
conn, err := outbound.ListenPacket(ctx, destination)
|
conn, err := outbound.ListenPacket(ctx, destination)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
Loading…
Reference in a new issue