Censor caller ID and full phone numbers --- PjsuaCommunicator.cpp +++ PjsuaCommunicator.cpp @@ -5,6 +5,7 @@ #include #include +#include using namespace std; @@ -131,6 +132,7 @@ namespace sip { void _Call::onCallState(pj::OnCallStateParam &prm) { auto ci = getInfo(); + boost::regex re("(?:\"[^\"]+\" )?sip:([0-9]{4})[0-9]+@"); communicator.logger.info("Call %d state=%s.", ci.id, ci.stateText.c_str()); @@ -138,6 +140,7 @@ namespace sip { boost::replace_all(address, "<", ""); boost::replace_all(address, ">", ""); + address = boost::regex_replace(address, re, "sip:$1XXXXXX@"); if (ci.state == PJSIP_INV_STATE_CONFIRMED) { auto msgText = "Incoming call from " + address + ".";