Merge pull request #15625 from ANR2ME/adhoc

Mask some part of public IP in the logs for security reason.
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2022-06-25 07:47:02 +02:00
commit d64100b75f
2 files changed
+6 -3

No files matched your search

+5 -2
View File
@@ -170,10 +170,13 @@ bool isPTPPortInUse(uint16_t port, bool forListen, SceNetEtherAddr* dstmac, uint
}
// Replacement for inet_ntoa since it's getting deprecated
std::string ip2str(in_addr in) {
std::string ip2str(in_addr in, bool maskPublicIP) {
char str[INET_ADDRSTRLEN] = "...";
u8* ipptr = (u8*)∈
snprintf(str, sizeof(str), "%u.%u.%u.%u", ipptr[0], ipptr[1], ipptr[2], ipptr[3]);
if (maskPublicIP && !isPrivateIP(in.s_addr))
snprintf(str, sizeof(str), "%u.%u.xx.%u", ipptr[0], ipptr[1], ipptr[3]);
else
snprintf(str, sizeof(str), "%u.%u.%u.%u", ipptr[0], ipptr[1], ipptr[2], ipptr[3]);
return std::string(str);
}
+1 -1
View File
@@ -1014,7 +1014,7 @@ bool isPDPPortInUse(uint16_t port);
bool isPTPPortInUse(uint16_t port, bool forListen, SceNetEtherAddr* dstmac = nullptr, uint16_t dstport = 0);
// Convert IPv4 address to string (Replacement for inet_ntoa since it's getting deprecated)
std::string ip2str(in_addr in);
std::string ip2str(in_addr in, bool maskPublicIP = true);
// Convert MAC address to string
std::string mac2str(SceNetEtherAddr* mac);