mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-26 03:25:35 +00:00
8fe504241d
Setting a user timeout will be a more practical tuning knob for a number of endpoints, this provides a way to set it. Updates tailscale/corp#17587 Signed-off-by: James Tucker <james@tailscale.com>
25 lines
388 B
Go
25 lines
388 B
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package ktimeout
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"net"
|
|
"time"
|
|
)
|
|
|
|
func ExampleUserTimeout() {
|
|
lc := net.ListenConfig{
|
|
Control: UserTimeout(30 * time.Second),
|
|
}
|
|
l, err := lc.Listen(context.TODO(), "tcp", "127.0.0.1:0")
|
|
if err != nil {
|
|
fmt.Printf("error: %v", err)
|
|
return
|
|
}
|
|
l.Close()
|
|
// Output:
|
|
}
|