Added strip-prefixes config param
This commit is contained in:
parent
b31790def4
commit
e1c18c07a4
|
@ -1,3 +1,5 @@
|
|||
2008-05-05 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||
* Added strip-prefixes config parameter
|
||||
2008-04-18 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||
* Various memory leak fixes (thanks to Monachin Eric @ Skycore)
|
||||
2008-04-11 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||
|
|
|
@ -35,6 +35,7 @@ mms-to-email-txt = "This is a multimedia message (HTML suppressed)"
|
|||
mms-to-email-html = "This is a multimedia message powered by <emph>Digital Solutions</emph>"
|
||||
mms-to-email-default-subject = "This is a multimedia message"
|
||||
mms-message-too-large-txt = "You have received a multimedia message from %S that is too large for your phone. Go to xxx to view it"
|
||||
strip-prefixes = "1;2"
|
||||
|
||||
group = mms-vasp
|
||||
vasp-id = newscorp
|
||||
|
|
|
@ -821,6 +821,28 @@ lists all the configuration directives. The column <b>Mode</b>
|
|||
after variable substitution, hence parameter quoting is not necessary.)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign=top >
|
||||
<tt>strip-prefixes
|
||||
|
||||
</td>
|
||||
|
||||
<td valign=top >
|
||||
<i>ALL</i>
|
||||
|
||||
</td>
|
||||
|
||||
<td valign=top >
|
||||
Number list
|
||||
</td>
|
||||
<td valign=top >
|
||||
A semi-colon (;) separated string of prefixes that should (if
|
||||
found) be stripped of the phone number <i>prior</i> to number
|
||||
normalisation as described below. Only the first prefix that matches
|
||||
will be stripped.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign=top >
|
||||
<tt>unified-prefix
|
||||
|
@ -845,6 +867,7 @@ lists all the configuration directives. The column <b>Mode</b>
|
|||
there are several unified prefixes, separate their rules with semicolon (';')
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign=top >
|
||||
<tt>maximum-send-attempts
|
||||
|
|
|
@ -2,7 +2,7 @@ This module provides Queue management for mbuni using PostgreSQL as the storage
|
|||
To use it, you need only add two lines to the mbuni config 'mbuni' group:
|
||||
|
||||
queue-manager-module = "/path_to/libmms_pgsql_queue.so"
|
||||
queue-module-init-data = "number_of_db_connections:host=dbhost user=db_user passwowrd=dbpassword dbname=dbname"
|
||||
queue-module-init-data = "number_of_db_connections:host=dbhost user=db_user password=dbpassword dbname=dbname"
|
||||
|
||||
Make sure the database you are trying to connect to has already been created
|
||||
and the relevant tables created using the supplied file "tables.sql".
|
||||
|
|
|
@ -50,6 +50,7 @@ SINGLE_GROUP(mbuni,
|
|||
OCTSTR(max-send-threads)
|
||||
OCTSTR(send-mail-prog)
|
||||
OCTSTR(unified-prefix)
|
||||
OCTSTR(strip-prefixes)
|
||||
OCTSTR(maximum-send-attempts)
|
||||
OCTSTR(default-message-expiry)
|
||||
OCTSTR(queue-run-interval)
|
||||
|
|
|
@ -264,7 +264,7 @@ static MmsEnvelope *mms_queue_readenvelope(char *qf, char *mms_queuedir, int sho
|
|||
if (mms_validate_address(e->from) != 0) {
|
||||
warning(0, "mms_queueread: Mal-formed address [%s] in file %s! "
|
||||
"Attempting fixup.", res, xqf);
|
||||
_mms_fixup_address(&e->from, NULL, 1);
|
||||
_mms_fixup_address(&e->from, NULL, NULL, 1);
|
||||
}
|
||||
break;
|
||||
case 'R':
|
||||
|
@ -273,7 +273,7 @@ static MmsEnvelope *mms_queue_readenvelope(char *qf, char *mms_queuedir, int sho
|
|||
if (mms_validate_address(t) != 0) {
|
||||
warning(0, "mms_queueread: Mal-formed address [%s] in file %s! "
|
||||
"Attempting fixup.", res, xqf);
|
||||
_mms_fixup_address(&t, NULL, 1);
|
||||
_mms_fixup_address(&t, NULL, NULL, 1);
|
||||
}
|
||||
to = gw_malloc(sizeof *to);
|
||||
to->rcpt = t;
|
||||
|
|
|
@ -982,8 +982,29 @@ int isphonenum(Octstr *s)
|
|||
return 1;
|
||||
}
|
||||
|
||||
void mms_normalize_phonenum(Octstr **num, char *unified_prefix, List *strip_prefixes)
|
||||
{
|
||||
int i, n;
|
||||
|
||||
if (num == NULL ||
|
||||
*num == NULL)
|
||||
return;
|
||||
|
||||
/* stip prefix first. */
|
||||
for (i = 0, n = gwlist_len(strip_prefixes); i<n;i++) {
|
||||
Octstr *x = gwlist_get(strip_prefixes, i);
|
||||
if (octstr_search(*num, x, 0) == 0) {
|
||||
octstr_delete(*num, 0, octstr_len(x));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (unified_prefix)
|
||||
normalize_number(unified_prefix, num);
|
||||
}
|
||||
|
||||
/* Doesn't handle IP addresses very well */
|
||||
void _mms_fixup_address(Octstr **address, char *unified_prefix, int keep_suffix)
|
||||
void _mms_fixup_address(Octstr **address, char *unified_prefix, List *strip_prefixes, int keep_suffix)
|
||||
{
|
||||
int i;
|
||||
Octstr *typ;
|
||||
|
@ -1002,7 +1023,7 @@ void _mms_fixup_address(Octstr **address, char *unified_prefix, int keep_suffix)
|
|||
|
||||
if (isphonenum(*address) || (typ && octstr_str_compare(typ, "/TYPE=PLMN") == 0)) {
|
||||
if (unified_prefix)
|
||||
normalize_number(unified_prefix, address);
|
||||
mms_normalize_phonenum(address, unified_prefix, strip_prefixes);
|
||||
octstr_append(*address, keep_suffix ? octstr_imm("/TYPE=PLMN") : octstr_imm(""));
|
||||
} else if (typ)
|
||||
octstr_append(*address, keep_suffix ? typ : octstr_imm(""));
|
||||
|
|
|
@ -154,7 +154,10 @@ unsigned long _mshash(char *s);
|
|||
/* Tell us whether address is a phone number. */
|
||||
int isphonenum(Octstr *s);
|
||||
/* Fixup an address: Normalize number (if prefix given), Add type (if keep_suffix is set), etc. */
|
||||
void _mms_fixup_address(Octstr **address, char *unified_prefix, int keep_suffix);
|
||||
void _mms_fixup_address(Octstr **address, char *unified_prefix, List *strip_prefixes, int keep_suffix);
|
||||
|
||||
/* normalize a phone number: Strip any prefixes, then normalize. */
|
||||
void mms_normalize_phonenum(Octstr **num, char *unified_prefix, List *strip_prefixes);
|
||||
|
||||
/* Check that host is one of hosts in semi-colon separated list in host_list */
|
||||
int is_allowed_host(Octstr *host, Octstr *host_list);
|
||||
|
|
|
@ -887,7 +887,8 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers,
|
|||
for (j = 0; j < gwlist_len(hv); j++) {
|
||||
Octstr *v = gwlist_get(hv, j);
|
||||
/* Fix the address. */
|
||||
_mms_fixup_address(&v, unified_prefix ? octstr_get_cstr(unified_prefix) : NULL, 1);
|
||||
_mms_fixup_address(&v, unified_prefix ? octstr_get_cstr(unified_prefix) : NULL,
|
||||
strip_prefixes, 1);
|
||||
gwlist_append(xto, v);
|
||||
}
|
||||
octstr_destroy(v);
|
||||
|
@ -944,7 +945,7 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers,
|
|||
xservice_code = octstr_duplicate(hsvc_code);
|
||||
|
||||
if (from)
|
||||
_mms_fixup_address(&from, NULL, 1); /* Don't normalise. */
|
||||
_mms_fixup_address(&from, NULL, NULL, 1); /* Don't normalise. */
|
||||
|
||||
/* Now get the data. */
|
||||
if (octstr_case_compare(ctype, octstr_imm("application/vnd.wap.mms-message")) == 0)
|
||||
|
@ -1292,7 +1293,7 @@ static void sendmms_func(void *unused)
|
|||
|
||||
if ((from = http_cgi_variable(cgivars, "from")) != NULL) {
|
||||
from = octstr_duplicate(from);
|
||||
_mms_fixup_address(&from, NULL, 1);
|
||||
_mms_fixup_address(&from, NULL, NULL, 1);
|
||||
if (from)
|
||||
HTTP_REPLACE_HEADER(rh, "X-Mbuni-From", octstr_get_cstr(from));
|
||||
octstr_destroy(from);
|
||||
|
|
|
@ -32,6 +32,8 @@ long mmsbox_maxsendattempts, mmsbox_send_back_off, default_msgexpiry;
|
|||
long maxthreads = 0;
|
||||
double queue_interval = -1;
|
||||
Octstr *unified_prefix = NULL;
|
||||
List *strip_prefixes = NULL;
|
||||
|
||||
int mt_multipart = 0;
|
||||
MmsQueueHandlerFuncs *qfs; /* queue functions. */
|
||||
MmsBoxResolverFuncStruct *rfs; /* resolver functions. */
|
||||
|
@ -123,10 +125,14 @@ int mms_load_mmsbox_settings(mCfg *cfg, gwthread_func_t *mmsc_handler_func)
|
|||
if (queue_interval <= 0)
|
||||
queue_interval = QUEUERUN_INTERVAL;
|
||||
|
||||
|
||||
|
||||
unified_prefix = _mms_cfg_getx(grp, octstr_imm("unified-prefix"));
|
||||
|
||||
if ((s = mms_cfg_get(grp, octstr_imm("strip-prefixes"))) != NULL) {
|
||||
strip_prefixes = octstr_split(s, octstr_imm(";"));
|
||||
octstr_destroy(s);
|
||||
} else
|
||||
strip_prefixes = NULL;
|
||||
|
||||
mms_cfg_get_int(grp, octstr_imm("sendmms-port"), &sendmms_port.port);
|
||||
#ifdef HAVE_LIBSSL
|
||||
mms_cfg_get_bool(grp, octstr_imm("sendmms-port-ssl"), &send_port_ssl);
|
||||
|
@ -531,9 +537,9 @@ Octstr *get_mmsbox_queue_dir(Octstr *from, List *to, MmscGrp *m,
|
|||
|
||||
|
||||
if (unified_prefix)
|
||||
_mms_fixup_address(&xfrom, octstr_get_cstr(unified_prefix), 0);
|
||||
_mms_fixup_address(&xfrom, octstr_get_cstr(unified_prefix), strip_prefixes, 0);
|
||||
if (unified_prefix)
|
||||
_mms_fixup_address(&fto, octstr_get_cstr(unified_prefix), 0);
|
||||
_mms_fixup_address(&fto, octstr_get_cstr(unified_prefix), strip_prefixes, 0);
|
||||
|
||||
_mcid = rfs->mmsbox_resolve(xfrom,fto,octstr_get_cstr(m->id), rfs_data, rfs_settings);
|
||||
|
||||
|
@ -543,7 +549,7 @@ Octstr *get_mmsbox_queue_dir(Octstr *from, List *to, MmscGrp *m,
|
|||
octstr_destroy(fto);
|
||||
} else {
|
||||
if (unified_prefix)
|
||||
_mms_fixup_address(&fto, octstr_get_cstr(unified_prefix), 1);
|
||||
_mms_fixup_address(&fto, octstr_get_cstr(unified_prefix), strip_prefixes, 1);
|
||||
gwlist_insert(to, 0, fto);
|
||||
octstr_destroy(xto);
|
||||
}
|
||||
|
|
|
@ -94,6 +94,7 @@ extern List *mms_services; /* list of MMS Services */
|
|||
extern List *mmscs; /* MMSC list. Perhaps turn into a Dict instead? */
|
||||
extern Octstr *incoming_qdir, *outgoing_qdir, *dlr_dir;
|
||||
extern Octstr *unified_prefix;
|
||||
extern List *strip_prefixes;
|
||||
extern long mmsbox_maxsendattempts, mmsbox_send_back_off, default_msgexpiry;
|
||||
extern long maxthreads;
|
||||
extern double queue_interval;
|
||||
|
|
|
@ -65,6 +65,11 @@ MmscSettings *mms_load_mmsc_settings(mCfg *cfg, List **proxyrelays)
|
|||
m->unified_prefix = _mms_cfg_getx(grp, octstr_imm("unified-prefix"));
|
||||
m->local_prefix = _mms_cfg_getx(grp, octstr_imm("local-prefixes"));
|
||||
|
||||
if ((s = mms_cfg_get(grp, octstr_imm("strip-prefixes"))) != NULL) {
|
||||
m->strip_prefixes = octstr_split(s, octstr_imm(";"));
|
||||
octstr_destroy(s);
|
||||
} else
|
||||
m->strip_prefixes = NULL;
|
||||
|
||||
if (m->hostname == NULL || octstr_len(m->hostname) == 0)
|
||||
m->hostname = octstr_create("localhost");
|
||||
|
@ -324,7 +329,7 @@ MmscSettings *mms_load_mmsc_settings(mCfg *cfg, List **proxyrelays)
|
|||
m->mms2mobile = mv;
|
||||
}
|
||||
|
||||
if ((s = _mms_cfg_getx(grp, octstr_imm("send-uaprof"))) != NULL){
|
||||
if ((s = mms_cfg_get(grp, octstr_imm("send-uaprof"))) != NULL){
|
||||
if (octstr_str_case_compare(s, "url") == 0)
|
||||
mv->send_uaprof = UAProf_URL;
|
||||
else if (octstr_str_case_compare(s, "ua") == 0)
|
||||
|
|
|
@ -40,6 +40,9 @@ typedef struct MmscSettings {
|
|||
Octstr *system_user;
|
||||
Octstr *name, *hostname, *host_alias;
|
||||
Octstr *unified_prefix, *local_prefix;
|
||||
|
||||
List *strip_prefixes;
|
||||
|
||||
Octstr *sendmail;
|
||||
|
||||
Octstr *global_queuedir, *mm1_queuedir;
|
||||
|
|
|
@ -521,7 +521,13 @@ static void fixup_recipient(void)
|
|||
/* XXX may be we should use fixup function in mmlib/mms_util.c ?? */
|
||||
if (isphonenum(xto) &&
|
||||
(!typ || octstr_str_compare(typ, "TYPE=PLMN") == 0)) { /* A phone number. */
|
||||
#if 0
|
||||
normalize_number(octstr_get_cstr(settings->unified_prefix), &xto);
|
||||
#else
|
||||
mms_normalize_phonenum(&xto,
|
||||
octstr_get_cstr(settings->unified_prefix),
|
||||
settings->strip_prefixes);
|
||||
#endif
|
||||
ttype = TPLMN;
|
||||
} else { /* For now everything else is email. */
|
||||
ttype = TEMAIL;
|
||||
|
|
|
@ -79,7 +79,7 @@ static int sendMsg(MmsEnvelope *e)
|
|||
MmsEnvelopeTo *to = gwlist_get(e->to, i);
|
||||
Octstr *s = octstr_duplicate(to->rcpt);
|
||||
|
||||
_mms_fixup_address(&s, octstr_get_cstr(settings->unified_prefix), 1);
|
||||
_mms_fixup_address(&s, octstr_get_cstr(settings->unified_prefix), settings->strip_prefixes, 1);
|
||||
gwlist_append(l, s);
|
||||
}
|
||||
|
||||
|
@ -244,8 +244,13 @@ static int sendMsg(MmsEnvelope *e)
|
|||
|
||||
if (sent != 1) { /* Not yet, sent, find the receiver MMSC. */
|
||||
/* Normalise the number, then see if we can resolve home MMSC for this recipient. */
|
||||
#if 0
|
||||
normalize_number(octstr_get_cstr(settings->unified_prefix), &phonenum);
|
||||
|
||||
#else
|
||||
mms_normalize_phonenum(&phonenum,
|
||||
octstr_get_cstr(settings->unified_prefix),
|
||||
settings->strip_prefixes);
|
||||
#endif
|
||||
if ((mmsc = settings->mms_resolvefuncs->mms_resolve(phonenum,
|
||||
settings->mms_resolver_module_data,
|
||||
settings, proxyrelays))) {
|
||||
|
|
|
@ -285,7 +285,13 @@ static int sendNotify(MmsEnvelope *e)
|
|||
|
||||
if (j > 0 && j - 1 + sizeof "/TYPE=PLMN" == len) { /* A proper number. */
|
||||
phonenum = octstr_copy(to, 0, j);
|
||||
#if 0
|
||||
normalize_number(octstr_get_cstr(settings->unified_prefix), &phonenum);
|
||||
#else
|
||||
mms_normalize_phonenum(&phonenum,
|
||||
octstr_get_cstr(settings->unified_prefix),
|
||||
settings->strip_prefixes);
|
||||
#endif
|
||||
} else if (k > 0 && k + sizeof "/TYPE=IPv" == len)
|
||||
rcpt_ip = octstr_copy(to, 0, k);
|
||||
else {
|
||||
|
|
|
@ -182,7 +182,13 @@ int main(int argc, char *argv[])
|
|||
else
|
||||
h.client_addr = octstr_duplicate(h.base_client_addr);
|
||||
} else { /* A bare number, normalise it. */
|
||||
#if 0
|
||||
normalize_number(octstr_get_cstr(settings->unified_prefix), &h.base_client_addr);
|
||||
#else
|
||||
mms_normalize_phonenum(&h.base_client_addr,
|
||||
octstr_get_cstr(settings->unified_prefix),
|
||||
settings->strip_prefixes);
|
||||
#endif
|
||||
if (octstr_case_search(h.base_client_addr, octstr_imm("TYPE="),0) < 0)
|
||||
h.client_addr = octstr_format("%S/TYPE=PLMN", h.base_client_addr);
|
||||
else
|
||||
|
|
|
@ -110,7 +110,8 @@ int main(int argc, char *argv[])
|
|||
while ((x = gwlist_extract_first(to)) != NULL) {
|
||||
octstr_strip_blanks(x);
|
||||
_mms_fixup_address(&x,
|
||||
settings->unified_prefix ? octstr_get_cstr(settings->unified_prefix) : NULL, 1);
|
||||
settings->unified_prefix ? octstr_get_cstr(settings->unified_prefix) : NULL,
|
||||
settings->strip_prefixes, 1);
|
||||
gwlist_append(l, x);
|
||||
}
|
||||
gwlist_destroy(to, NULL);
|
||||
|
@ -119,7 +120,8 @@ int main(int argc, char *argv[])
|
|||
|
||||
/* fix from address. */
|
||||
_mms_fixup_address(&from,
|
||||
settings->unified_prefix ? octstr_get_cstr(settings->unified_prefix) : NULL, 1);
|
||||
settings->unified_prefix ? octstr_get_cstr(settings->unified_prefix) : NULL,
|
||||
settings->strip_prefixes, 1);
|
||||
|
||||
#if 0
|
||||
mms_start_profile_engine(octstr_get_cstr(settings->ua_profile_cache_dir));
|
||||
|
|
Loading…
Reference in New Issue