-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: deprecate the netipx package (#53)
I moved it basically immediately to rbmk-project/common since x depends on dnscore, so dnscore cannot depend on x. While there, update deps.
- Loading branch information
1 parent
4cc2756
commit 0e28dad
Showing
4 changed files
with
10 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,11 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
// Package netipx contains [net/netip] extensions. | ||
// | ||
// Deprecated: use github.com/rbmk-project/common/netipx instead. | ||
package netipx | ||
|
||
import ( | ||
"net" | ||
"net/netip" | ||
) | ||
import "github.com/rbmk-project/common/netipx" | ||
|
||
// AddrToAddrPort converts a [net.Addr] to a [netip.AddrPort]. | ||
// | ||
// If the input is nil or neither a [*net.TCPAddr] nor [*net.UDPAddr], | ||
// returns an unspecified IPv6 address with port 0. | ||
// | ||
// For [*net.TCPAddr] and [*net.UDPAddr] addresses, returns their | ||
// corresponding [netip.AddrPort] representation. | ||
func AddrToAddrPort(addr net.Addr) netip.AddrPort { | ||
if addr == nil { | ||
return netip.AddrPortFrom(netip.IPv6Unspecified(), 0) | ||
} | ||
if tcp, ok := addr.(*net.TCPAddr); ok { | ||
return tcp.AddrPort() | ||
} | ||
if udp, ok := addr.(*net.UDPAddr); ok { | ||
return udp.AddrPort() | ||
} | ||
return netip.AddrPortFrom(netip.IPv6Unspecified(), 0) | ||
} | ||
// AddrToAddrPort is an alias for [netipx.AddrToAddrPort]. | ||
var AddrToAddrPort = netipx.AddrToAddrPort |
This file was deleted.
Oops, something went wrong.