// SPDX-FileCopyrightText: 2026 Matvey Shcherbinin // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL // KOutNet - one place to turn a socket address into a table key. #pragma once #include #include namespace koutnet { // Dual-stack sockets hand back IPv4 peers as "::ffff:10.0.0.5", and link-local // IPv6 carries a zone id ("fe80::1%eth0") that is local to one machine and // meaningless as a peer key. Presence, dialing, voice seats and the pin table // must all file the same peer under the same string, so this lives here rather // than being copied into each transport. inline QString normaliseAddress(const QHostAddress &addr) { QString s = addr.toString(); if (s.startsWith(QLatin1String("::ffff:"))) s = s.mid(7); const int zone = s.indexOf(QLatin1Char('%')); if (zone >= 0) s.truncate(zone); return s; } inline QString normaliseAddress(const QString &address) { return normaliseAddress(QHostAddress(address)); } } // namespace koutnet