mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-13 22:47:30 +00:00
safesocket: add ConnectContext
This adds a variant for Connect that takes in a context.Context which allows passing through cancellation etc by the caller. Updates tailscale/corp#18266 Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
package safesocket
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
@@ -16,11 +17,12 @@ import (
|
||||
"runtime"
|
||||
)
|
||||
|
||||
func connect(path string) (net.Conn, error) {
|
||||
func connect(ctx context.Context, path string) (net.Conn, error) {
|
||||
if runtime.GOOS == "js" {
|
||||
return nil, errors.New("safesocket.Connect not yet implemented on js/wasm")
|
||||
}
|
||||
return net.Dial("unix", path)
|
||||
var std net.Dialer
|
||||
return std.DialContext(ctx, "unix", path)
|
||||
}
|
||||
|
||||
func listen(path string) (net.Listener, error) {
|
||||
|
Reference in New Issue
Block a user