Compare commits

...

3 Commits

Author SHA1 Message Date
Ahnaf Tahmid 5b7ee5e26a TLS/SSL support not available 2022-08-31 01:09:33 +06:00
Ahnaf Tahmid 200b0f1c1b try added bug fix 2022-08-31 01:03:16 +06:00
Ahnaf Tahmid ae401eae3d Categories Development remove 2022-08-31 01:02:40 +06:00
28 changed files with 240 additions and 413 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -4,133 +4,150 @@ import time
def get_subscribers_list():
t = telnetlib.Telnet("localhost", 4258)
t.write(b"enable \r\n\r")
t.write(b"show subscribers all \r\n\r")
try:
t = telnetlib.Telnet("localhost", 4258)
t.write(b"enable \r\n\r")
t.write(b"show subscribers all \r\n\r")
time.sleep(0.01)
read = t.read_very_eager()
subscribers = read.rsplit(b"NAM")[1].split(b"\r\n")[2:-4]
subscribers = [subscriber.decode().split() for subscriber in subscribers]
t.close()
return subscribers
time.sleep(0.01)
read = t.read_very_eager()
subscribers = read.rsplit(b"NAM")[1].split(b"\r\n")[2:-4]
subscribers = [subscriber.decode().split() for subscriber in subscribers]
t.close()
return subscribers
except:
return []
def get_subscribers_last_seen():
t = telnetlib.Telnet("localhost", 4258)
t.write(b"enable \r\n\r")
t.write(b"show subscribers last-seen \r\n\r")
time.sleep(0.01)
read = t.read_very_eager()
subscribers = read.rsplit(b"NAM")[1].split(b"\r\n")[2:-4]
subscribers = [subscriber.decode().split() for subscriber in subscribers]
t.close()
return subscribers
try:
t = telnetlib.Telnet("localhost", 4258)
t.write(b"enable \r\n\r")
t.write(b"show subscribers last-seen \r\n\r")
time.sleep(0.01)
read = t.read_very_eager()
subscribers = read.rsplit(b"NAM")[1].split(b"\r\n")[2:-4]
subscribers = [subscriber.decode().split() for subscriber in subscribers]
t.close()
return subscribers
except:
return []
def add_subscriber(imsi, msisdn):
t = telnetlib.Telnet("localhost", 4258)
t.write(b"enable \r\n\r")
t.write(b"subscriber imsi " + imsi.encode() + b" create \r\n\r")
t.write(b"subscriber imsi " + imsi.encode() + b" update msisdn " +
msisdn.encode() + b" \r\n\r")
time.sleep(0.1)
read = t.read_very_eager()
t.close()
if read.find(b"Subscriber already exists") != -1:
return {"status": "error", "message": "Subscriber already exists"}
if read.find(b"Not a valid IMSI") != -1:
return {"status": "error", "message": "Not a valid IMSI"}
if read.find(b"MSISDN invalid") != -1:
return {"status": "error", "message": "MSISDN invalid"}
return {
"status": "success",
"message": "Subscriber added for imsi " + imsi
}
try:
t = telnetlib.Telnet("localhost", 4258)
t.write(b"enable \r\n\r")
t.write(b"subscriber imsi " + imsi.encode() + b" create \r\n\r")
t.write(b"subscriber imsi " + imsi.encode() + b" update msisdn " +
msisdn.encode() + b" \r\n\r")
time.sleep(0.1)
read = t.read_very_eager()
t.close()
if read.find(b"Subscriber already exists") != -1:
return {"status": "error", "message": "Subscriber already exists"}
if read.find(b"Not a valid IMSI") != -1:
return {"status": "error", "message": "Not a valid IMSI"}
if read.find(b"MSISDN invalid") != -1:
return {"status": "error", "message": "MSISDN invalid"}
return {
"status": "success",
"message": "Subscriber added for imsi " + imsi
}
except:
return {"status": "error", "message": "Could not connect to OsmoHLR"}
def remove_subscriber(imsi):
t = telnetlib.Telnet("localhost", 4258)
t.write(b"enable \r\n\r")
t.write(b"subscriber imsi " + imsi.encode() + b" delete \r\n\r")
time.sleep(0.1)
read = t.read_very_eager()
t.close()
if read.find(b"Subscriber does not exist") != -1:
return {"status": "error", "message": "Subscriber does not exist"}
return {
"status": "success",
"message": "Subscriber removed for imsi " + imsi
}
try:
t = telnetlib.Telnet("localhost", 4258)
t.write(b"enable \r\n\r")
t.write(b"subscriber imsi " + imsi.encode() + b" delete \r\n\r")
time.sleep(0.1)
read = t.read_very_eager()
t.close()
if read.find(b"Subscriber does not exist") != -1:
return {"status": "error", "message": "Subscriber does not exist"}
return {
"status": "success",
"message": "Subscriber removed for imsi " + imsi
}
except:
return {"status": "error", "message": "Could not connect to OsmoHLR"}
def get_subscriber_info(imsi):
t = telnetlib.Telnet("localhost", 4258)
t.write(b"enable \r\n\r")
t.write(b"show subscriber imsi " + imsi.encode() + b"\n")
time.sleep(0.1)
read = (t.read_very_eager().split(b"subscriber imsi " +
imsi.encode())[1].split(b"\r\n")[1:-1])
subscriber_info = [
subscriber.decode().replace(": ", "=").replace(" ", "").replace(
"(", "=").replace(")", "").split("=") for subscriber in read
]
t.close()
return subscriber_info
try:
t = telnetlib.Telnet("localhost", 4258)
t.write(b"enable \r\n\r")
t.write(b"show subscriber imsi " + imsi.encode() + b"\n")
time.sleep(0.1)
read = (t.read_very_eager().split(b"subscriber imsi " +
imsi.encode())[1].split(b"\r\n")[1:-1])
subscriber_info = [
subscriber.decode().replace(": ", "=").replace(" ", "").replace(
"(", "=").replace(")", "").split("=") for subscriber in read
]
t.close()
return subscriber_info
except:
return []
def update_subscriber_info(imsi, msisdn, imei, aud2g, ki, aud3g, k, op, opc):
t = telnetlib.Telnet("localhost", 4258)
t.write(b"enable \n")
t.write(b"subscriber imsi " + imsi.encode() + b" update msisdn " +
msisdn.encode() + b" \n")
if imei == "":
t.write(b"subscriber imsi " + imsi.encode() + b" update imei none \n")
else:
t.write(b"subscriber imsi " + imsi.encode() + b" update imei " +
imei.encode() + b"\n")
if aud2g == "none":
t.write(b"subscriber imsi " + imsi.encode() + b" update aud2g none \n")
elif ki == "":
return {"status": "error", "message": "KI is required"}
else:
t.write(b"subscriber imsi " + imsi.encode() + b" update aud2g " +
aud2g.encode() + b" ki " + ki.encode() + b"\n")
if aud3g == "none":
t.write(b"subscriber imsi " + imsi.encode() + b" update aud3g none \n")
elif k == "":
return {"status": "error", "message": "K is required"}
elif aud3g == "xor":
t.write(b"subscriber imsi " + imsi.encode() + b" update aud3g " +
aud3g.encode() + b" k " + k.encode() + b"\n")
elif op == "":
t.write(b"subscriber imsi " + imsi.encode() + b" update aud3g " +
aud3g.encode() + b" k " + k.encode() + b" opc " +
opc.encode() + b"\n")
elif opc == "":
t.write(b"subscriber imsi " + imsi.encode() + b" update aud3g " +
aud3g.encode() + b" k " + k.encode() + b" op " + op.encode() +
b"\n")
else:
return {"status": "error", "message": "OP or OPC is required"}
time.sleep(0.1)
read = t.read_very_eager()
print(read.decode())
if read.find(b"MSISDN invalid") != -1:
return {"status": "error", "message": "MSISDN invalid"}
if read.find(b"IMEI invalid") != -1:
return {"status": "error", "message": "IMEI invalid"}
if read.find(b"Invalid value for KI") != -1:
return {"status": "error", "message": "Invalid value for KI"}
if read.find(b"Invalid value for K") != -1:
return {"status": "error", "message": "Invalid value for K"}
if read.find(b"cannot set 3G auth data") != -1:
return {"status": "error", "message": "cannot set 3G auth data"}
if read.find(b"cannot set 2G auth data") != -1:
return {"status": "error", "message": "cannot set 2G auth data"}
if read.find(b"Invalid value for OP") != -1:
return {"status": "error", "message": "Invalid value for OP"}
if read.find(b"Invalid value for OPC") != -1:
return {"status": "error", "message": "Invalid value for OPC"}
t.close()
return {"status": "success", "message": "Subscriber updated"}
try:
t = telnetlib.Telnet("localhost", 4258)
t.write(b"enable \n")
t.write(b"subscriber imsi " + imsi.encode() + b" update msisdn " +
msisdn.encode() + b" \n")
if imei == "":
t.write(b"subscriber imsi " + imsi.encode() + b" update imei none \n")
else:
t.write(b"subscriber imsi " + imsi.encode() + b" update imei " +
imei.encode() + b"\n")
if aud2g == "none":
t.write(b"subscriber imsi " + imsi.encode() + b" update aud2g none \n")
elif ki == "":
return {"status": "error", "message": "KI is required"}
else:
t.write(b"subscriber imsi " + imsi.encode() + b" update aud2g " +
aud2g.encode() + b" ki " + ki.encode() + b"\n")
if aud3g == "none":
t.write(b"subscriber imsi " + imsi.encode() + b" update aud3g none \n")
elif k == "":
return {"status": "error", "message": "K is required"}
elif aud3g == "xor":
t.write(b"subscriber imsi " + imsi.encode() + b" update aud3g " +
aud3g.encode() + b" k " + k.encode() + b"\n")
elif op == "":
t.write(b"subscriber imsi " + imsi.encode() + b" update aud3g " +
aud3g.encode() + b" k " + k.encode() + b" opc " +
opc.encode() + b"\n")
elif opc == "":
t.write(b"subscriber imsi " + imsi.encode() + b" update aud3g " +
aud3g.encode() + b" k " + k.encode() + b" op " + op.encode() +
b"\n")
else:
return {"status": "error", "message": "OP or OPC is required"}
time.sleep(0.1)
read = t.read_very_eager()
if read.find(b"MSISDN invalid") != -1:
return {"status": "error", "message": "MSISDN invalid"}
if read.find(b"IMEI invalid") != -1:
return {"status": "error", "message": "IMEI invalid"}
if read.find(b"Invalid value for KI") != -1:
return {"status": "error", "message": "Invalid value for KI"}
if read.find(b"Invalid value for K") != -1:
return {"status": "error", "message": "Invalid value for K"}
if read.find(b"cannot set 3G auth data") != -1:
return {"status": "error", "message": "cannot set 3G auth data"}
if read.find(b"cannot set 2G auth data") != -1:
return {"status": "error", "message": "cannot set 2G auth data"}
if read.find(b"Invalid value for OP") != -1:
return {"status": "error", "message": "Invalid value for OP"}
if read.find(b"Invalid value for OPC") != -1:
return {"status": "error", "message": "Invalid value for OPC"}
t.close()
return {"status": "success", "message": "Subscriber updated"}
except:
return {"status": "error", "message": "Could not connect to OsmoHLR"}

View File

@ -171,7 +171,7 @@ Comment=Open source mobile communications
Exec=${working_dir}/osmo-gui
Icon=${working_dir}/static/images/osmocom_icon.png
Type=Application
Categories=Development;HamRadio;Science;
Categories=HamRadio;Science;
Keywords=SDR;Radio;HAM;RF;
MimeType=application/gnuradio-grc;
Terminal=false

11
snap/gui/osmocom.desktop Normal file
View File

@ -0,0 +1,11 @@
[Desktop Entry]
Version=1.0
Name=Osmocom
Comment=Open source mobile communications
Exec=osmocom
Icon=${SNAP}/meta/gui/osmocom.png
Type=Application
Categories=HamRadio;Science;
Keywords=SDR;Radio;HAM;RF;
MimeType=application/gnuradio-grc;
Terminal=false

BIN
snap/gui/osmocom.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

24
snap/local/run-program Normal file
View File

@ -0,0 +1,24 @@
#!/snap/osmocom/current/bin/python3
import webview
import subprocess
import time
django = subprocess.Popen(
["/snap/osmocom/current/bin/python3",
"/snap/osmocom/current/osmo-gui/manage.py",
"runserver", "127.0.0.1:8900"], )
time.sleep(0.5)
webview.create_window(
"Osmocom",
"http://localhost:8900/hlr/",
text_select= True,
width=1366,
height=768,
min_size=(800, 600)
)
webview.start()
django.terminate()
if __name__ == "__main__":
pass

73
snapcraft.yaml Normal file
View File

@ -0,0 +1,73 @@
name: osmocom
version: 1.0.0
summary: A graphical user interface for the Osmocom project
description: |
This is the graphical user interface for the Osmocom project.
This program is developed with Django framework.
It is a web application that allows to manage the Osmocom network.
However, it is not a complete web application.
confinement: devmode
base: core22
grade: stable
parts:
osmocom:
plugin: python
source: .
build-packages:
- gcc # GNU Compiler Collection
- pkg-config # manage compile and link flags for libraries
- python3-dev # header files and a static library for Python (default)
- build-essential # Informational list of build-essential packages
- libxml2-dev # Development files for the GNOME XML library
- libcurl4-openssl-dev # Development files and documentation for libcurl (OpenSSL flavour)
- libicu-dev # Development files for International Components for Unicode
stage-packages:
- gir1.2-gtk-3.0 # GTK+ graphical user interface library (runtime files)
- gir1.2-webkit2-4.0 # WebKitGTK+ Web content engine library (runtime files)
- gobject-introspection # Generate interface introspection data for GObject libraries
- xapp # Xfce Application Library
- libcanberra-gtk3-module # GTK+ 3.0 module for playing event sounds
- libgl1-mesa-dri # free implementation of the OpenGL API -- DRI modules
- libgl1-mesa-glx # free implementation of the OpenGL API -- GLX runtime
- glib-networking # Network-related giomodules for GLib
python-packages:
- django # The Web framework for perfectionists with deadlines.
- pywebview # A lightweight cross-platform native wrapper around a webview component
- pycairo # Python bindings for the cairo graphics library
- pygobject # Python bindings for GObject
override-build: |
mkdir -p $SNAPCRAFT_PART_INSTALL/osmo-gui
cp -r * $SNAPCRAFT_PART_INSTALL/osmo-gui
mv $SNAPCRAFT_PART_INSTALL/osmo-gui/snap/local/run-program $SNAPCRAFT_PART_INSTALL/run-program
chmod +x $SNAPCRAFT_PART_INSTALL/run-program
rm -rf $SNAPCRAFT_PART_INSTALL/osmo-gui/snap
rm -rf $SNAPCRAFT_PART_INSTALL/osmo-gui/snapcraft.yaml
rm -rf $SNAPCRAFT_PART_INSTALL/osmo-gui/.git
rm -rf $SNAPCRAFT_PART_INSTALL/osmo-gui/.gitignore
snapcraftctl build
layout:
/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/webkit2gtk-4.0:
bind: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/webkit2gtk-4.0
/usr/lib/dri:
bind: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/dri
/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/gio/modules:
bind: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/gio/modules
/usr/share/glib-2.0/schemas:
bind: $SNAP/usr/share/glib-2.0/schemas
apps:
osmocom:
command: run-program
plugs: [network, x11, desktop, unity7, gsettings]
environment:
GI_TYPELIB_PATH: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/girepository-1.0
GTK_PATH: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/gtk-3.0
GTK_EXE_PREFIX: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET
GTK_DATA_PREFIX: $SNAP/usr/share
LC_ALL: C.UTF-8

View File

@ -1,22 +0,0 @@
#!/snap/osmocom/current/bin/python3
import webview
import subprocess
import time
""" django = subprocess.Popen(
["/snap/osmocom/current/bin/python3", "/snap/osmocom/current/osmo-gui/manage.py", "runserver", "127.0.0.1:8900"], )
time.sleep(1) """
webview.create_window(
"Osmocom",
"http://localhost:8900/hlr/",
confirm_close=True,
width=1366,
height=768,
min_size=(800, 600),
)
webview.start()
#django.terminate()
if __name__ == "__main__":
pass

View File

@ -1,86 +0,0 @@
name: osmocom
version: 1.0.0
summary: A graphical user interface for the Osmocom project
description: |
This is the graphical user interface for the Osmocom project.
This program is developed with Django framework.
It is a web application that allows to manage the Osmocom network.
However, it is not a complete web application.
confinement: devmode
base: core22
grade: devel
parts:
osmo-gui:
plugin: python
source: .
build-packages:
- gcc
- pkg-config
- python3-dev
stage-packages:
- python3-pyqt5
- build-essential
- libfontconfig1
- libgirepository1.0-dev
- libcairo2-dev
- libxt-dev
- libgl1-mesa-dev
- libnss3-dev
- libxcomposite-dev
- libxkbcommon-dev
- libxcursor-dev
- libxcb-xinerama0
- libx11-xcb-dev
- libqt5gui5
- libqt5core5a
- libqt5xdg3
- libqt5webkit5
- libqt5widgets5
- libqt5dbus5
- libqt5webchannel5
- libqt5multimedia5
- libqt5opengl5
- qtchooser
- qtbase5-dev
- qtbase5-dev-tools
- qt5-qmake
- qt5-gtk-platformtheme
- libqt5x11extras5
- libsoqt520
- libxdamage-dev
- libxrandr-dev
- libxtst-dev
- libxss-dev
- libdbus-1-dev
- libevent-dev
- libfontconfig1-dev
- libcap-dev
- libpulse-dev
- libudev-dev
- libpci-dev
- libasound2-dev
- openssl
python-packages:
- django
- pywebview
- pycairo
- gobject
- proxy-tools
- pycairo
- PyGObject
override-build: |
mkdir -p $SNAPCRAFT_PART_INSTALL/osmo-gui
cp -r * $SNAPCRAFT_PART_INSTALL/osmo-gui
mv $SNAPCRAFT_PART_INSTALL/osmo-gui/gui $SNAPCRAFT_PART_INSTALL/run-program
chmod +x $SNAPCRAFT_PART_INSTALL/run-program
snapcraftctl build
apps:
osmo-gui:
command: run-program
plugs: [network]

View File

@ -1,49 +0,0 @@
name: osmocom
version: 1.0.0
summary: A graphical user interface for the Osmocom project
description: |
This is the graphical user interface for the Osmocom project.
This program is developed with Django framework.
It is a web application that allows to manage the Osmocom network.
However, it is not a complete web application.
confinement: devmode
base: core22
grade: devel
parts:
osmocom:
plugin: dump
source: .
build-packages:
- gcc
- pkg-config
- python3-dev
- python3-venv
- build-essential
- libxml2-dev
- libcurl4-openssl-dev
- libicu-dev
override-build: |
snapcraftctl build
rm -rf $SNAPCRAFT_PART_INSTALL/snapcraft.yaml
rm -rf $SNAPCRAFT_PART_INSTALL/README.md
rm -rf $SNAPCRAFT_PART_INSTALL/install.sh
rm -rf $SNAPCRAFT_PART_INSTALL/.gitignore
rm -rf $SNAPCRAFT_PART_INSTALL/.git
rm -rf $SNAPCRAFT_PART_INSTALL/.github
mv $SNAPCRAFT_PART_INSTALL/gui $SNAPCRAFT_PART_INSTALL/run-program
chmod +x $SNAPCRAFT_PART_INSTALL/run-program
python3 -m venv $SNAPCRAFT_PART_INSTALL/env
source $SNAPCRAFT_PART_INSTALL/env/bin/activate
pip3 install -U pip django PyGObject pycairo pywebview
stage-packages:
- gir1.2-gtk-3.0
- gir1.2-appindicator3-0.1
- gir1.2-webkit2-4.0
apps:
osmocom:
command: run-program
plugs: [network, x11]

View File

@ -1,91 +0,0 @@
name: osmocom
version: 1.0.0
summary: A graphical user interface for the Osmocom project
description: |
This is the graphical user interface for the Osmocom project.
This program is developed with Django framework.
It is a web application that allows to manage the Osmocom network.
However, it is not a complete web application.
confinement: devmode
base: core22
grade: devel
parts:
osmocom:
plugin: python
source: .
build-packages:
- gcc
- pkg-config
- python3-dev
- build-essential
- libxml2-dev
- libcurl4-openssl-dev
- libicu-dev
stage-packages:
- gir1.2-gtk-3.0
- gir1.2-appindicator3-0.1
- gir1.2-webkit2-4.0
- gir1.2-ibus-1.0
- gobject-introspection
- gir1.2-atk-1.0
- gir1.2-freedesktop
- gir1.2-gdkpixbuf-2.0
- gir1.2-glib-2.0
- gir1.2-pango-1.0
- libgtk-3-0
- libgtk-3-dev
- libgtk-3-common
- libepoxy0
- libepoxy-dev
- gir1.2-gdkpixbuf-2.0
- gir1.2-gudev-1.0
- gir1.2-handy-0.0
- gir1.2-rsvg-2.0
- gir1.2-secret-1
- libglib-object-introspection-perl
- libglib2.0-dev
- libgail-3-0
- libgail-common
- libgail18
- libatk1.0-dev
- libatk1.0-0
- libatk-wrapper-java
- libatk-wrapper-java-jni
- libatk-bridge2.0-0
- libatk-bridge2.0-dev
- libatk-adaptor
- eog
- libgdk-pixbuf2.0-dev
- libgdk-pixbuf2.0-0
- libgdk-pixbuf2.0-common
- libgdk-pixbuf2.0-bin
- gir1.2-pango-1.0
- libpango1.0-dev
- libpango1.0-0
- gstreamer1.0-x
- libcogl-pango20
- libpangocairo-1.0-0
- pango1.0-tools
- dbus
- gir1.2-dbusmenu-glib-0.4
- gir1.2-gck-1
python-packages:
- django
- pywebview
- pycairo
- pygobject
override-build: |
mkdir -p $SNAPCRAFT_PART_INSTALL/osmo-gui
cp -r * $SNAPCRAFT_PART_INSTALL/osmo-gui
mv $SNAPCRAFT_PART_INSTALL/osmo-gui/gui $SNAPCRAFT_PART_INSTALL/run-program
chmod +x $SNAPCRAFT_PART_INSTALL/run-program
snapcraftctl build
apps:
osmocom:
command: run-program
plugs: [network]

View File

@ -1,50 +0,0 @@
name: osmocom
version: 1.0.0
summary: A graphical user interface for the Osmocom project
description: |
This is the graphical user interface for the Osmocom project.
This program is developed with Django framework.
It is a web application that allows to manage the Osmocom network.
However, it is not a complete web application.
confinement: devmode
base: core22
grade: devel
parts:
osmocom:
plugin: python
source: .
build-packages:
- gcc
- pkg-config
- python3-dev
- build-essential
- libxml2-dev
- libcurl4-openssl-dev
- libicu-dev
stage-packages:
- gir1.2-gtk-3.0
- gir1.2-appindicator3-0.1
- gir1.2-webkit2-4.0
- gir1.2-ibus-1.0
- gobject-introspection
python-packages:
- django
- pywebview
- pycairo
- pygobject
override-build: |
mkdir -p $SNAPCRAFT_PART_INSTALL/osmo-gui
cp -r * $SNAPCRAFT_PART_INSTALL/osmo-gui
mv $SNAPCRAFT_PART_INSTALL/osmo-gui/gui $SNAPCRAFT_PART_INSTALL/run-program
chmod +x $SNAPCRAFT_PART_INSTALL/run-program
snapcraftctl build
apps:
osmocom:
command: run-program
plugs: [network]