net/memnet: export the network name (#9111)

This makes it more maintainable for other code to statically depend
on the exact value of this string. It also makes it easier to
identify what code might depend on this string by looking up
references to this constant.

Updates tailscale/corp#13777

Signed-off-by: Joe Tsai <joetsai@digital-static.net>
pull/9116/head
Joe Tsai 1 year ago committed by GitHub
parent 346dc5f37e
commit fcbb2bf348
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -9,6 +9,10 @@ import (
"time" "time"
) )
// NetworkName is the network name returned by [net.Addr.Network]
// for [net.Conn.LocalAddr] and [net.Conn.RemoteAddr] from the [Conn] type.
const NetworkName = "mem"
// Conn is a net.Conn that can additionally have its reads and writes blocked and unblocked. // Conn is a net.Conn that can additionally have its reads and writes blocked and unblocked.
type Conn interface { type Conn interface {
net.Conn net.Conn
@ -45,7 +49,7 @@ func NewTCPConn(src, dst netip.AddrPort, maxBuf int) (local Conn, remote Conn) {
type connAddr string type connAddr string
func (a connAddr) Network() string { return "mem" } func (a connAddr) Network() string { return NetworkName }
func (a connAddr) String() string { return string(a) } func (a connAddr) String() string { return string(a) }
type connHalf struct { type connHalf struct {

Loading…
Cancel
Save