ContextDialer returns a ContextDialer that wraps d and injects n's latency in its connections. n's Latency is also injected to the connection's creation.
(d ContextDialer)
| 307 | // in its connections. n's Latency is also injected to the connection's |
| 308 | // creation. |
| 309 | func (n *Network) ContextDialer(d ContextDialer) ContextDialer { |
| 310 | if n.isLocal() { |
| 311 | return d |
| 312 | } |
| 313 | return func(ctx context.Context, network, address string) (net.Conn, error) { |
| 314 | conn, err := d(ctx, network, address) |
| 315 | if err != nil { |
| 316 | return nil, err |
| 317 | } |
| 318 | return n.Conn(conn) |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | // pktTime returns the time it takes to transmit one packet of data of size b |
| 323 | // in bytes. |
no test coverage detected