Source file src/net/hook.go

     1  // Copyright 2015 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package net
     6  
     7  import (
     8  	"context"
     9  	"time"
    10  )
    11  
    12  var (
    13  	// if non-nil, overrides dialTCP.
    14  	testHookDialTCP func(ctx context.Context, net string, laddr, raddr *TCPAddr) (*TCPConn, error)
    15  
    16  	testHookLookupIP = func(
    17  		ctx context.Context,
    18  		fn func(context.Context, string, string) ([]IPAddr, error),
    19  		network string,
    20  		host string,
    21  	) ([]IPAddr, error) {
    22  		return fn(ctx, network, host)
    23  	}
    24  	testHookSetKeepAlive = func(time.Duration) {}
    25  
    26  	// testHookStepTime sleeps until time has moved forward by a nonzero amount.
    27  	// This helps to avoid flakes in timeout tests by ensuring that an implausibly
    28  	// short deadline (such as 1ns in the future) is always expired by the time
    29  	// a relevant system call occurs.
    30  	testHookStepTime = func() {}
    31  )
    32  

View as plain text