playSMS Forum

Bug in kannel geturl.php


(Andres Maduro) #1

Hi,

I am using latest PlaySMS 1.4.2 on Ubuntu 18.04.

I have configured multiple KANNEL connections and they are working fine for sending SMS (MT). I currently have 3 kannels, one in localhost (with one direct SMMPP TX connection to Mobile Operator), one in 192.168.4.4 (modem pool) and one in 192.168.4.117 (connects to several operators through SMPP with RX/TX/TRX configs)

I configured Kannel sms-service to forward messages to PlaySMS as indicated in tutorial (see below) with a keyword and SMS are being received by PlaySMS but are not being reouted as the sender remote IP is different than current configured bearerbox IP. See below log extract from playsms.log.

The problem is very simple, geturl.php is checking the remote IP address against only one instance of kannel configuration (I guess the first one) which has an IP address of localhost, so when incoming SMS is being sent by 192.168.4.117 it is different than localhost (127.0.0.1).

You can see below the if condition that is found on geturl.php on kannel plugin which is now checking against multiple kannel configurations. I think this is a bug as only one kannel config will work correctly. This will mostly work for most of the users, but in my case will not work.

playsms.log:
192.168.4.117 playsms.telemo.com.ve 2018-12-09 23:07:31 PID5c0dd87387c71 - L2 kannel__call # start load:/usr/local/www/playsms.telemo.com.ve/html/playsms/plugin/gateway/kannel/geturl.php
192.168.4.117 playsms.telemo.com.ve 2018-12-09 23:07:31 PID5c0dd87387c71 - L2 kannel__incoming # unable to process incoming SMS. remote_addr:[192.168.4.117] or remote_host:[playsms.telemo.com.ve] does not match with your bearerbox_host config:[localhost] smsc:[digitel-157]

Since I have multiple kannel instances configured, getting into the geturl.php for kannel plugin I found the condition to check the IP addr of the remote against the configured bearerbox and found that it is checking this value against $plugin_config[‘kannel’][‘bearerbox_host’] which currently is getting the value for the first instance of the kannel config which is localhost in my case instead of 192.168.4.117 where the actual SMS are being received from.

This should be fairly easy to fix by changing manually the if condition and adding all the IPs of allowed configured kannel instances.

Is there a way to check multiple kannel instances and in case there is no match, then fails and log the issue ?

Here is the actual code for the if where you can show there is no checking for multiple instances of kannel smscs:

if ($remote_addr != $plugin_config[‘kannel’][‘bearerbox_host’])
if ($remote_addr != $plugin_config[‘kannel’][‘bearerbox_host’] && $remote_host != $plugin_config[‘kannel’][‘bearerbox_host’])
{
_log(“unable to process incoming SMS. remote_addr:[” . $remote_addr . “] or remote_host:[” . $remote_host . “] does no
t match with your bearerbox_host config:[” . $plugin_config[‘kannel’][‘bearerbox_host’] . “] smsc:[” . $smsc . “]”, 2, “kannel
incoming”);
exit();

Regards,


(Anton Raharja) #2

I’ll take a look at this, thanks.

anton


(Andres Maduro) #3

Hi Anton,

Found same problem in playsms/plugin/gateway/kannel/dlr.php (exactly same condition to check remote_addr is the same as configured in bearerbox host.

I had to manually add several IPs to a custom if.

Regards