Commit 7de1d102 authored by Simon Morlat's avatar Simon Morlat

Implement regexp matching of client certificate subjects.

parent 45acb7c2
......@@ -26,6 +26,7 @@
#include <sofia-sip/msg_addr.h>
#include "sipattrextractor.hh"
using namespace std;
void MsgSip::assignMsg(msg_t *msg) {
......@@ -267,6 +268,23 @@ void RequestSipEvent::suspendProcessing() {
RequestSipEvent::~RequestSipEvent() {
}
bool RequestSipEvent::matchIncomingSubject(regex_t *regex){
const su_strlst_t *strlst = tport_delivered_from_subjects(mIncomingTport.get(), mMsgSip->getMsg());
int count = su_strlst_len(strlst);
for (int k = 0 ; k < count ; ++k){
const char *subj = su_strlst_item(strlst, k);
LOGD("matchIncomingSubject %s", subj);
int res = regexec(regex, subj, 0, NULL, 0);
if (res == 0) {
return true;
}else if (res != REG_NOMATCH){
LOGE("RequestSipEvent::matchIncomingSubject() regexec() returned unexpected %i", res);
}
}
return false;
}
bool RequestSipEvent::findIncomingSubject(const char *searched) {
auto strlst = tport_delivered_from_subjects(mIncomingTport.get(), mMsgSip->getMsg());
return !!tport_subject_search(searched, strlst);
......
......@@ -28,6 +28,8 @@
#include <sofia-sip/sip.h>
#include <sofia-sip/nta.h>
#include <regex.h>
class Agent;
class Module;
class IncomingAgent;
......@@ -194,6 +196,7 @@ class RequestSipEvent : public SipEvent {
/** Find if incoming tport TLS client certificate contains a given entry */
bool findIncomingSubject(const char *searched);
const char *findIncomingSubject(const std::list<std::string> &in);
bool matchIncomingSubject(regex_t *regex);
void unlinkTransactions();
const std::shared_ptr<tport_t> &getIncomingTport() const {
return mIncomingTport;
......
......@@ -610,6 +610,7 @@ int main(int argc, char *argv[]) {
Stats *presence_stats = NULL;
#endif
bool debug;
bool user_errors = false;
map<string, string> oset;
string versionString = version();
......@@ -747,6 +748,9 @@ int main(int argc, char *argv[]) {
if (cfg->getGlobal()->get<ConfigBoolean>("debug")->read()){
debug = true;
}
}else{
//if --debug is given, enable user-errors logs as well.
user_errors = true;
}
bool dump_cores = cfg->getGlobal()->get<ConfigBoolean>("dump-corefiles")->read();
......@@ -781,7 +785,7 @@ int main(int argc, char *argv[]) {
// Initialize
std::string log_level = cfg->getGlobal()->get<ConfigString>("log-level")->read();
std::string syslog_level = cfg->getGlobal()->get<ConfigString>("syslog-level")->read();
bool user_errors = cfg->getGlobal()->get<ConfigBoolean>("user-errors-logs")->read();
if (!user_errors) user_errors = cfg->getGlobal()->get<ConfigBoolean>("user-errors-logs")->read();
ortp_set_log_handler(NULL); /*remove ortp's default log handler that logs to stdout*/
ortp_init();
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment