mirror of
https://github.com/daeuniverse/dae.git
synced 2025-08-04 01:00:02 +07:00
chore: adjust directory structure
This commit is contained in:
25
control/addr.go
Normal file
25
control/addr.go
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright (c) since 2023, mzz2017 <mzz@tuta.io>
|
||||
*/
|
||||
|
||||
package control
|
||||
|
||||
import (
|
||||
"net"
|
||||
"net/netip"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func RefineSourceToShow(src netip.AddrPort, dAddr netip.Addr) (srcToShow string) {
|
||||
if src.Addr() == dAddr {
|
||||
// If nothing else, this means this packet is sent from localhost.
|
||||
return net.JoinHostPort("localhost", strconv.Itoa(int(src.Port())))
|
||||
} else {
|
||||
return RefineAddrPortToShow(src)
|
||||
}
|
||||
}
|
||||
|
||||
func RefineAddrPortToShow(addrPort netip.AddrPort) (srcToShow string) {
|
||||
return net.JoinHostPort(net.IP(addrPort.Addr().AsSlice()).String(), strconv.Itoa(int(addrPort.Port())))
|
||||
}
|
Reference in New Issue
Block a user