- Email2MMS now uses relay-hosts config rather than relay prefixes (nod to number portability)
This commit is contained in:
parent
47904ecd65
commit
f5834f50bb
|
@ -23,7 +23,7 @@ sendsms-password = foobar
|
|||
mms-port = 1981
|
||||
mm7-port = 1982
|
||||
#allow-ip = 192.168.129.11
|
||||
email2mms-relay-prefixes = "037;035;25637"
|
||||
email2mms-relay-hosts = "mbuni.org;dsmagic.com;ds.co.ug"
|
||||
billing-module-parameters = "/tmp/log/cdr.log"
|
||||
# billing-library = billdemo.so
|
||||
#prov-server-notify-script = ~/src/mmprov/provnotify.sh
|
||||
|
|
|
@ -1081,19 +1081,23 @@ lists all the configuration directives. Items in black are used by
|
|||
|
||||
<tr style="color: #500000; background: white">
|
||||
<td valign=top >
|
||||
<tt>email2mms-relay-prefixes</tt>
|
||||
<tt>email2mms-relay-hosts</tt>
|
||||
</td>
|
||||
<td valign=top >
|
||||
Number list
|
||||
</td>
|
||||
<td valign=top >
|
||||
When MMS is received
|
||||
A semi-colon separated list of hosts/domains. When MMS is received
|
||||
via SMTP, the gateway needs to determine whether it is for a local or a
|
||||
foreign recipient. To determine if the recipient is local recipient, we use
|
||||
the <tt>local-prefixes</tt> setting. If the recipient is not local,
|
||||
the message should be forwarded on to the relevant foreign MMS gateway, only
|
||||
if the recipient number matches one of the prefixes in this comma-separated
|
||||
list.
|
||||
the resolver module, if supplied. (Note that default resolution
|
||||
uses <tt>local-prefixes</tt> setting to determine if the recipient
|
||||
is local, returning the local MMSC name, if not, then it checks each
|
||||
of the defined relays to see if the recipient address is for one
|
||||
of them, by checking the prefixes, returning the matching
|
||||
proxy/relay name.) The resolver should return a host name that is
|
||||
matched against this setting. If any name matches, the message is
|
||||
queued, otherwise it is discarded.
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="color: #500000; background: white">
|
||||
|
|
|
@ -61,7 +61,7 @@ SINGLE_GROUP(mbuni,
|
|||
OCTSTR(mm7-port)
|
||||
OCTSTR(allow-ip)
|
||||
OCTSTR(deny-ip)
|
||||
OCTSTR(email2mms-relay-prefixes)
|
||||
OCTSTR(email2mms-relay-hosts)
|
||||
OCTSTR(billing-module-parameters)
|
||||
OCTSTR(billing-library)
|
||||
OCTSTR(resolver-module-parameters)
|
||||
|
|
|
@ -998,3 +998,24 @@ void _mms_fixup_address(Octstr *address)
|
|||
else
|
||||
octstr_append(address, octstr_imm("@unknown"));
|
||||
}
|
||||
|
||||
/* compare, reversed result! */
|
||||
static int comp_fn(void *item, void *pattern)
|
||||
{
|
||||
return (octstr_case_compare(item, pattern) == 0) ? 1 : 0;
|
||||
}
|
||||
int is_allowed_host(Octstr *host, Octstr *host_list)
|
||||
{
|
||||
List *l;
|
||||
int ret;
|
||||
gw_assert(host_list);
|
||||
gw_assert(host);
|
||||
|
||||
l = octstr_split(host_list, octstr_imm(";"));
|
||||
|
||||
ret = (list_search(l, host, comp_fn) != NULL) ? 1 : 0;
|
||||
|
||||
list_destroy(l, (void *)octstr_destroy);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -140,6 +140,9 @@ unsigned long _mshash(char *s);
|
|||
int isphonenum(Octstr *s);
|
||||
/* Fixup an address: Add type, etc. */
|
||||
void _mms_fixup_address(Octstr *address);
|
||||
|
||||
/* Check that host is one of hosts in semi-colon separated list in host_list */
|
||||
int is_allowed_host(Octstr *host, Octstr *host_list);
|
||||
#define MAXQTRIES 100
|
||||
#define BACKOFF_FACTOR 5*60 /* In seconds */
|
||||
#define QUEUERUN_INTERVAL 15*60 /* 15 minutes. */
|
||||
|
|
|
@ -197,8 +197,8 @@ MmscSettings *mms_load_mmsc_settings(mCfg *cfg, List **proxyrelays)
|
|||
m->allow_ip = _mms_cfg_getx(grp, octstr_imm("allow-ip"));
|
||||
m->deny_ip = _mms_cfg_getx(grp, octstr_imm("deny-ip"));
|
||||
|
||||
m->email2mmsrelay_prefixes = _mms_cfg_getx(grp,
|
||||
octstr_imm("email2mms-relay-prefixes"));
|
||||
m->email2mmsrelay_hosts = _mms_cfg_getx(grp,
|
||||
octstr_imm("email2mms-relay-hosts"));
|
||||
|
||||
m->prov_notify = _mms_cfg_getx(grp,octstr_imm("prov-server-notify-script"));
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ typedef struct MmscSettings {
|
|||
Octstr *allow_ip;
|
||||
Octstr *deny_ip;
|
||||
|
||||
Octstr *email2mmsrelay_prefixes;
|
||||
Octstr *email2mmsrelay_hosts;
|
||||
Octstr *sendsms_url;
|
||||
#if 0
|
||||
Octstr *sendsms_user, *sendsms_pass, *sendsms_globalsender;
|
||||
|
|
|
@ -39,6 +39,7 @@ int main(int argc, char *argv[])
|
|||
MmsMsg *msg;
|
||||
|
||||
Octstr *email;
|
||||
Octstr *home_mmsc = NULL;
|
||||
|
||||
mms_lib_init();
|
||||
|
||||
|
@ -78,10 +79,17 @@ int main(int argc, char *argv[])
|
|||
fixup_recipient();
|
||||
fixup_sender();
|
||||
|
||||
if (!xto ||
|
||||
(ttype == TPLMN && !does_prefix_match(settings->email2mmsrelay_prefixes, xto))) {
|
||||
error(0, " Not allowed to send to this recipient %s!",
|
||||
xto ? octstr_get_cstr(xto) : "(null)");
|
||||
if (xto && ttype == TPLMN) /* Get the home mmsc domain for this recipient. */
|
||||
home_mmsc = settings->mms_resolvefuncs->mms_resolve(xto,
|
||||
settings->mms_resolver_module_data,
|
||||
settings, proxyrelays);
|
||||
if (!xto ||
|
||||
(ttype == TPLMN && (!home_mmsc ||
|
||||
!is_allowed_host(home_mmsc,
|
||||
settings->email2mmsrelay_hosts)))) {
|
||||
error(0, " Not allowed to send to this recipient %s, resolved mmsc=%s!",
|
||||
xto ? octstr_get_cstr(xto) : "(null)",
|
||||
home_mmsc ? octstr_get_cstr(home_mmsc) : "(null)");
|
||||
mms_lib_shutdown();
|
||||
return -1;
|
||||
}
|
||||
|
@ -123,11 +131,9 @@ int main(int argc, char *argv[])
|
|||
|
||||
switch(mms_messagetype(msg)) {
|
||||
case MMS_MSGTYPE_SEND_REQ:
|
||||
if (ttype != TPLMN ||/* We only send to phones from this interface */
|
||||
!does_prefix_match(settings->email2mmsrelay_prefixes,
|
||||
xto)) {
|
||||
error(0, "Not allowed to send to %s!", octstr_get_cstr(xto));
|
||||
} else {
|
||||
if (ttype != TPLMN)
|
||||
error(0, "Not allowed to send to non-phone recipient, to=%s!", octstr_get_cstr(xto));
|
||||
else {
|
||||
List *lto = list_create();
|
||||
Octstr *qf;
|
||||
Octstr *msgid = mms_get_header_value(msg, octstr_imm("Message-ID"));
|
||||
|
@ -237,11 +243,9 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
break;
|
||||
case MMS_MSGTYPE_DELIVERY_IND:
|
||||
if (ttype != TPLMN ||/* We only send to phones from this interface */
|
||||
!does_prefix_match(settings->email2mmsrelay_prefixes,
|
||||
xto)) {
|
||||
if (ttype != TPLMN) /* We only send to phones from this interface */
|
||||
error(0, "Not allowed to send to %s!", octstr_get_cstr(xto));
|
||||
} else {
|
||||
else {
|
||||
List *lto = list_create();
|
||||
Octstr *qf;
|
||||
|
||||
|
@ -275,11 +279,9 @@ int main(int argc, char *argv[])
|
|||
|
||||
/* Fall through. */
|
||||
case MMS_MSGTYPE_READ_ORIG_IND:
|
||||
if (ttype != TPLMN ||/* We only send to phones from this interface */
|
||||
!does_prefix_match(settings->email2mmsrelay_prefixes,
|
||||
xto)) {
|
||||
if (ttype != TPLMN) /* We only send to phones from this interface */
|
||||
error(0, "Not allowed to send to %s!", octstr_get_cstr(xto));
|
||||
} else {
|
||||
else {
|
||||
List *lto = list_create();
|
||||
Octstr *qf;
|
||||
|
||||
|
@ -314,6 +316,7 @@ int main(int argc, char *argv[])
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mms_destroy(msg);
|
||||
mms_lib_shutdown();
|
||||
|
||||
|
|
Loading…
Reference in New Issue