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  )
    10  
    11  var (
    12  	// if non-nil, overrides dialTCP.
    13  	testHookDialTCP func(ctx context.Context, net string, laddr, raddr *TCPAddr) (*TCPConn, error)
    14  
    15  	testHookLookupIP = func(
    16  		ctx context.Context,
    17  		fn func(context.Context, string, string) ([]IPAddr, error),
    18  		network string,
    19  		host string,
    20  	) ([]IPAddr, error) {
    21  		return fn(ctx, network, host)
    22  	}
    23  	testPreHookSetKeepAlive = func(*netFD) {}
    24  	testHookSetKeepAlive    = func(KeepAliveConfig) {}
    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