dOpensource / dsiprouter

UI Interface for implementing Kamailio to provide PBX Hosting and SIP Trunking Services
https://dsiprouter.org
Apache License 2.0
196 stars 103 forks source link

Server Issue (Detailed Information: list index out of range) #468

Closed OsvaldoSierra closed 1 year ago

OsvaldoSierra commented 1 year ago

Hi DSIProuter team! I have the next issue trying to open an endpoint from the Endpoint list. I'll share PS to show the step by step:

1) Enter to "Endpoints group" 2) Just click on "Troncal remoto" (ID=13) image

After click I got this error message: image

Extra data: If i click the other Endpoint (ID=12) I have no problem, that Endpoint opens well.

Thank you in advance.

mackhendricks commented 1 year ago

@devopsec Can you please look into this.

devopsec commented 1 year ago

@OsvaldoSierra can you provide the following:

For the last one in particular; what state was the system in before this issue occurred.

OsvaldoSierra commented 1 year ago

Hi guys. Here the info:

1) OS Info: PRETTY_NAME="Debian GNU/Linux 10 (buster)" NAME="Debian GNU/Linux" VERSION_ID="10" VERSION="10 (buster)" VERSION_CODENAME=buster ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"

2) DSIPRouter version: 0.70

3) Cloud enviroment: Huawei cloud (Hiperstack)

4) Just click on "Endpoint Groups" (Left menu) => Click on a Endpoint called "TroncalRemoto" => Next the error I've shown on my PS.

devopsec commented 1 year ago

We haven't tested on the Huawei cloud platform but if your network settings are correct then that wouldn't be the cause of this issue.
Can you start dsiprouter in debug mode and attach the stack trace from /var/log/dsiprouter.log?

You can start in debug mode by running:

dsiprouter restart -debug
devopsec commented 1 year ago

@OsvaldoSierra please attach dsiprouter.log from when this issue occurs

OsvaldoSierra commented 1 year ago

Hi team! Sure, I'll share it with you in a few hours

OsvaldoSierra commented 1 year ago

dsiprouter.log

Hi team. Here I'm adding the dsiprouter.log. I've replied the error after dsiprouter restart -debug command. The testing time was at:

root@dsiprouter-prueba-osvaldo:~# date Sat 17 Dec 2022 02:28:46 AM CST

devopsec commented 1 year ago

Issue occurs due to no weight validation in endpoint group api checks.
This should not happen in normal use as the api puts in a default value.

Below is a workaround that will allow the attrs column of the dispatcher table to be empty:

diff --git a/gui/modules/api/api_routes.py b/gui/modules/api/api_routes.py
index 68f8d00..aea2c2b 100644
--- a/gui/modules/api/api_routes.py
+++ b/gui/modules/api/api_routes.py
@@ -862,9 +862,12 @@ def getEndpointGroup(gwgroupid):
             dispatcher = db.query(Dispatcher).filter(Dispatcher.setid == gwgroupid)
             if dispatcher:
                 weightList = {}
-                for item in dispatcher:
-                    weight = item.attrs.split('=')[1]
-                    weightList[item.destination[4:]] = weight
+                try:
+                    for item in dispatcher:
+                        weight = item.attrs.split('=')[1]
+                        weightList[item.destination[4:]] = weight
+                except IndexError:
+                    pass

             for endpoint in endpoints:
                 ep = {}
devopsec commented 1 year ago

Will commit a better solution in v0.72, the workaround is only temporary