mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-06-27 12:49:03 +03:00
Fix WARP endpoint error
This commit is contained in:
@@ -185,31 +185,28 @@ func (w *WARPEndpoint) Start(stage adapter.StartStage) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *WARPEndpoint) Close() error {
|
func (w *WARPEndpoint) Close() error {
|
||||||
if err := w.isEndpointInitialized(); err != nil {
|
if ok := w.isEndpointInitialized(); !ok {
|
||||||
return err
|
return E.New("endpoint not initialized")
|
||||||
}
|
}
|
||||||
return w.endpoint.Close()
|
return w.endpoint.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WARPEndpoint) DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error) {
|
func (w *WARPEndpoint) DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error) {
|
||||||
if err := w.isEndpointInitialized(); err != nil {
|
if ok := w.isEndpointInitialized(); !ok {
|
||||||
return nil, err
|
return nil, E.New("endpoint not initialized")
|
||||||
}
|
}
|
||||||
return w.endpoint.DialContext(ctx, network, destination)
|
return w.endpoint.DialContext(ctx, network, destination)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WARPEndpoint) ListenPacket(ctx context.Context, destination M.Socksaddr) (net.PacketConn, error) {
|
func (w *WARPEndpoint) ListenPacket(ctx context.Context, destination M.Socksaddr) (net.PacketConn, error) {
|
||||||
if err := w.isEndpointInitialized(); err != nil {
|
if ok := w.isEndpointInitialized(); !ok {
|
||||||
return nil, err
|
return nil, E.New("endpoint not initialized")
|
||||||
}
|
}
|
||||||
return w.endpoint.ListenPacket(ctx, destination)
|
return w.endpoint.ListenPacket(ctx, destination)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WARPEndpoint) isEndpointInitialized() error {
|
func (w *WARPEndpoint) isEndpointInitialized() bool {
|
||||||
w.mtx.Lock()
|
w.mtx.Lock()
|
||||||
defer w.mtx.Unlock()
|
defer w.mtx.Unlock()
|
||||||
if w.endpoint == nil {
|
return w.endpoint != nil
|
||||||
return E.New("endpoint not initialized")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user