mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-16 18:08:40 +00:00
derp: move write timeout to package constant.
Signed-off-by: David Anderson <dave@natulte.net>
This commit is contained in:
parent
dbfc916273
commit
1e031001db
@ -118,7 +118,6 @@ func main() {
|
||||
letsEncrypt := tsweb.IsProd443(*addr)
|
||||
|
||||
s := derp.NewServer(key.Private(cfg.PrivateKey), log.Printf)
|
||||
s.WriteTimeout = 2 * time.Second
|
||||
expvar.Publish("derp", s.ExpVar())
|
||||
|
||||
// Create our own mux so we don't expose /debug/ stuff to the world.
|
||||
|
@ -31,7 +31,10 @@ import (
|
||||
|
||||
var debug, _ = strconv.ParseBool(os.Getenv("DERP_DEBUG_LOGS"))
|
||||
|
||||
const perClientSendQueueDepth = 32 // packets buffered for sending
|
||||
const (
|
||||
perClientSendQueueDepth = 32 // packets buffered for sending
|
||||
writeTimeout = 2 * time.Second
|
||||
)
|
||||
|
||||
// Server is a DERP server.
|
||||
type Server struct {
|
||||
@ -560,9 +563,7 @@ func (c *sclient) sendLoop(ctx context.Context) error {
|
||||
}
|
||||
|
||||
func (c *sclient) sendKeepalive() error {
|
||||
if c.s.WriteTimeout != 0 {
|
||||
c.nc.SetWriteDeadline(time.Now().Add(c.s.WriteTimeout))
|
||||
}
|
||||
c.nc.SetWriteDeadline(time.Now().Add(writeTimeout))
|
||||
if err := writeFrame(c.bw, frameKeepAlive, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -583,9 +584,7 @@ func (c *sclient) sendPacket(srcKey key.Public, contents []byte) (err error) {
|
||||
}
|
||||
}()
|
||||
|
||||
if c.s.WriteTimeout != 0 {
|
||||
c.nc.SetWriteDeadline(time.Now().Add(c.s.WriteTimeout))
|
||||
}
|
||||
c.nc.SetWriteDeadline(time.Now().Add(writeTimeout))
|
||||
|
||||
withKey := !srcKey.IsZero()
|
||||
pktLen := len(contents)
|
||||
|
Loading…
x
Reference in New Issue
Block a user