* fix: prevent duplicate call link detection (#23) Co-authored-by: Maksim <maksim@MacBook-Pro-Maksim.local> * bot improvements (#25) Co-authored-by: Maksim <maksim@MBP-Maksim.lan> * headless vk video creator * add scroll to logs * allow peer reconnection * add todo about topology changes, kick stale peer to prevent SFU topology * unified relay for headless * remove relay binaries, extend build-go.sh to build them * refactor constants * limit headless resource usage * nuke everyone and yourself at sfu topology changes * add headless for creator * save bot enabled state * increment release version --------- Co-authored-by: Nevenuga <80585376+Nevenuga@users.noreply.github.com> Co-authored-by: Maksim <maksim@MacBook-Pro-Maksim.local> Co-authored-by: Maksim <maksim@MBP-Maksim.lan> Co-authored-by: kulikov <user@Mac.lan>
42 lines
769 B
Go
42 lines
769 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
)
|
|
|
|
// maskAddr masks the sensitive portion of an address for logging.
|
|
// IPv4: keeps first two octets, e.g. "192.168.x.x"
|
|
// IPv6: fully masked
|
|
// hostname: first char + "***"
|
|
// host:port: masks host, keeps port
|
|
func maskAddr(addr string) string {
|
|
host, port, err := net.SplitHostPort(addr)
|
|
if err != nil {
|
|
host = addr
|
|
port = ""
|
|
}
|
|
masked := maskHost(host)
|
|
if port != "" {
|
|
return net.JoinHostPort(masked, port)
|
|
}
|
|
return masked
|
|
}
|
|
|
|
func maskHost(host string) string {
|
|
if host == "" {
|
|
return ""
|
|
}
|
|
ip := net.ParseIP(host)
|
|
if ip != nil {
|
|
if ip4 := ip.To4(); ip4 != nil {
|
|
return fmt.Sprintf("%d.%d.x.x", ip4[0], ip4[1])
|
|
}
|
|
return "x::x"
|
|
}
|
|
if len(host) <= 1 {
|
|
return "*"
|
|
}
|
|
return string(host[0]) + "***"
|
|
}
|