mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-21 12:28:39 +00:00
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>
This commit is contained in:
parent
346dc5f37e
commit
fcbb2bf348
@ -9,6 +9,10 @@ import (
|
||||
"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.
|
||||
type Conn interface {
|
||||
net.Conn
|
||||
@ -45,7 +49,7 @@ func NewTCPConn(src, dst netip.AddrPort, maxBuf int) (local Conn, remote Conn) {
|
||||
|
||||
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) }
|
||||
|
||||
type connHalf struct {
|
||||
|
Loading…
x
Reference in New Issue
Block a user