Compare commits
213 Commits
Author | SHA1 | Date |
---|---|---|
KF7EEL | 4633f4d518 | |
KF7EEL | bb8763bd45 | |
KF7EEL | f306c6587d | |
KF7EEL | a5634ac0c9 | |
KF7EEL | 8ce5427406 | |
KF7EEL | fbbf4c4b50 | |
KF7EEL | 7e1ea37142 | |
KF7EEL | 3892dca12a | |
KF7EEL | 4016371447 | |
KF7EEL | 85d197b762 | |
KF7EEL | eced139c70 | |
KF7EEL | ce94f102ca | |
KF7EEL | 213d85d052 | |
KF7EEL | 19013c6da2 | |
KF7EEL | 1847f13471 | |
KF7EEL | f5f1f9b91f | |
KF7EEL | 69b8570ee2 | |
KF7EEL | 3b8dff4c03 | |
KF7EEL | 4fcafa1927 | |
KF7EEL | f63b782cdf | |
KF7EEL | e8e6e04f60 | |
KF7EEL | 9dc5693dd6 | |
KF7EEL | 857c397693 | |
KF7EEL | d53743e171 | |
KF7EEL | 55c0651795 | |
KF7EEL | c08fa3badd | |
KF7EEL | ceb42fac61 | |
KF7EEL | 0e03ad4f03 | |
KF7EEL | 85a16ffe08 | |
KF7EEL | f16dc601ca | |
KF7EEL | ee4f13c6dd | |
KF7EEL | d2a20b2354 | |
KF7EEL | 207ad07345 | |
KF7EEL | e37013d7a7 | |
KF7EEL | 2c6c36dff1 | |
KF7EEL | 4e98ed8513 | |
KF7EEL | 2f8350ecc0 | |
KF7EEL | 2d3185f94f | |
KF7EEL | 19db51b1f6 | |
KF7EEL | 6541aa61b6 | |
KF7EEL | 88d4447bae | |
KF7EEL | 75625510c9 | |
KF7EEL | dd521eb385 | |
KF7EEL | c1e867721b | |
KF7EEL | 370c4694ac | |
KF7EEL | 9690cdf98c | |
KF7EEL | 73c5ec938f | |
KF7EEL | 0b9d70b141 | |
KF7EEL | 3028682ac0 | |
KF7EEL | 61372e74d1 | |
KF7EEL | 651ced5ebd | |
KF7EEL | bad9ad53ae | |
KF7EEL | 97bb174bf6 | |
KF7EEL | 698ae71223 | |
KF7EEL | 620374e4e7 | |
KF7EEL | 432c356c24 | |
KF7EEL | 0200789b1b | |
KF7EEL | c8d2d932a9 | |
KF7EEL | 35c5afafff | |
KF7EEL | 3678ca107e | |
KF7EEL | d347c72e3d | |
KF7EEL | 87bb1aa6d1 | |
KF7EEL | 2a556d5b9b | |
KF7EEL | c123b94618 | |
KF7EEL | 901b9ee933 | |
KF7EEL | 651ef0b0d2 | |
KF7EEL | d0783fc31e | |
KF7EEL | 72f2bf7d7d | |
KF7EEL | ce2a45a9a0 | |
KF7EEL | c414edab99 | |
KF7EEL | e72682800a | |
KF7EEL | 8c05948c2f | |
KF7EEL | e4524965d1 | |
KF7EEL | 8874c304bf | |
KF7EEL | bd464b4954 | |
KF7EEL | 716acefb1e | |
KF7EEL | 2269b57b5c | |
KF7EEL | 3692621c6d | |
KF7EEL | 5b290bf1b8 | |
KF7EEL | af345335b7 | |
KF7EEL | 1cee45de63 | |
KF7EEL | a50901f9c0 | |
KF7EEL | 38375688f2 | |
KF7EEL | 95c71f7c87 | |
KF7EEL | 98e7169f34 | |
KF7EEL | 4a76abbb5d | |
KF7EEL | 89cf62e360 | |
KF7EEL | e2760f8f80 | |
KF7EEL | b8b8e09cae | |
KF7EEL | 15ddbbff88 | |
KF7EEL | 7e7a31e309 | |
KF7EEL | f30aa4f722 | |
KF7EEL | 803d2e13f9 | |
KF7EEL | eb62034ea5 | |
KF7EEL | 58215d9a3e | |
KF7EEL | c7eb288f78 | |
KF7EEL | df9f376ec5 | |
KF7EEL | 0152b4f190 | |
KF7EEL | b7102bab4a | |
KF7EEL | f5f57d7607 | |
KF7EEL | 6ff7372743 | |
KF7EEL | 1e1284b982 | |
KF7EEL | d70fad9815 | |
KF7EEL | 8866058467 | |
KF7EEL | 3e5cdf2f51 | |
KF7EEL | 77744c7b82 | |
KF7EEL | 601656b448 | |
KF7EEL | 2d23f9521f | |
KF7EEL | 2f2053a236 | |
KF7EEL | eeaa092858 | |
KF7EEL | f7fd25fdc3 | |
KF7EEL | aeaea3a135 | |
KF7EEL | 8aee058e73 | |
KF7EEL | 1865a4e36a | |
KF7EEL | aa86b5344c | |
KF7EEL | 756443f7af | |
KF7EEL | f91a85b241 | |
KF7EEL | ea1c04528c | |
KF7EEL | e55c1395f6 | |
KF7EEL | b7b29a4402 | |
KF7EEL | 3c461363a4 | |
KF7EEL | c761e740bc | |
KF7EEL | 7db02fcb4b | |
KF7EEL | b382ffa21f | |
KF7EEL | e971fb0f50 | |
KF7EEL | 54f038a0c4 | |
KF7EEL | 9980d65f57 | |
KF7EEL | e128e10dcc | |
KF7EEL | 5c73861c69 | |
KF7EEL | 59ac3a693e | |
KF7EEL | 3fd29ab75c | |
KF7EEL | b5843dfed1 | |
KF7EEL | a81679a3db | |
KF7EEL | ce6ba7c5dc | |
KF7EEL | 82213561b8 | |
KF7EEL | 82d54848ee | |
KF7EEL | d7ba7e73f4 | |
KF7EEL | 4d9502e828 | |
KF7EEL | cd76853928 | |
Eric | be1f0c836d | |
KF7EEL | 2b8ede347d | |
KF7EEL | 4685686053 | |
KF7EEL | b3f12587c1 | |
KF7EEL | 1d93ef13ea | |
KF7EEL | 6d093b4b08 | |
KF7EEL | 7429db3a03 | |
KF7EEL | ea39d5fa6a | |
KF7EEL | 5f57ceae66 | |
KF7EEL | 434c9a8e80 | |
KF7EEL | 38a1ee2c0f | |
KF7EEL | 6362b8cd5a | |
KF7EEL | 275af6168d | |
KF7EEL | ccc5801b59 | |
KF7EEL | d7266ac387 | |
KF7EEL | 2503e448c6 | |
KF7EEL | 6258ccc074 | |
KF7EEL | 3ce2e2c683 | |
KF7EEL | 017f55eef3 | |
KF7EEL | ccaee1015b | |
KF7EEL | e71c2046d1 | |
KF7EEL | 7bea2fbe18 | |
KF7EEL | 3be127d0f4 | |
KF7EEL | 9267fef2cb | |
KF7EEL | 413044aba8 | |
KF7EEL | de08cc897e | |
KF7EEL | ac7b827c36 | |
KF7EEL | 3f3b980b98 | |
KF7EEL | c16036b58d | |
KF7EEL | f94d68ae81 | |
KF7EEL | d87c67acb0 | |
KF7EEL | 06cc28fe82 | |
KF7EEL | 92e0e2e405 | |
KF7EEL | a03a9e1018 | |
KF7EEL | c9436e54ec | |
KF7EEL | eb0a6b49d4 | |
KF7EEL | d8e4351ad3 | |
KF7EEL | 1b9bb3a83f | |
KF7EEL | 886a15945d | |
KF7EEL | 90aa470bb9 | |
KF7EEL | 37af7aab2a | |
KF7EEL | dd0825c005 | |
KF7EEL | 6ac2ffe091 | |
KF7EEL | b6f1a92a60 | |
KF7EEL | cb81326da2 | |
KF7EEL | d1a7faf29c | |
KF7EEL | 257232078a | |
KF7EEL | 09e1fca1cb | |
KF7EEL | aa9e68ae5a | |
KF7EEL | ed31308b26 | |
KF7EEL | 6827cda57a | |
KF7EEL | fa11f3bdf4 | |
KF7EEL | 7d890bc504 | |
KF7EEL | df1b69612a | |
KF7EEL | a60e1b2cac | |
KF7EEL | 5915463b71 | |
KF7EEL | 080b88d43f | |
Eric | c362e3e675 | |
Eric | 2af99e7f46 | |
KF7EEL | 52ac438fcc | |
KF7EEL | bda66fbdde | |
KF7EEL | 16744c61e5 | |
KF7EEL | 2159d09525 | |
KF7EEL | 6ddfb2b1c1 | |
KF7EEL | 8adb80f188 | |
KF7EEL | 3ed20d48ac | |
KF7EEL | bc2b146f79 | |
KF7EEL | f1541c7d7d | |
KF7EEL | 912d875d11 | |
KF7EEL | 213a5c6d8f | |
KF7EEL | a93a61d05b | |
KF7EEL | 72d0ca87e5 | |
KF7EEL | 1902234e87 | |
KF7EEL | 5de722fcf1 |
217
README.md
217
README.md
|
@ -1,177 +1,60 @@
|
|||
### This project has morphed into HBNet. It is still under heavy development and not ready for production. You can see it [here](https://github.com/kf7eel/hblink3/tree/hbnet). The example/development server can be found at [https://demo.hbnet.xyz](https://demo.hbnet.xyz).
|
||||
![ ](https://raw.githubusercontent.com/kf7eel/hblink3/hbnet/HBNet.png "Logo")
|
||||
|
||||
# GPS/Data Application
|
||||
HBNet is a fork of [HBlink3](https://github.com/HBLink-org/hblink3) that extends the functionality of HBLink through several features, making it more of a usable application and less of a framework. HBNet aims to be complete and ready to use application that can be used to build and run a DMR network.
|
||||
|
||||
This repository contains everything needed to decode DMR GPS packets and SMS for HBLink3. This application can act as a master or peer and receive data as a group call or private call. It is designed to work in a multi system/user network.
|
||||
HBNet consists of 2 parts, HBNet Web Service and the actual DMR server, based on HBLink. The HBNet Web Service handles user administration, server configuration, and is a content management system for your DMR network.
|
||||
|
||||
Files modified from original master branch of HBLink3:
|
||||
|
||||
* bridge.py
|
||||
* config.py
|
||||
|
||||
#### Required modules
|
||||
|
||||
* pynmea2
|
||||
* aprslib
|
||||
* maidenhead
|
||||
|
||||
#### Optional Modules
|
||||
* Flask - Required for dashboard
|
||||
* smtplib - Required for sending email. If pip fails to install module, it may already be installed as most Linux distributions have this module by default.
|
||||
* traceback - If pip fails to install module, it may already be installed as most Linux distrobutions have this module by default.
|
||||
* slixmpp - Required for upcoming XMPP gateway.
|
||||
* folium - Required for mapping on dashboard.
|
||||
|
||||
This should work for DMR radios that send location data as a UTF-8 NMEA sentence. I am hopping to add support for more radios in the future.
|
||||
|
||||
### Differences in branches
|
||||
|
||||
* **GPS**: Contains the GPS/Data Application.
|
||||
* **aprs_features**: Contains the GPS/Data Application and a modified version of the APRS implementation for repeaters and hotspots by **IU7IGU**. (See [https://github.com/iu7igu/hblink3-aprs](https://github.com/iu7igu/hblink3-aprs) for his work). I combined these for convenience.
|
||||
|
||||
## Confirmed working:
|
||||
Actually tested
|
||||
|
||||
| Radio | GPS | SMS |
|
||||
|-------|:---:|:---:|
|
||||
| Anytone D878| YES | YES |
|
||||
| Anytone D578| YES | YES |
|
||||
| BTech DMR-6x2 | YES | Most likely |
|
||||
| MD-380 (MD380tools, no GPS) | - | YES |
|
||||
| MD-380 (stock firmware, GPS) | YES | Most likely |
|
||||
| MD-390 (stock firmware) | YES | YES |
|
||||
| Retevis RT73* | YES | YES |
|
||||
| Ailunce HD1 | YES | YES |
|
||||
|
||||
*RT73 must have unconfirmed data setting enabled.
|
||||
|
||||
## Highly suspected to work:
|
||||
Not tested yet, but will most likely work.
|
||||
|
||||
| Radio | GPS | SMS |
|
||||
|-------|:---:|:---:|
|
||||
| Anytone D868 | Most likely | Most likely |
|
||||
| TYT MD-2017 | Most likely | Likely |
|
||||
| TYT MD-9600 | Most likely | Likely |
|
||||
| Retevis RT8 | Most likely | Likely |
|
||||
|
||||
|
||||
## Tested, but with issues.
|
||||
Tested, but with bugs present.
|
||||
|
||||
| Radio | GPS | SMS |
|
||||
|-------|:---:|:---:|
|
||||
| Alinco DJ-MD5TGP | WIP | Most likely |
|
||||
| Motorola DP3601| WIP | WIP |
|
||||
This project originally started as a not so simple set of scripts to decode GPS locations and generate APRS positions. Through other modifications and additions, it has grown into a fully featured fork.
|
||||
|
||||
|
||||
## Would like to test:
|
||||
### User end features:
|
||||
|
||||
Connect Systems GPS enabled radios
|
||||
* Handles user registration and email verification
|
||||
|
||||
## Features
|
||||
* Individual hotspot passphrases for each user
|
||||
|
||||
* Decode GPS locations and upload APRS position packets
|
||||
* Each user/DMR ID can customize APRS position
|
||||
* Ability to receive data as a private call or group call
|
||||
* Trigger a command or script via DMR SMS
|
||||
* Optional web dashboard to show APRS packets uploaded
|
||||
* Display bulletins sent via SMS on web dashboard
|
||||
* Automatic retrieval of DMR IDs on registration
|
||||
|
||||
* Automatically generate talkgroup pages
|
||||
|
||||
* Automatically generates a script for Pi-Star setup (WORK IN PROGRESS)
|
||||
|
||||
* Map of currently connected peers
|
||||
|
||||
|
||||
## How it works
|
||||
### Administrative features:
|
||||
|
||||
A user should configure their radio for the DMR ID of the application and private or group call. When a position is received by the application, it will extract the coordinates and create an APRS position packet. The application will find the callsign of the user based on the sending radio's DMR ID. It is essential to have an up to date subscriber_ids file for this to work. A predefined APRS SSID is appended to the callsign. The APRS location packet is then uploaded to APRS-IS. No setup is required beforehand on the part of the user. This is pretty much "plug and play."
|
||||
* Administrate multiple DMR servers through a single web service
|
||||
|
||||
For example, N0CALL has a DMR ID of 1234567. N0CALL's radio sends a position to the application. The application will query the subscriber_ids file for DMR ID 1234567. The result will be N0CALL. An APRS location pack is created and uploaded to APRS-IS.
|
||||
* Optional manual approval of new users
|
||||
|
||||
## Individual user/DMR ID APRS settings
|
||||
* Multiple Admin user logins
|
||||
|
||||
By default, all APRS positions will have an SSID of 15, a default comment, and the callsign of the DMR user. These default settings can be changed.
|
||||
|
||||
The comment, SSID, and icon can be set for each individual user/DMR ID the application sees. The application stores all the setting in a file. You may have different SSIDs, icons, and comments for different DMR IDs. This is done via DMR SMS using the following commands:
|
||||
### OpenBridge additions
|
||||
|
||||
| Command | Description | Example |
|
||||
|-------|:---:|:---:|
|
||||
|**@SSID**|Change SSID of user callsign.|`@SSID 7`|
|
||||
|**@ICON**|Change the icon of the APRS position. *See [http://aprs.net/vm/DOS/SYMBOLS.HTM](http://aprs.net/vm/DOS/SYMBOLS.HTM) for icon list.|`@icon /p`|
|
||||
|**@COM**|Change the comment of the APRS.|`@COM This is a test comment.`|
|
||||
|**@MH**|Set you location by maidenhead grid square. Designed for radios with no GPS or that are not compatable yet.|`@MH DN97uk`|
|
||||
|**@BB**|Post a bulliten to the web dashboard.|`@BB This is a test bulletin.`|
|
||||
|**@[CALLSIGN W/ SSID] A-[MESSAGE]**|Send a message to another station via APRS.|`@N0CALL-15 A-This is a test.`|
|
||||
|**[EMAIL ADDRESS] E-[MESSAGE]**|Send an email to an email address.|`test@example.org E-This is a test.`|
|
||||
* Enhanced unit call routing between connected servers. Every server known which server every subscribers is on.
|
||||
|
||||
* Optionally encrypt data sent over OpenBridge
|
||||
|
||||
|
||||
### Data Gateway (APRS/SMS)
|
||||
|
||||
* Compatable with HBNet and original HBLink.
|
||||
|
||||
* Connect your server via OpenBridge or MMDVM.
|
||||
|
||||
* Decodes GPS positions and generates APRS positions
|
||||
|
||||
* Simple web dashboard
|
||||
|
||||
|
||||
|
||||
Send a DMR SMS to the configured dmr_data_id in the application with the desired command followed by the value. For example, to change your icon to a dog, the command would be `@ICON /p` (see the icon table for values). Changing your SSID is as simple as `@SSID 7`, and `@COM Testing 123` will change the comment.
|
||||
### Other features
|
||||
|
||||
Sending `@BB Test` will result in a post to the bulletin board with the messaage of "Test".
|
||||
* SQLite or MySQL backend
|
||||
|
||||
|
||||
**To remove any of the stored values, just send the appropriate command without any input.** `@COM` will remove the stored comment, `@ICON` will remove the stored icon, and `@COM` will remove the strored comment. Any position now reports sent will have the default settings.
|
||||
|
||||
|
||||
## Web Dashboard
|
||||
|
||||
The web dashboard is completely optional. Python module flask is required for this to work. The web dashboard will display the last 15 positions of radios sent to APRS-IS. The dashboard will also sh user bulletin. A bulletin is a message sent via SMS that will display on the web dashboard. There are several uses for this, including: testing SMS functionality of radio, announcements, and moire. It is a novel feature. The page will automatically reload every 2 minutes. Setup is rather simple. Just modify the example config in the dashboard directory and rename it to dashboard_settings.py. Then start dashboard.py.
|
||||
|
||||
## APRS messaging
|
||||
|
||||
**At this time, only sending of messages from DMR SMS to APRS-IS is supported.** I find this feature very pointless because it will only go one way, but someone else may find it important. **Messages from sent from APRS-IS to DMR SMS will not work.** I have not written the code for this yet. It will likley be a long time before this is a possibility.
|
||||
|
||||
## APRS TOCALL
|
||||
|
||||
The project was granted a [tocall](http://www.aprs.org/aprs11/tocalls.txt) of **APHBLx** by Bob Bruniga, WB4APR. This will identify that your APRS position came from HBLink. The x on the end can be any letter/number. Here are the current designations of APHBLx:
|
||||
|
||||
* **APHBL3** - HBlink3 D-APRS gateway
|
||||
* **APHBLD** - DMRlink D-APRS gateway (the IPSC version of the project)
|
||||
* **_APHBLS_** - Planned, but not in use: HBLink3 via KISS TNC
|
||||
|
||||
## Configuration
|
||||
|
||||
See hblink_SAMPLE.cfg, rules_SAMPLE.py, and gps_data_SAMPLE.cfg for examples.
|
||||
|
||||
## Special thanks to:
|
||||
|
||||
**N0MJS** - For creating HBLink and dmr_utils. This project not possible without him.
|
||||
|
||||
**IU7IGU** - For creating APRS position beaconing for PEER connections.
|
||||
|
||||
**IV3JDV** - For helping debug SMS in Anytone radios.
|
||||
|
||||
**KD7LMN** - For pointing out a critical bug.
|
||||
|
||||
**KB5PBM** - For helping implement support for MD-380 type radios.
|
||||
|
||||
**EI7IG** - For writing the page explaining MD-380 type GPS packets.
|
||||
|
||||
**M0GLJ** - For assisting with Motorola testing.
|
||||
|
||||
## Resources for DMR data
|
||||
|
||||
I spent many hours looking at the following for this project. You may find these links useful.
|
||||
|
||||
https://github.com/travisgoodspeed/md380tools/issues/160
|
||||
|
||||
https://jpronans.github.io/ei7ig/dmr.html
|
||||
|
||||
http://cloud.dstar.su/files/G4KLX/MMDVM/MMDVM%20Specification%2020150922.pdf
|
||||
|
||||
https://wiki.brandmeister.network/index.php/NMEA_Location_Reporting
|
||||
|
||||
https://forums.radioreference.com/threads/motorola-lrrp-protocol.370081/
|
||||
|
||||
https://forums.radioreference.com/threads/lrrp-decoding.359575/
|
||||
|
||||
https://github.com/polkabana/go-dmr
|
||||
|
||||
https://github.com/nonoo/dmrshark
|
||||
|
||||
https://wiki.brandmeister.network/index.php/Compressed_Location_Reporting
|
||||
|
||||
All of the ETSI DMR documents (ETSI 102 361-1 through 361-4).
|
||||
|
||||
The Shark RF forums.
|
||||
* APRS and SMS features (WORK IN PROGRESS)
|
||||
|
||||
---
|
||||
### FOR SUPPORT, DISCUSSION, GETTING INVOLVED ###
|
||||
|
@ -180,7 +63,7 @@ Please join the DVSwitch group at groups.io for online forum support, discussion
|
|||
|
||||
DVSwitch@groups.io
|
||||
|
||||
A voluntary registrty for HBlink systems with public access has been created at http://hblink-register.com.es Please consider listing your system if you allow open access.
|
||||
A voluntary registry for HBlink systems with public access has been created at http://hblink-register.com.es Please consider listing your system if you allow open access.
|
||||
|
||||
---
|
||||
|
||||
|
@ -201,32 +84,6 @@ None. The owners of this work make absolutely no warranty, express or implied. U
|
|||
**PRE-REQUISITE KNOWLEDGE:**
|
||||
This document assumes the reader is familiar with Linux/UNIX, the Python programming language and DMR.
|
||||
|
||||
**Using docker version**
|
||||
|
||||
To work with provided docker setup you will need:
|
||||
* A private repository with your configuration files (all .cfg files in repo will be copyed to the application root directory on start up)
|
||||
* A service user able to read your private repository (or be brave and publish your configuration, or be really brave and give your username and password to the docker)
|
||||
* A server with docker installed
|
||||
* Follow this simple steps:
|
||||
|
||||
Build your own image from source
|
||||
|
||||
```bash
|
||||
|
||||
docker build . -t millaguie/hblink:3.0.0
|
||||
|
||||
```
|
||||
|
||||
Or user a prebuilt one in docker hub: millaguie/hblink:3.0.0
|
||||
|
||||
Wake up your container
|
||||
|
||||
```bash
|
||||
touch /var/log/hblink.log
|
||||
chown 65000 /var/log/hblink.log
|
||||
run -v /var/log/hblink.log:/var/log/hblink.log -e GIT_USER=$USER -e GIT_PASSWORD=$PASSWORD -e GIT_REPO=$URL_TO_REPO_WITHOUT_HTTPS:// -p 54000:54000 millaguie/hblink:3.0.0
|
||||
```
|
||||
|
||||
**MORE DOCUMENTATION TO COME**
|
||||
|
||||
***0x49 DE N0MJS***
|
||||
|
|
|
@ -0,0 +1,150 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
###############################################################################
|
||||
# Copyright (C) 2016-2019 Cortney T. Buffington, N0MJS <n0mjs@me.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
###############################################################################
|
||||
|
||||
# Python modules we need
|
||||
import sys
|
||||
from bitarray import bitarray
|
||||
from time import time
|
||||
from importlib import import_module
|
||||
|
||||
# Twisted is pretty important, so I keep it separate
|
||||
from twisted.internet.protocol import Factory, Protocol
|
||||
from twisted.protocols.basic import NetstringReceiver
|
||||
from twisted.internet import reactor, task
|
||||
|
||||
# Things we import from the main hblink module
|
||||
from hblink import HBSYSTEM, OPENBRIDGE, systems, hblink_handler, reportFactory, REPORT_OPCODES, mk_aliases
|
||||
from dmr_utils3.utils import bytes_3, int_id, get_alias
|
||||
from dmr_utils3 import decode, bptc, const
|
||||
import config
|
||||
import log
|
||||
from const import *
|
||||
|
||||
# Stuff for socket reporting
|
||||
import pickle
|
||||
# REMOVE LATER from datetime import datetime
|
||||
# The module needs logging, but handlers, etc. are controlled by the parent
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# Does anybody read this stuff? There's a PEP somewhere that says I should do this.
|
||||
__author__ = 'Cortney T. Buffington, N0MJS'
|
||||
__copyright__ = 'Copyright (c) 2016-2018 Cortney T. Buffington, N0MJS and the K0USY Group'
|
||||
__credits__ = 'Colin Durbridge, G4EML, Steve Zingman, N4IRS; Mike Zingman, N4IRR; Jonathan Naylor, G4KLX; Hans Barthen, DL5DI; Torsten Shultze, DG1HT'
|
||||
__license__ = 'GNU GPLv3'
|
||||
__maintainer__ = 'Cort Buffington, N0MJS'
|
||||
__email__ = 'n0mjs@me.com'
|
||||
|
||||
# Module gobal varaibles
|
||||
|
||||
|
||||
class OBP(OPENBRIDGE):
|
||||
|
||||
def __init__(self, _name, _config, _report):
|
||||
OPENBRIDGE.__init__(self, _name, _config, _report)
|
||||
|
||||
|
||||
def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data):
|
||||
pass
|
||||
|
||||
|
||||
class HBP(HBSYSTEM):
|
||||
|
||||
def __init__(self, _name, _config, _report):
|
||||
HBSYSTEM.__init__(self, _name, _config, _report)
|
||||
|
||||
def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
#************************************************
|
||||
# MAIN PROGRAM LOOP STARTS HERE
|
||||
#************************************************
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
import os
|
||||
import signal
|
||||
|
||||
# Change the current directory to the location of the application
|
||||
os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])))
|
||||
|
||||
# CLI argument parser - handles picking up the config file from the command line, and sending a "help" message
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-c', '--config', action='store', dest='CONFIG_FILE', help='/full/path/to/config.file (usually hblink.cfg)')
|
||||
parser.add_argument('-l', '--logging', action='store', dest='LOG_LEVEL', help='Override config file logging level.')
|
||||
cli_args = parser.parse_args()
|
||||
|
||||
# Ensure we have a path for the config file, if one wasn't specified, then use the default (top of file)
|
||||
if not cli_args.CONFIG_FILE:
|
||||
cli_args.CONFIG_FILE = os.path.dirname(os.path.abspath(__file__))+'/hblink.cfg'
|
||||
|
||||
# Call the external routine to build the configuration dictionary
|
||||
CONFIG = config.build_config(cli_args.CONFIG_FILE)
|
||||
|
||||
# Start the system logger
|
||||
if cli_args.LOG_LEVEL:
|
||||
CONFIG['LOGGER']['LOG_LEVEL'] = cli_args.LOG_LEVEL
|
||||
logger = log.config_logging(CONFIG['LOGGER'])
|
||||
logger.info('\n\nCopyright (c) 2013, 2014, 2015, 2016, 2018\n\tThe Regents of the K0USY Group. All rights reserved.\n')
|
||||
logger.debug('(GLOBAL) Logging system started, anything from here on gets logged')
|
||||
|
||||
# Set up the signal handler
|
||||
def sig_handler(_signal, _frame):
|
||||
logger.info('(GLOBAL) SHUTDOWN: CONFBRIDGE IS TERMINATING WITH SIGNAL %s', str(_signal))
|
||||
hblink_handler(_signal, _frame)
|
||||
logger.info('(GLOBAL) SHUTDOWN: ALL SYSTEM HANDLERS EXECUTED - STOPPING REACTOR')
|
||||
reactor.stop()
|
||||
|
||||
# Set signal handers so that we can gracefully exit if need be
|
||||
for sig in [signal.SIGINT, signal.SIGTERM]:
|
||||
signal.signal(sig, sig_handler)
|
||||
|
||||
# Create the name-number mapping dictionaries
|
||||
peer_ids, subscriber_ids, talkgroup_ids = mk_aliases(CONFIG)
|
||||
|
||||
# INITIALIZE THE REPORTING LOOP
|
||||
if CONFIG['REPORTS']['REPORT']:
|
||||
report_server = config_reports(CONFIG, bridgeReportFactory)
|
||||
else:
|
||||
report_server = None
|
||||
logger.info('(REPORT) TCP Socket reporting not configured')
|
||||
|
||||
# HBlink instance creation
|
||||
logger.info('(GLOBAL) HBlink \'bridge.py\' -- SYSTEM STARTING...')
|
||||
for system in CONFIG['SYSTEMS']:
|
||||
if CONFIG['SYSTEMS'][system]['ENABLED']:
|
||||
if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE':
|
||||
systems[system] = OBP(system, CONFIG, report_server)
|
||||
else:
|
||||
systems[system] = HBP(system, CONFIG, report_server)
|
||||
reactor.listenUDP(CONFIG['SYSTEMS'][system]['PORT'], systems[system], interface=CONFIG['SYSTEMS'][system]['IP'])
|
||||
logger.debug('(GLOBAL) %s instance created: %s, %s', CONFIG['SYSTEMS'][system]['MODE'], system, systems[system])
|
||||
|
||||
def loopingErrHandle(failure):
|
||||
logger.error('(GLOBAL) STOPPING REACTOR TO AVOID MEMORY LEAK: Unhandled error in timed loop.\n %s', failure)
|
||||
reactor.stop()
|
||||
|
||||
|
||||
reactor.run()
|
563
bridge.py
563
bridge.py
|
@ -1,7 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
###############################################################################
|
||||
# Copyright (C) 2016-2019 Cortney T. Buffington, N0MJS <n0mjs@me.com>
|
||||
# Copyright (C) 2020-2021 Eric, KF7EEL, <kf7eel@qsl.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -42,12 +43,13 @@ from twisted.protocols.basic import NetstringReceiver
|
|||
from twisted.internet import reactor, task
|
||||
|
||||
# Things we import from the main hblink module
|
||||
from hblink import HBSYSTEM, OPENBRIDGE, systems, hblink_handler, reportFactory, REPORT_OPCODES, mk_aliases
|
||||
from hblink import HBSYSTEM, OPENBRIDGE, systems, hblink_handler, reportFactory, REPORT_OPCODES, mk_aliases, download_burnlist
|
||||
from dmr_utils3.utils import bytes_3, int_id, get_alias
|
||||
from dmr_utils3 import decode, bptc, const
|
||||
import config
|
||||
import log
|
||||
from const import *
|
||||
from hashlib import sha256
|
||||
|
||||
# Stuff for socket reporting
|
||||
import pickle
|
||||
|
@ -55,35 +57,284 @@ import pickle
|
|||
# The module needs logging, but handlers, etc. are controlled by the parent
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
import os, ast
|
||||
import json, requests
|
||||
|
||||
# User for different functions that need to be running: APRS, Proxy, etc
|
||||
import threading
|
||||
|
||||
# Hotspot Proxy stuff
|
||||
from hotspot_proxy_v2 import Proxy
|
||||
|
||||
# Used for converting time
|
||||
from datetime import datetime
|
||||
|
||||
import re
|
||||
from socket import gethostbyname
|
||||
|
||||
# Import UNIT time from rules.py
|
||||
from rules import UNIT_TIME, STATIC_UNIT
|
||||
|
||||
|
||||
# Does anybody read this stuff? There's a PEP somewhere that says I should do this.
|
||||
__author__ = 'Cortney T. Buffington, N0MJS'
|
||||
__copyright__ = 'Copyright (c) 2016-2019 Cortney T. Buffington, N0MJS and the K0USY Group'
|
||||
__author__ = 'Cortney T. Buffington, N0MJS, Eric Craw, KF7EEL, kf7eel@qsl.net'
|
||||
__copyright__ = 'Copyright (c) 2016-2019 Cortney T. Buffington, N0MJS and the K0USY Group, Copyright (c) 2020-2021, Eric Craw, KF7EEL'
|
||||
__credits__ = 'Colin Durbridge, G4EML, Steve Zingman, N4IRS; Mike Zingman, N4IRR; Jonathan Naylor, G4KLX; Hans Barthen, DL5DI; Torsten Shultze, DG1HT'
|
||||
__license__ = 'GNU GPLv3'
|
||||
__maintainer__ = 'Cort Buffington, N0MJS'
|
||||
__email__ = 'n0mjs@me.com'
|
||||
__maintainer__ = 'Eric Craw, KF7EEL'
|
||||
__email__ = 'kf7eel@qsl.net'
|
||||
|
||||
# Module gobal varaibles
|
||||
##import os, ast
|
||||
|
||||
# Function to download rules
|
||||
def update_tg(CONFIG, mode, dmr_id, data):
|
||||
user_man_url = CONFIG['WEB_SERVICE']['URL']
|
||||
shared_secret = str(sha256(CONFIG['WEB_SERVICE']['SHARED_SECRET'].encode()).hexdigest())
|
||||
update_srv = {
|
||||
'update_tg':CONFIG['WEB_SERVICE']['THIS_SERVER_NAME'],
|
||||
'secret':shared_secret,
|
||||
'dmr_id': dmr_id,
|
||||
## 'ts1': data['ts1'],
|
||||
## 'ts2': data['ts2'],
|
||||
'mode': mode,
|
||||
'data': data
|
||||
}
|
||||
## print(rules_check)
|
||||
json_object = json.dumps(update_srv, indent = 4)
|
||||
|
||||
try:
|
||||
req = requests.post(user_man_url, data=json_object, headers={'Content-Type': 'application/json'})
|
||||
## resp = json.loads(req.text)
|
||||
## print(resp)
|
||||
## return resp['rules']
|
||||
except requests.ConnectionError:
|
||||
logger.error('Config server unreachable, defaulting to local config')
|
||||
## return config.build_config(cli_file)
|
||||
|
||||
|
||||
def send_unit_table(CONFIG, _data):
|
||||
user_man_url = CONFIG['WEB_SERVICE']['URL']
|
||||
shared_secret = str(sha256(CONFIG['WEB_SERVICE']['SHARED_SECRET'].encode()).hexdigest())
|
||||
sms_data = {
|
||||
'unit_table': CONFIG['WEB_SERVICE']['THIS_SERVER_NAME'],
|
||||
'secret':shared_secret,
|
||||
'data': str(_data),
|
||||
|
||||
}
|
||||
json_object = json.dumps(sms_data, indent = 4)
|
||||
|
||||
try:
|
||||
req = requests.post(user_man_url, data=json_object, headers={'Content-Type': 'application/json'})
|
||||
## resp = json.loads(req.text)
|
||||
## print(resp)
|
||||
## return resp['rules']
|
||||
except requests.ConnectionError:
|
||||
logger.error('Config server unreachable')
|
||||
|
||||
def ping(CONFIG):
|
||||
user_man_url = CONFIG['WEB_SERVICE']['URL']
|
||||
shared_secret = str(sha256(CONFIG['WEB_SERVICE']['SHARED_SECRET'].encode()).hexdigest())
|
||||
ping_data = {
|
||||
'ping': CONFIG['WEB_SERVICE']['THIS_SERVER_NAME'],
|
||||
'secret':shared_secret
|
||||
|
||||
}
|
||||
## print(rules_check)
|
||||
json_object = json.dumps(ping_data, indent = 4)
|
||||
|
||||
try:
|
||||
req = requests.post(user_man_url, data=json_object, headers={'Content-Type': 'application/json'})
|
||||
## resp = json.loads(req.text)
|
||||
## print(resp)
|
||||
## return resp['rules']
|
||||
except requests.ConnectionError:
|
||||
logger.error('Config server unreachable')
|
||||
## return config.build_config(cli_file)
|
||||
|
||||
|
||||
# Function to download rules
|
||||
def download_rules(L_CONFIG_FILE, cli_file):
|
||||
user_man_url = L_CONFIG_FILE['WEB_SERVICE']['URL']
|
||||
shared_secret = str(sha256(L_CONFIG_FILE['WEB_SERVICE']['SHARED_SECRET'].encode()).hexdigest())
|
||||
rules_check = {
|
||||
'get_rules':L_CONFIG_FILE['WEB_SERVICE']['THIS_SERVER_NAME'],
|
||||
'secret':shared_secret
|
||||
}
|
||||
## print(rules_check)
|
||||
json_object = json.dumps(rules_check, indent = 4)
|
||||
|
||||
try:
|
||||
req = requests.post(user_man_url, data=json_object, headers={'Content-Type': 'application/json'})
|
||||
resp = json.loads(req.text)
|
||||
## print(resp)
|
||||
return resp['rules']
|
||||
except requests.ConnectionError:
|
||||
logger.error('Config server unreachable, defaulting to local config')
|
||||
return config.build_config(cli_file)
|
||||
|
||||
|
||||
# Function to download config
|
||||
def download_config(L_CONFIG_FILE, cli_file):
|
||||
user_man_url = L_CONFIG_FILE['WEB_SERVICE']['URL']
|
||||
shared_secret = str(sha256(L_CONFIG_FILE['WEB_SERVICE']['SHARED_SECRET'].encode()).hexdigest())
|
||||
config_check = {
|
||||
'get_config':L_CONFIG_FILE['WEB_SERVICE']['THIS_SERVER_NAME'],
|
||||
'secret':shared_secret
|
||||
}
|
||||
json_object = json.dumps(config_check, indent = 4)
|
||||
|
||||
try:
|
||||
req = requests.post(user_man_url, data=json_object, headers={'Content-Type': 'application/json'})
|
||||
resp = json.loads(req.text)
|
||||
iterate_config = resp['peers'].copy()
|
||||
corrected_config = resp['config'].copy()
|
||||
corrected_config['SYSTEMS'] = {}
|
||||
corrected_config['LOGGER'] = {}
|
||||
iterate_config.update(resp['masters'].copy())
|
||||
corrected_config['SYSTEMS'].update(iterate_config)
|
||||
corrected_config['LOGGER'].update(L_CONFIG_FILE['LOGGER'])
|
||||
## corrected_config['WEB_SERVICE'].update(resp['config']['WEB_SERVICE'])
|
||||
corrected_config['WEB_SERVICE'] = {}
|
||||
corrected_config['WEB_SERVICE']['THIS_SERVER_NAME'] = L_CONFIG_FILE['WEB_SERVICE']['THIS_SERVER_NAME']
|
||||
corrected_config['WEB_SERVICE']['URL'] = L_CONFIG_FILE['WEB_SERVICE']['URL']
|
||||
corrected_config['WEB_SERVICE']['SHARED_SECRET'] = L_CONFIG_FILE['WEB_SERVICE']['SHARED_SECRET']
|
||||
corrected_config['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] = L_CONFIG_FILE['WEB_SERVICE']['REMOTE_CONFIG_ENABLED']
|
||||
corrected_config['WEB_SERVICE'].update(resp['config']['WEB_SERVICE'])
|
||||
corrected_config['GLOBAL']['TG1_ACL'] = config.acl_build(corrected_config['GLOBAL']['TG1_ACL'], 4294967295)
|
||||
corrected_config['GLOBAL']['TG2_ACL'] = config.acl_build(corrected_config['GLOBAL']['TG2_ACL'], 4294967295)
|
||||
corrected_config['GLOBAL']['REG_ACL'] = config.acl_build(corrected_config['GLOBAL']['REG_ACL'], 4294967295)
|
||||
corrected_config['GLOBAL']['SUB_ACL'] = config.acl_build(corrected_config['GLOBAL']['SUB_ACL'], 4294967295)
|
||||
## corrected_config['SYSTEMS'] = {}
|
||||
for i in iterate_config:
|
||||
## corrected_config['SYSTEMS'][i]['GROUP_HANGTIME'] = int(iterate_config[i]['GROUP_HANGTIME'])
|
||||
## corrected_config['SYSTEMS'][i] = {}
|
||||
## print(iterate_config[i])
|
||||
if iterate_config[i]['MODE'] == 'MASTER' or iterate_config[i]['MODE'] == 'PROXY' or iterate_config[i]['MODE'] == 'OPENBRIDGE':
|
||||
## print(iterate_config[i])
|
||||
corrected_config['SYSTEMS'][i]['TG1_ACL'] = config.acl_build(iterate_config[i]['TG1_ACL'], 4294967295)
|
||||
corrected_config['SYSTEMS'][i]['TG2_ACL'] = config.acl_build(iterate_config[i]['TG2_ACL'], 4294967295)
|
||||
corrected_config['SYSTEMS'][i]['PASSPHRASE'] = bytes(iterate_config[i]['PASSPHRASE'], 'utf-8')
|
||||
if iterate_config[i]['MODE'] == 'OPENBRIDGE':
|
||||
## corrected_config['SYSTEMS'][i]['NETWORK_ID'] = int(iterate_config[i]['NETWORK_ID']).to_bytes(4, 'big')
|
||||
corrected_config['SYSTEMS'][i]['NETWORK_ID'] = int(iterate_config[i]['NETWORK_ID']).to_bytes(4, 'big')
|
||||
corrected_config['SYSTEMS'][i]['PASSPHRASE'] = (iterate_config[i]['PASSPHRASE'] + b'\x00' * 30)[:20] #bytes(re.sub('', "b'|'", str(iterate_config[i]['PASSPHRASE'])).ljust(20, '\x00')[:20], 'utf-8') #bytes(iterate_config[i]['PASSPHRASE'].ljust(20,'\x00')[:20], 'utf-8')
|
||||
corrected_config['SYSTEMS'][i]['BOTH_SLOTS'] = iterate_config[i]['BOTH_SLOTS']
|
||||
corrected_config['SYSTEMS'][i]['TARGET_SOCK'] = (gethostbyname(iterate_config[i]['TARGET_IP']), iterate_config[i]['TARGET_PORT'])
|
||||
corrected_config['SYSTEMS'][i]['ENCRYPTION_KEY'] = bytes(iterate_config[i]['ENCRYPTION_KEY'], 'utf-8')
|
||||
corrected_config['SYSTEMS'][i]['USE_ENCRYPTION'] = iterate_config[i]['USE_ENCRYPTION']
|
||||
|
||||
|
||||
if iterate_config[i]['MODE'] == 'PEER' or iterate_config[i]['MODE'] == 'XLXPEER':
|
||||
## print(iterate_config[i])
|
||||
corrected_config['SYSTEMS'][i]['GROUP_HANGTIME'] = int(iterate_config[i]['GROUP_HANGTIME'])
|
||||
corrected_config['SYSTEMS'][i]['RADIO_ID'] = int(iterate_config[i]['RADIO_ID']).to_bytes(4, 'big')
|
||||
corrected_config['SYSTEMS'][i]['TG1_ACL'] = config.acl_build(iterate_config[i]['TG1_ACL'], 4294967295)
|
||||
corrected_config['SYSTEMS'][i]['TG2_ACL'] = config.acl_build(iterate_config[i]['TG2_ACL'], 4294967295)
|
||||
## corrected_config['SYSTEMS'][i]['SUB_ACL'] = config.acl_build(iterate_config[i]['SUB_ACL'], 4294967295)
|
||||
corrected_config['SYSTEMS'][i]['MASTER_SOCKADDR'] = tuple(iterate_config[i]['MASTER_SOCKADDR'])
|
||||
corrected_config['SYSTEMS'][i]['SOCK_ADDR'] = tuple(iterate_config[i]['SOCK_ADDR'])
|
||||
corrected_config['SYSTEMS'][i]['PASSPHRASE'] = bytes((iterate_config[i]['PASSPHRASE']), 'utf-8')
|
||||
corrected_config['SYSTEMS'][i]['CALLSIGN'] = bytes((iterate_config[i]['CALLSIGN']).ljust(8)[:8], 'utf-8')
|
||||
corrected_config['SYSTEMS'][i]['RX_FREQ'] = bytes((iterate_config[i]['RX_FREQ']).ljust(9)[:9], 'utf-8')
|
||||
corrected_config['SYSTEMS'][i]['TX_FREQ'] = bytes((iterate_config[i]['TX_FREQ']).ljust(9)[:9], 'utf-8')
|
||||
corrected_config['SYSTEMS'][i]['TX_POWER'] = bytes((iterate_config[i]['TX_POWER']).rjust(2,'0'), 'utf-8')
|
||||
corrected_config['SYSTEMS'][i]['COLORCODE'] = bytes((iterate_config[i]['COLORCODE']).rjust(2,'0'), 'utf-8')
|
||||
corrected_config['SYSTEMS'][i]['LATITUDE'] = bytes((iterate_config[i]['LATITUDE']).ljust(8)[:8], 'utf-8')
|
||||
corrected_config['SYSTEMS'][i]['LONGITUDE'] = bytes((iterate_config[i]['LONGITUDE']).ljust(9)[:9], 'utf-8')
|
||||
corrected_config['SYSTEMS'][i]['HEIGHT'] = bytes((iterate_config[i]['HEIGHT']).rjust(3,'0'), 'utf-8')
|
||||
corrected_config['SYSTEMS'][i]['LOCATION'] = bytes((iterate_config[i]['LOCATION']).ljust(20)[:20], 'utf-8')
|
||||
corrected_config['SYSTEMS'][i]['DESCRIPTION'] = bytes((iterate_config[i]['DESCRIPTION']).ljust(19)[:19], 'utf-8')
|
||||
corrected_config['SYSTEMS'][i]['SLOTS'] = bytes((iterate_config[i]['SLOTS']), 'utf-8')
|
||||
corrected_config['SYSTEMS'][i]['URL'] = bytes((iterate_config[i]['URL']).ljust(124)[:124], 'utf-8')
|
||||
corrected_config['SYSTEMS'][i]['SOFTWARE_ID'] = bytes(('Development').ljust(40)[:40], 'utf-8')#bytes(('HBNet V1.0').ljust(40)[:40], 'utf-8')
|
||||
corrected_config['SYSTEMS'][i]['PACKAGE_ID'] = bytes(('HBNet').ljust(40)[:40], 'utf-8')
|
||||
corrected_config['SYSTEMS'][i]['OPTIONS'] = b''.join([b'Type=HBNet;', bytes(iterate_config[i]['OPTIONS'], 'utf-8')])
|
||||
|
||||
|
||||
|
||||
|
||||
if iterate_config[i]['MODE'] == 'PEER':
|
||||
corrected_config['SYSTEMS'][i].update({'STATS':{
|
||||
'CONNECTION': 'NO', # NO, RTPL_SENT, AUTHENTICATED, CONFIG-SENT, YES
|
||||
'CONNECTED': None,
|
||||
'PINGS_SENT': 0,
|
||||
'PINGS_ACKD': 0,
|
||||
'NUM_OUTSTANDING': 0,
|
||||
'PING_OUTSTANDING': False,
|
||||
'LAST_PING_TX_TIME': 0,
|
||||
'LAST_PING_ACK_TIME': 0,
|
||||
}})
|
||||
if iterate_config[i]['MODE'] == 'XLXPEER':
|
||||
corrected_config['SYSTEMS'][i].update({'XLXSTATS': {
|
||||
'CONNECTION': 'NO', # NO, RTPL_SENT, AUTHENTICATED, CONFIG-SENT, YES
|
||||
'CONNECTED': None,
|
||||
'PINGS_SENT': 0,
|
||||
'PINGS_ACKD': 0,
|
||||
'NUM_OUTSTANDING': 0,
|
||||
'PING_OUTSTANDING': False,
|
||||
'LAST_PING_TX_TIME': 0,
|
||||
'LAST_PING_ACK_TIME': 0,
|
||||
}})
|
||||
corrected_config['SYSTEMS'][i]['USE_ACL'] = iterate_config[i]['USE_ACL']
|
||||
corrected_config['SYSTEMS'][i]['SUB_ACL'] = config.acl_build(iterate_config[i]['SUB_ACL'], 16776415)
|
||||
|
||||
return corrected_config
|
||||
# For exception, write blank dict
|
||||
except requests.ConnectionError:
|
||||
logger.error('Config server unreachable, defaulting to local config')
|
||||
return config.build_config(cli_file)
|
||||
|
||||
|
||||
# From hotspot_proxy2, FreeDMR
|
||||
def hotspot_proxy(listen_port, port_start, port_stop):
|
||||
Master = "127.0.0.1"
|
||||
ListenPort = listen_port
|
||||
DestportStart = port_start
|
||||
DestPortEnd = port_stop
|
||||
Timeout = 30
|
||||
Stats = True
|
||||
Debug = False
|
||||
BlackList = [1234567]
|
||||
|
||||
|
||||
CONNTRACK = {}
|
||||
|
||||
for port in range(DestportStart,DestPortEnd+1,1):
|
||||
CONNTRACK[port] = False
|
||||
|
||||
|
||||
reactor.listenUDP(ListenPort,Proxy(Master,ListenPort,CONNTRACK,BlackList,Timeout,Debug,DestportStart,DestPortEnd))
|
||||
|
||||
def loopingErrHandle(failure):
|
||||
logger.error('(GLOBAL) STOPPING REACTOR TO AVOID MEMORY LEAK: Unhandled error innowtimed loop.\n {}'.format(failure))
|
||||
reactor.stop()
|
||||
|
||||
def stats():
|
||||
count = 0
|
||||
nowtime = time()
|
||||
for port in CONNTRACK:
|
||||
if CONNTRACK[port]:
|
||||
count = count+1
|
||||
|
||||
totalPorts = DestPortEnd - DestportStart
|
||||
freePorts = totalPorts - count
|
||||
|
||||
logger.info("{} ports out of {} in use ({} free)".format(count,totalPorts,freePorts))
|
||||
|
||||
|
||||
|
||||
if Stats == True:
|
||||
stats_task = task.LoopingCall(stats)
|
||||
statsa = stats_task.start(30)
|
||||
statsa.addErrback(loopingErrHandle)
|
||||
|
||||
# Used to track if we have downloaded user custon rules
|
||||
user_rules = {}
|
||||
|
||||
# Dictionary for dynamically mapping unit (subscriber) to a system.
|
||||
# This is for pruning unit-to-uint calls to not broadcast once the
|
||||
# target system for a unit is identified
|
||||
# format 'unit_id': ('SYSTEM', time)
|
||||
UNIT_MAP = {}
|
||||
|
||||
# UNIX time for end of year 2060. This is used to keep subscribers in UNIT_MAP indefinitely to accomplish static routes for unit calls
|
||||
#time_2060 = 2871763199.0000000
|
||||
# 20 years in seconds. added to current at time of start to keep static units from being trimmed.
|
||||
time_20 = 630720000
|
||||
|
||||
# Build a UNIT_MAP based on values in STATIC_MAP.
|
||||
for i in STATIC_UNIT:
|
||||
UNIT_MAP[bytes_3(i[0])] = i[1], time() + time_20
|
||||
BRIDGES = {}
|
||||
|
||||
# Timed loop used for reporting HBP status
|
||||
#
|
||||
|
@ -106,6 +357,27 @@ def config_reports(_config, _factory):
|
|||
|
||||
return report_server
|
||||
|
||||
# Send data to all OBP connections that have an encryption key. Data such as subscribers are sent to other HBNet servers.
|
||||
def svrd_send_all(_svrd_data):
|
||||
_svrd_packet = SVRD
|
||||
for system in CONFIG['SYSTEMS']:
|
||||
if CONFIG['SYSTEMS'][system]['ENABLED']:
|
||||
if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE':
|
||||
if CONFIG['SYSTEMS'][system]['ENCRYPTION_KEY'] != b'':
|
||||
systems[system].send_system(_svrd_packet + _svrd_data)
|
||||
|
||||
# Send any data packets to connections with ALL_DATA specified in other options
|
||||
def mirror_traffic(_data):
|
||||
for system in CONFIG['SYSTEMS']:
|
||||
if CONFIG['SYSTEMS'][system]['ENABLED']:
|
||||
if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE':
|
||||
print(CONFIG['SYSTEMS'][system]['OTHER_OPTIONS'])
|
||||
if 'MIRROR_ALL_TRAFFIC' in CONFIG['SYSTEMS'][system]['OTHER_OPTIONS']:
|
||||
print('mirrored to ' + system)
|
||||
print(_data)
|
||||
systems[system].send_system(SVRD + b'DATA' + _data)
|
||||
|
||||
|
||||
|
||||
# Import Bridging rules
|
||||
# Note: A stanza *must* exist for any MASTER or CLIENT configured in the main
|
||||
|
@ -133,11 +405,12 @@ def make_bridges(_rules):
|
|||
|
||||
|
||||
# Run this every minute for rule timer updates
|
||||
def rule_timer_loop():
|
||||
def rule_timer_loop(unit_flood_time):
|
||||
global UNIT_MAP
|
||||
logger.debug('(ROUTER) routerHBP Rule timer loop started')
|
||||
_now = time()
|
||||
|
||||
#This is a good place to get and modify rules for users
|
||||
## print(BRIDGES)
|
||||
for _bridge in BRIDGES:
|
||||
for _system in BRIDGES[_bridge]:
|
||||
if _system['TO_TYPE'] == 'ON':
|
||||
|
@ -145,6 +418,10 @@ def rule_timer_loop():
|
|||
if _system['TIMER'] < _now:
|
||||
_system['ACTIVE'] = False
|
||||
logger.info('(ROUTER) Conference Bridge TIMEOUT: DEACTIVATE System: %s, Bridge: %s, TS: %s, TGID: %s', _system['SYSTEM'], _bridge, _system['TS'], int_id(_system['TGID']))
|
||||
# Send not active POST
|
||||
#update_tg(CONFIG, 'off', 0, [{'SYSTEM':_system['SYSTEM']}, {'ts':_system['TS']}, {'tg': int_id(_system['TGID'])}])
|
||||
|
||||
## print(_system)
|
||||
else:
|
||||
timeout_in = _system['TIMER'] - _now
|
||||
logger.info('(ROUTER) Conference Bridge ACTIVE (ON timer running): System: %s Bridge: %s, TS: %s, TGID: %s, Timeout in: %.2fs,', _system['SYSTEM'], _bridge, _system['TS'], int_id(_system['TGID']), timeout_in)
|
||||
|
@ -155,23 +432,30 @@ def rule_timer_loop():
|
|||
if _system['TIMER'] < _now:
|
||||
_system['ACTIVE'] = True
|
||||
logger.info('(ROUTER) Conference Bridge TIMEOUT: ACTIVATE System: %s, Bridge: %s, TS: %s, TGID: %s', _system['SYSTEM'], _bridge, _system['TS'], int_id(_system['TGID']))
|
||||
# POST ON
|
||||
## update_tg(CONFIG, 'on', 0, [{'SYSTEM':_system['SYSTEM']}, {'ts':_system['TS']}, {'tg': int_id(_system['TGID'])}])
|
||||
else:
|
||||
timeout_in = _system['TIMER'] - _now
|
||||
logger.info('(ROUTER) Conference Bridge INACTIVE (OFF timer running): System: %s Bridge: %s, TS: %s, TGID: %s, Timeout in: %.2fs,', _system['SYSTEM'], _bridge, _system['TS'], int_id(_system['TGID']), timeout_in)
|
||||
elif _system['ACTIVE'] == True:
|
||||
logger.debug('(ROUTER) Conference Bridge ACTIVE (no change): System: %s Bridge: %s, TS: %s, TGID: %s', _system['SYSTEM'], _bridge, _system['TS'], int_id(_system['TGID']))
|
||||
# POST on
|
||||
## print(_system)
|
||||
## update_tg(CONFIG, 'on', 0, [{'SYSTEM':_system['SYSTEM']}, {'ts':_system['TS']}, {'tg': int_id(_system['TGID'])}])
|
||||
else:
|
||||
logger.debug('(ROUTER) Conference Bridge NO ACTION: System: %s, Bridge: %s, TS: %s, TGID: %s', _system['SYSTEM'], _bridge, _system['TS'], int_id(_system['TGID']))
|
||||
|
||||
_then = _now - 60 * UNIT_TIME
|
||||
remove_list = []
|
||||
#logger.info(UNIT_MAP)
|
||||
for unit in UNIT_MAP:
|
||||
if UNIT_MAP[unit][1] < (_then):
|
||||
remove_list.append(unit)
|
||||
svrd_send_all(b'UNIT' + unit)
|
||||
_then = _now - unit_flood_time
|
||||
remove_list = []
|
||||
for unit in UNIT_MAP:
|
||||
if UNIT_MAP[unit][1] < (_then):
|
||||
remove_list.append(unit)
|
||||
|
||||
for unit in remove_list:
|
||||
del UNIT_MAP[unit]
|
||||
send_unit_table(CONFIG, UNIT_MAP)
|
||||
|
||||
logger.debug('Removed unit(s) %s from UNIT_MAP', remove_list)
|
||||
|
||||
|
@ -182,9 +466,11 @@ def rule_timer_loop():
|
|||
|
||||
# run this every 10 seconds to trim orphaned stream ids
|
||||
def stream_trimmer_loop():
|
||||
print(UNIT_MAP)
|
||||
ping(CONFIG)
|
||||
logger.debug('(ROUTER) Trimming inactive stream IDs from system lists')
|
||||
_now = time()
|
||||
|
||||
|
||||
for system in systems:
|
||||
# HBP systems, master and peer
|
||||
if CONFIG['SYSTEMS'][system]['MODE'] != 'OPENBRIDGE':
|
||||
|
@ -240,6 +526,19 @@ class routerOBP(OPENBRIDGE):
|
|||
# list of self._targets for unit (subscriber, private) calls
|
||||
self._targets = []
|
||||
|
||||
def svrd_received(self, _mode, _data):
|
||||
print(UNIT_MAP)
|
||||
logger.info('SVRD Received. Mode: ' + str(_mode) + ' Data: ' + str(_data))
|
||||
if _mode == b'UNIT':
|
||||
UNIT_MAP[_data] = (self._system, time())
|
||||
|
||||
## def mmdvm_cmd(self, _cmd):
|
||||
## print('---')
|
||||
## print(_cmd)
|
||||
## print('---')
|
||||
## pass
|
||||
|
||||
|
||||
def group_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _frame_type, _dtype_vseq, _stream_id, _data):
|
||||
pkt_time = time()
|
||||
dmrpkt = _data[20:53]
|
||||
|
@ -439,18 +738,12 @@ class routerOBP(OPENBRIDGE):
|
|||
pkt_time = time()
|
||||
dmrpkt = _data[20:53]
|
||||
_bits = _data[15]
|
||||
|
||||
# Check if subscriber is in STATIC_UNIT
|
||||
for i in STATIC_UNIT:
|
||||
# Subscriber is static. Add 20 years of time.
|
||||
if i[0] == int_id(_rf_src):
|
||||
map_time = pkt_time + time_20
|
||||
logger.debug('Static Unit, update time.')
|
||||
# Proceed as normal
|
||||
else:
|
||||
map_time = pkt_time
|
||||
|
||||
# Make/update this unit in the UNIT_MAP cache
|
||||
UNIT_MAP[_rf_src] = (self.name, map_time)
|
||||
UNIT_MAP[_rf_src] = (self.name, pkt_time)
|
||||
|
||||
# Send update to all OpenBridge connections
|
||||
## svrd_send_all(b'UNIT' + _rf_src) # + b'TIME' + pkt_time)
|
||||
|
||||
|
||||
# Is this a new call stream?
|
||||
|
@ -597,18 +890,16 @@ class routerOBP(OPENBRIDGE):
|
|||
elif _call_type == 'unit':
|
||||
self.unit_received(_peer_id, _rf_src, _dst_id, _seq, _slot, _frame_type, _dtype_vseq, _stream_id, _data)
|
||||
elif _call_type == 'vcsbk':
|
||||
# Route CSBK packets to destination TG. Necessary for group data to work with GPS/Data decoder.
|
||||
self.group_received(_peer_id, _rf_src, _dst_id, _seq, _slot, _frame_type, _dtype_vseq, _stream_id, _data)
|
||||
logger.debug('CSBK recieved, but HBlink does not process them currently. Packets routed to talkgroup.')
|
||||
|
||||
logger.debug('CSBK recieved, forwarded to destination TG.')
|
||||
else:
|
||||
logger.error('Unknown call type recieved -- not processed')
|
||||
|
||||
|
||||
class routerHBP(HBSYSTEM):
|
||||
|
||||
def __init__(self, _name, _config, _report):
|
||||
HBSYSTEM.__init__(self, _name, _config, _report)
|
||||
## print(_config)
|
||||
self.name = _name
|
||||
|
||||
# list of self._targets for unit (subscriber, private) calls
|
||||
|
@ -671,17 +962,18 @@ class routerHBP(HBSYSTEM):
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def group_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _frame_type, _dtype_vseq, _stream_id, _data):
|
||||
global UNIT_MAP
|
||||
pkt_time = time()
|
||||
dmrpkt = _data[20:53]
|
||||
_bits = _data[15]
|
||||
|
||||
|
||||
# Make/update an entry in the UNIT_MAP for this subscriber
|
||||
UNIT_MAP[_rf_src] = (self.name, pkt_time)
|
||||
|
||||
# Update other servers via OBP
|
||||
## svrd_send_all(b'UNIT' + _rf_src) # + b'TIME' + pkt_time)
|
||||
|
||||
# Is this a new call stream?
|
||||
if (_stream_id != self.STATUS[_slot]['RX_STREAM_ID']):
|
||||
if (self.STATUS[_slot]['RX_TYPE'] != HBPF_SLT_VTERM) and (pkt_time < (self.STATUS[_slot]['RX_TIME'] + STREAM_TO)) and (_rf_src != self.STATUS[_slot]['RX_RFS']):
|
||||
|
@ -689,6 +981,10 @@ class routerHBP(HBSYSTEM):
|
|||
return
|
||||
|
||||
# This is a new call stream
|
||||
|
||||
# Send subscriber ID over OBP
|
||||
svrd_send_all(b'UNIT' + _rf_src)
|
||||
|
||||
self.STATUS[_slot]['RX_START'] = pkt_time
|
||||
logger.info('(%s) *GROUP CALL START* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s', \
|
||||
self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot)
|
||||
|
@ -704,10 +1000,22 @@ class routerHBP(HBSYSTEM):
|
|||
# just make a new one from the HBP header. This is good enough, and it saves lots of time
|
||||
else:
|
||||
self.STATUS[_slot]['RX_LC'] = LC_OPT + _dst_id + _rf_src
|
||||
|
||||
# Download rules
|
||||
if _rf_src not in user_rules:
|
||||
user_rules[_rf_src] = self.name
|
||||
if _rf_src in user_rules:
|
||||
## print('in')
|
||||
if user_rules[_rf_src] != self.name:
|
||||
user_rules[_rf_src] = self.name
|
||||
## print('updated')
|
||||
## print(user_rules)
|
||||
for _bridge in BRIDGES:
|
||||
## print(BRIDGES)
|
||||
## print(_bridge)
|
||||
# Match bridge name here
|
||||
for _system in BRIDGES[_bridge]:
|
||||
|
||||
## print(_system)
|
||||
# Modify rule here for indiv system
|
||||
if (_system['SYSTEM'] == self._system and _system['TGID'] == _dst_id and _system['TS'] == _slot and _system['ACTIVE'] == True):
|
||||
|
||||
for _target in BRIDGES[_bridge]:
|
||||
|
@ -869,6 +1177,10 @@ class routerHBP(HBSYSTEM):
|
|||
for _bridge in BRIDGES:
|
||||
for _system in BRIDGES[_bridge]:
|
||||
if _system['SYSTEM'] == self._system:
|
||||
## # Insert POST for TG timer update?
|
||||
## print(_system)
|
||||
## print()
|
||||
## print(datetime.fromtimestamp(_system['TIMER']).strftime('%H:%M:%S - %m/%d/%y'))
|
||||
|
||||
# TGID matches a rule source, reset its timer
|
||||
if _slot == _system['TS'] and _dst_id == _system['TGID'] and ((_system['TO_TYPE'] == 'ON' and (_system['ACTIVE'] == True)) or (_system['TO_TYPE'] == 'OFF' and _system['ACTIVE'] == False)):
|
||||
|
@ -877,11 +1189,17 @@ class routerHBP(HBSYSTEM):
|
|||
|
||||
# TGID matches an ACTIVATION trigger
|
||||
if (_dst_id in _system['ON'] or _dst_id in _system['RESET']) and _slot == _system['TS']:
|
||||
# POST update TG for self care
|
||||
update_tg(CONFIG, 'on', int(str(int_id(self.STATUS[2]['RX_PEER']))[:7]), [{'SYSTEM':_system['SYSTEM']}, {'ts1':int_id(self.STATUS[1]['RX_TGID'])}, {'ts2':int_id(self.STATUS[2]['RX_TGID'])}])
|
||||
## print(datetime.fromtimestamp(_system['TIMER']).strftime('%H:%M:%S - %m/%d/%y'))
|
||||
|
||||
## update_tg(CONFIG, mode, dmr_id, data)
|
||||
# Set the matching rule as ACTIVE
|
||||
if _dst_id in _system['ON']:
|
||||
if _system['ACTIVE'] == False:
|
||||
_system['ACTIVE'] = True
|
||||
_system['TIMER'] = pkt_time + _system['TIMEOUT']
|
||||
|
||||
logger.info('(%s) Bridge: %s, connection changed to state: %s', self._system, _bridge, _system['ACTIVE'])
|
||||
# Cancel the timer if we've enabled an "OFF" type timeout
|
||||
if _system['TO_TYPE'] == 'OFF':
|
||||
|
@ -899,6 +1217,9 @@ class routerHBP(HBSYSTEM):
|
|||
if _system['ACTIVE'] == True:
|
||||
_system['ACTIVE'] = False
|
||||
logger.info('(%s) Bridge: %s, connection changed to state: %s', self._system, _bridge, _system['ACTIVE'])
|
||||
# POST off
|
||||
update_tg(CONFIG, 'off', 0, [{'SYSTEM':_system['SYSTEM']}, {'ts':_system['TS']}, {'tg': int_id(_system['TGID'])}])
|
||||
## update_tg(CONFIG, 'on', int(str(int_id(self.STATUS[2]['RX_PEER']))[:7]), [{'SYSTEM':_system['SYSTEM']}, {'ts1':int_id(self.STATUS[1]['RX_TGID'])}, {'ts2':int_id(self.STATUS[2]['RX_TGID'])}])
|
||||
# Cancel the timer if we've enabled an "ON" type timeout
|
||||
if _system['TO_TYPE'] == 'ON':
|
||||
_system['TIMER'] = pkt_time
|
||||
|
@ -930,20 +1251,12 @@ class routerHBP(HBSYSTEM):
|
|||
pkt_time = time()
|
||||
dmrpkt = _data[20:53]
|
||||
_bits = _data[15]
|
||||
|
||||
# Check if subscriber is in STATIC_UNIT
|
||||
for i in STATIC_UNIT:
|
||||
# Subscriber is static. Add 20 years of time.
|
||||
if i[0] == int_id(_rf_src):
|
||||
map_time = pkt_time + time_20
|
||||
logger.debug('Static Unit, update time.')
|
||||
# Proceed as normal
|
||||
else:
|
||||
map_time = pkt_time
|
||||
|
||||
|
||||
# Make/update this unit in the UNIT_MAP cache
|
||||
UNIT_MAP[_rf_src] = (self.name, map_time)
|
||||
UNIT_MAP[_rf_src] = (self.name, pkt_time)
|
||||
|
||||
# Update other servers via OBP
|
||||
## svrd_send_all(b'UNIT' + _rf_src) # + b'TIME' + pkt_time)
|
||||
|
||||
|
||||
# Is this a new call stream?
|
||||
|
@ -966,6 +1279,7 @@ class routerHBP(HBSYSTEM):
|
|||
self._targets.remove(self._system)
|
||||
|
||||
# This is a new call stream, so log & report
|
||||
svrd_send_all(b'UNIT' + _rf_src)
|
||||
self.STATUS[_slot]['RX_START'] = pkt_time
|
||||
logger.info('(%s) *UNIT CALL START* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) UNIT: %s (%s), TS: %s, FORWARD: %s', \
|
||||
self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot, self._targets)
|
||||
|
@ -1076,21 +1390,23 @@ class routerHBP(HBSYSTEM):
|
|||
self.STATUS[_slot]['RX_TIME'] = pkt_time
|
||||
self.STATUS[_slot]['RX_STREAM_ID'] = _stream_id
|
||||
|
||||
|
||||
def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data):
|
||||
if _call_type == 'group':
|
||||
self.group_received(_peer_id, _rf_src, _dst_id, _seq, _slot, _frame_type, _dtype_vseq, _stream_id, _data)
|
||||
mirror_traffic(_data)
|
||||
elif _call_type == 'unit':
|
||||
if self._system not in UNIT:
|
||||
logger.error('(%s) *UNIT CALL NOT FORWARDED* UNIT calling is disabled for this system (INGRESS)', self._system)
|
||||
else:
|
||||
self.unit_received(_peer_id, _rf_src, _dst_id, _seq, _slot, _frame_type, _dtype_vseq, _stream_id, _data)
|
||||
mirror_traffic(_data)
|
||||
elif _call_type == 'vcsbk':
|
||||
# Route CSBK packets to destination TG. Necessary for group data to work with GPS/Data decoder.
|
||||
self.group_received(_peer_id, _rf_src, _dst_id, _seq, _slot, _frame_type, _dtype_vseq, _stream_id, _data)
|
||||
logger.debug('CSBK recieved, but HBlink does not process them currently. Packets routed to talkgroup.')
|
||||
logger.debug('CSBK recieved, forwarded to destination TG.')
|
||||
mirror_traffic(_data)
|
||||
else:
|
||||
logger.error('Unknown call type recieved -- not processed')
|
||||
mirror_traffic(_data)
|
||||
|
||||
#
|
||||
# Socket-based reporting section
|
||||
|
@ -1118,22 +1434,30 @@ if __name__ == '__main__':
|
|||
import os
|
||||
import signal
|
||||
|
||||
## global unit_flood_time
|
||||
|
||||
# Change the current directory to the location of the application
|
||||
os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])))
|
||||
|
||||
# CLI argument parser - handles picking up the config file from the command line, and sending a "help" message
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-c', '--config', action='store', dest='CONFIG_FILE', help='/full/path/to/config.file (usually hblink.cfg)')
|
||||
parser.add_argument('-c', '--config', action='store', dest='CONFIG_FILE', help='/full/path/to/config.file (usually hbnet.cfg)')
|
||||
parser.add_argument('-r', '--rules', action='store', dest='RULES_FILE', help='/full/path/to/rules.file (usually rules.py)')
|
||||
parser.add_argument('-l', '--logging', action='store', dest='LOG_LEVEL', help='Override config file logging level.')
|
||||
cli_args = parser.parse_args()
|
||||
|
||||
# Ensure we have a path for the config file, if one wasn't specified, then use the default (top of file)
|
||||
if not cli_args.CONFIG_FILE:
|
||||
cli_args.CONFIG_FILE = os.path.dirname(os.path.abspath(__file__))+'/hblink.cfg'
|
||||
cli_args.CONFIG_FILE = os.path.dirname(os.path.abspath(__file__))+'/hbnet.cfg'
|
||||
|
||||
# Call the external routine to build the configuration dictionary
|
||||
CONFIG = config.build_config(cli_args.CONFIG_FILE)
|
||||
LOCAL_CONFIG = config.build_config(cli_args.CONFIG_FILE)
|
||||
if LOCAL_CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED']:
|
||||
CONFIG = download_config(LOCAL_CONFIG, cli_args.CONFIG_FILE)
|
||||
## print(CONFIG['SYSTEMS'])
|
||||
## print('enabled')
|
||||
else:
|
||||
CONFIG = config.build_config(cli_args.CONFIG_FILE)
|
||||
|
||||
# Ensure we have a path for the rules file, if one wasn't specified, then use the default (top of file)
|
||||
if not cli_args.RULES_FILE:
|
||||
|
@ -1143,6 +1467,7 @@ if __name__ == '__main__':
|
|||
if cli_args.LOG_LEVEL:
|
||||
CONFIG['LOGGER']['LOG_LEVEL'] = cli_args.LOG_LEVEL
|
||||
logger = log.config_logging(CONFIG['LOGGER'])
|
||||
logger.info('\n\nCopyright (c) 2020, 2021\n\tKF7EEL - Eric, kf7eel@qsl.net - All rights reserved.\n')
|
||||
logger.info('\n\nCopyright (c) 2013, 2014, 2015, 2016, 2018, 2019, 2020\n\tThe Regents of the K0USY Group. All rights reserved.\n')
|
||||
logger.debug('(GLOBAL) Logging system started, anything from here on gets logged')
|
||||
|
||||
|
@ -1160,20 +1485,6 @@ if __name__ == '__main__':
|
|||
# Create the name-number mapping dictionaries
|
||||
peer_ids, subscriber_ids, talkgroup_ids = mk_aliases(CONFIG)
|
||||
|
||||
# Import the ruiles file as a module, and create BRIDGES from it
|
||||
spec = importlib.util.spec_from_file_location("module.name", cli_args.RULES_FILE)
|
||||
rules_module = importlib.util.module_from_spec(spec)
|
||||
try:
|
||||
spec.loader.exec_module(rules_module)
|
||||
logger.info('(ROUTER) Routing bridges file found and bridges imported: %s', cli_args.RULES_FILE)
|
||||
except (ImportError, FileNotFoundError):
|
||||
sys.exit('(ROUTER) TERMINATING: Routing bridges file not found or invalid: {}'.format(cli_args.RULES_FILE))
|
||||
|
||||
# Build the routing rules file
|
||||
BRIDGES = make_bridges(rules_module.BRIDGES)
|
||||
|
||||
# Get rule parameter for private calls
|
||||
UNIT = rules_module.UNIT
|
||||
|
||||
# INITIALIZE THE REPORTING LOOP
|
||||
if CONFIG['REPORTS']['REPORT']:
|
||||
|
@ -1183,7 +1494,92 @@ if __name__ == '__main__':
|
|||
logger.info('(REPORT) TCP Socket reporting not configured')
|
||||
|
||||
# HBlink instance creation
|
||||
logger.info('(GLOBAL) HBlink \'bridge.py\' -- SYSTEM STARTING...')
|
||||
logger.info('(GLOBAL) HBNet \'hbnet.py\' -- SYSTEM STARTING...')
|
||||
|
||||
# Generate list of Enabled MODE: PROXY masters
|
||||
proxy_master_list = []
|
||||
for i in CONFIG['SYSTEMS']:
|
||||
if CONFIG['SYSTEMS'][i]['ENABLED'] == True:
|
||||
if CONFIG['SYSTEMS'][i]['MODE'] == 'PROXY':
|
||||
proxy_master_list.append(i)
|
||||
# Start proxy as a thread (if enabled in config) for each set of MASTERs
|
||||
for m in proxy_master_list:
|
||||
if CONFIG['SYSTEMS'][m]['EXTERNAL_PROXY_SCRIPT'] == False:
|
||||
proxy_thread = threading.Thread(target=hotspot_proxy, args=(CONFIG['SYSTEMS'][m]['EXTERNAL_PORT'],CONFIG['SYSTEMS'][m]['INTERNAL_PORT_START'],CONFIG['SYSTEMS'][m]['INTERNAL_PORT_STOP'],))
|
||||
proxy_thread.daemon = True
|
||||
proxy_thread.start()
|
||||
logger.info('Started thread for PROXY for MASTER set: ' + m)
|
||||
|
||||
#Build Master configs from list
|
||||
for i in proxy_master_list:
|
||||
n_systems = CONFIG['SYSTEMS'][i]['INTERNAL_PORT_STOP'] - CONFIG['SYSTEMS'][i]['INTERNAL_PORT_START']
|
||||
n_count = 0
|
||||
while n_count < n_systems:
|
||||
CONFIG['SYSTEMS'].update({i + '-' + str(n_count): {
|
||||
'MODE': 'MASTER',
|
||||
'ENABLED': True,
|
||||
'STATIC_APRS_POSITION_ENABLED': CONFIG['SYSTEMS'][i]['STATIC_APRS_POSITION_ENABLED'],
|
||||
'USE_USER_MAN': CONFIG['SYSTEMS'][i]['USE_USER_MAN'],
|
||||
'REPEAT': CONFIG['SYSTEMS'][i]['REPEAT'],
|
||||
'MAX_PEERS': 1,
|
||||
'IP': '127.0.0.1',
|
||||
'PORT': CONFIG['SYSTEMS'][i]['INTERNAL_PORT_START'] + n_count,
|
||||
'PASSPHRASE': CONFIG['SYSTEMS'][i]['PASSPHRASE'],
|
||||
'GROUP_HANGTIME': CONFIG['SYSTEMS'][i]['GROUP_HANGTIME'],
|
||||
'USE_ACL': CONFIG['SYSTEMS'][i]['USE_ACL'],
|
||||
'REG_ACL': CONFIG['SYSTEMS'][i]['REG_ACL'],
|
||||
'SUB_ACL': CONFIG['SYSTEMS'][i]['SUB_ACL'],
|
||||
'TG1_ACL': CONFIG['SYSTEMS'][i]['TG1_ACL'],
|
||||
'TG2_ACL': CONFIG['SYSTEMS'][i]['TG2_ACL']
|
||||
}})
|
||||
CONFIG['SYSTEMS'][i + '-' + str(n_count)].update({'PEERS': {}})
|
||||
systems[i + '-' + str(n_count)] = routerHBP(i + '-' + str(n_count), CONFIG, report_server)
|
||||
n_count = n_count + 1
|
||||
# Remove original MASTER stanza to prevent errors
|
||||
CONFIG['SYSTEMS'].pop(i)
|
||||
logger.info('Generated MASTER instances for proxy set: ' + i)
|
||||
|
||||
# Attempt to use downloaded rules
|
||||
if LOCAL_CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED']:
|
||||
try:
|
||||
remote_config = download_rules(LOCAL_CONFIG, cli_args.CONFIG_FILE)
|
||||
# Build the routing rules file
|
||||
BRIDGES = make_bridges(remote_config[1]) #make_bridges(rules_module.BRIDGES)
|
||||
# Get rule parameter for private calls
|
||||
UNIT = remote_config[0]
|
||||
unit_flood_time = CONFIG['OTHER']['UNIT_TIME']
|
||||
except:
|
||||
logger.error('Control server unreachable or other error. Using local config.')
|
||||
spec = importlib.util.spec_from_file_location("module.name", cli_args.RULES_FILE)
|
||||
rules_module = importlib.util.module_from_spec(spec)
|
||||
try:
|
||||
spec.loader.exec_module(rules_module)
|
||||
logger.info('(ROUTER) Routing bridges file found and bridges imported: %s', cli_args.RULES_FILE)
|
||||
except (ImportError, FileNotFoundError):
|
||||
sys.exit('(ROUTER) TERMINATING: Routing bridges file not found or invalid: {}'.format(cli_args.RULES_FILE))
|
||||
# Build the routing rules file
|
||||
BRIDGES = make_bridges(rules_module.BRIDGES)
|
||||
# Get rule parameter for private calls
|
||||
UNIT = rules_module.UNIT
|
||||
unit_flood_time = rules_module.FLOOD_TIMEOUT
|
||||
|
||||
else:
|
||||
spec = importlib.util.spec_from_file_location("module.name", cli_args.RULES_FILE)
|
||||
rules_module = importlib.util.module_from_spec(spec)
|
||||
try:
|
||||
spec.loader.exec_module(rules_module)
|
||||
logger.info('(ROUTER) Routing bridges file found and bridges imported: %s', cli_args.RULES_FILE)
|
||||
except (ImportError, FileNotFoundError):
|
||||
sys.exit('(ROUTER) TERMINATING: Routing bridges file not found or invalid: {}'.format(cli_args.RULES_FILE))
|
||||
spec = importlib.util.spec_from_file_location("module.name", cli_args.RULES_FILE)
|
||||
## print('--------')
|
||||
## print(rules_module.BRIDGES)
|
||||
# Build the routing rules file
|
||||
BRIDGES = make_bridges(rules_module.BRIDGES)
|
||||
# Get rule parameter for private calls
|
||||
UNIT = rules_module.UNIT
|
||||
unit_flood_time = rules_module.FLOOD_TIMEOUT
|
||||
|
||||
for system in CONFIG['SYSTEMS']:
|
||||
if CONFIG['SYSTEMS'][system]['ENABLED']:
|
||||
if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE':
|
||||
|
@ -1197,8 +1593,9 @@ if __name__ == '__main__':
|
|||
logger.error('(GLOBAL) STOPPING REACTOR TO AVOID MEMORY LEAK: Unhandled error in timed loop.\n %s', failure)
|
||||
reactor.stop()
|
||||
|
||||
|
||||
# Initialize the rule timer -- this if for user activated stuff
|
||||
rule_timer_task = task.LoopingCall(rule_timer_loop)
|
||||
rule_timer_task = task.LoopingCall(rule_timer_loop, unit_flood_time)
|
||||
rule_timer = rule_timer_task.start(60)
|
||||
rule_timer.addErrback(loopingErrHandle)
|
||||
|
||||
|
@ -1207,4 +1604,10 @@ if __name__ == '__main__':
|
|||
stream_trimmer = stream_trimmer_task.start(5)
|
||||
stream_trimmer.addErrback(loopingErrHandle)
|
||||
|
||||
logger.info('UNIT calls will be bridged to: ' + str(UNIT))
|
||||
|
||||
# Download burn list
|
||||
if LOCAL_CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED']:
|
||||
with open(CONFIG['WEB_SERVICE']['BURN_FILE'], 'w') as f:
|
||||
f.write(str(download_burnlist(CONFIG)))
|
||||
reactor.run()
|
||||
|
|
1935
bridge_gps_data.py
1935
bridge_gps_data.py
File diff suppressed because it is too large
Load Diff
94
config.py
94
config.py
|
@ -68,6 +68,8 @@ def acl_build(_acl, _max):
|
|||
return(True, set((const.ID_MIN, _max)))
|
||||
|
||||
acl = [] #set()
|
||||
if type(_acl) == tuple:
|
||||
_acl = ''.join(_acl)
|
||||
sections = _acl.split(':')
|
||||
|
||||
if sections[0] == 'PERMIT':
|
||||
|
@ -106,8 +108,8 @@ def build_config(_config_file):
|
|||
CONFIG['GLOBAL'] = {}
|
||||
CONFIG['REPORTS'] = {}
|
||||
CONFIG['LOGGER'] = {}
|
||||
CONFIG['GPS_DATA'] = {}
|
||||
CONFIG['ALIASES'] = {}
|
||||
CONFIG['WEB_SERVICE'] = {}
|
||||
CONFIG['SYSTEMS'] = {}
|
||||
|
||||
try:
|
||||
|
@ -142,35 +144,6 @@ def build_config(_config_file):
|
|||
if not CONFIG['LOGGER']['LOG_FILE']:
|
||||
CONFIG['LOGGER']['LOG_FILE'] = '/dev/null'
|
||||
|
||||
elif section == 'GPS_DATA':
|
||||
CONFIG['GPS_DATA'].update({
|
||||
'DATA_DMR_ID': config.get(section, 'DATA_DMR_ID'),
|
||||
'USER_APRS_SSID': config.get(section, 'USER_APRS_SSID'),
|
||||
'CALL_TYPE': config.get(section, 'CALL_TYPE'),
|
||||
'USER_APRS_COMMENT': config.get(section, 'USER_APRS_COMMENT'),
|
||||
'APRS_LOGIN_CALL': config.get(section, 'APRS_LOGIN_CALL'),
|
||||
'APRS_LOGIN_PASSCODE': config.get(section, 'APRS_LOGIN_PASSCODE'),
|
||||
'APRS_SERVER': config.get(section, 'APRS_SERVER'),
|
||||
'APRS_PORT': config.get(section, 'APRS_PORT'),
|
||||
'IGATE_BEACON_TIME': config.get(section, 'IGATE_BEACON_TIME'),
|
||||
'IGATE_BEACON_ICON': config.get(section, 'IGATE_BEACON_ICON'),
|
||||
'IGATE_BEACON_COMMENT': config.get(section, 'IGATE_BEACON_COMMENT'),
|
||||
'IGATE_LATITUDE': config.get(section, 'IGATE_LATITUDE'),
|
||||
'IGATE_LONGITUDE': config.get(section, 'IGATE_LONGITUDE'),
|
||||
'EMAIL_SENDER': config.get(section, 'EMAIL_SENDER'),
|
||||
'EMAIL_PASSWORD': config.get(section, 'EMAIL_PASSWORD'),
|
||||
'SMTP_SERVER': config.get(section, 'SMTP_SERVER'),
|
||||
'SMTP_PORT': config.get(section, 'SMTP_PORT'),
|
||||
'LOCATION_FILE': config.get(section, 'LOCATION_FILE'),
|
||||
'BULLETIN_BOARD_FILE': config.get(section, 'BULLETIN_BOARD_FILE'),
|
||||
'MAILBOX_FILE': config.get(section, 'MAILBOX_FILE'),
|
||||
'EMERGENCY_SOS_FILE': config.get(section, 'EMERGENCY_SOS_FILE'),
|
||||
'USER_SETTINGS_FILE': config.get(section, 'USER_SETTINGS_FILE'),
|
||||
|
||||
})
|
||||
if not CONFIG['LOGGER']['LOG_FILE']:
|
||||
CONFIG['LOGGER']['LOG_FILE'] = '/dev/null'
|
||||
|
||||
elif section == 'ALIASES':
|
||||
CONFIG['ALIASES'].update({
|
||||
'TRY_DOWNLOAD': config.getboolean(section, 'TRY_DOWNLOAD'),
|
||||
|
@ -183,6 +156,26 @@ def build_config(_config_file):
|
|||
'STALE_TIME': config.getint(section, 'STALE_DAYS') * 86400,
|
||||
})
|
||||
|
||||
elif section == 'WEB_SERVICE':
|
||||
CONFIG['WEB_SERVICE'].update({
|
||||
'THIS_SERVER_NAME': config.get(section, 'THIS_SERVER_NAME'),
|
||||
'URL': config.get(section, 'URL'),
|
||||
'REMOTE_CONFIG_ENABLED': config.getboolean(section, 'REMOTE_CONFIG_ENABLED'),
|
||||
'APPEND_INT': config.getint(section, 'APPEND_INT'),
|
||||
'EXTRA_INT_1': config.getint(section, 'EXTRA_INT_1'),
|
||||
'EXTRA_INT_2': config.getint(section, 'EXTRA_INT_2'),
|
||||
'EXTRA_1': config.get(section, 'EXTRA_1'),
|
||||
'EXTRA_2': config.get(section, 'EXTRA_2'),
|
||||
'SHARED_SECRET': config.get(section, 'SHARED_SECRET'),
|
||||
'SHORTEN_PASSPHRASE': config.getboolean(section, 'SHORTEN_PASSPHRASE'),
|
||||
'SHORTEN_SAMPLE': config.get(section, 'SHORTEN_SAMPLE'),
|
||||
'SHORTEN_LENGTH': config.get(section, 'SHORTEN_LENGTH'),
|
||||
'BURN_FILE': config.get(section, 'BURN_FILE'),
|
||||
'BURN_INT': config.getint(section, 'BURN_INT'),
|
||||
|
||||
|
||||
})
|
||||
|
||||
elif config.getboolean(section, 'ENABLED'):
|
||||
if config.get(section, 'MODE') == 'PEER':
|
||||
CONFIG['SYSTEMS'].update({section: {
|
||||
|
@ -212,11 +205,13 @@ def build_config(_config_file):
|
|||
'SOFTWARE_ID': bytes(config.get(section, 'SOFTWARE_ID').ljust(40)[:40], 'utf-8'),
|
||||
'PACKAGE_ID': bytes(config.get(section, 'PACKAGE_ID').ljust(40)[:40], 'utf-8'),
|
||||
'GROUP_HANGTIME': config.getint(section, 'GROUP_HANGTIME'),
|
||||
'OPTIONS': bytes(config.get(section, 'OPTIONS'), 'utf-8'),
|
||||
'OPTIONS': b''.join([b'Type=HBNet;', bytes(config.get(section, 'OPTIONS'), 'utf-8')]),
|
||||
'USE_ACL': config.getboolean(section, 'USE_ACL'),
|
||||
'SUB_ACL': config.get(section, 'SUB_ACL'),
|
||||
'TG1_ACL': config.get(section, 'TGID_TS1_ACL'),
|
||||
'TG2_ACL': config.get(section, 'TGID_TS2_ACL')
|
||||
'TG2_ACL': config.get(section, 'TGID_TS2_ACL'),
|
||||
'OTHER_OPTIONS': config.get(section, 'OTHER_OPTIONS'),
|
||||
|
||||
}})
|
||||
CONFIG['SYSTEMS'][section].update({'STATS': {
|
||||
'CONNECTION': 'NO', # NO, RTPL_SENT, AUTHENTICATED, CONFIG-SENT, YES
|
||||
|
@ -262,7 +257,9 @@ def build_config(_config_file):
|
|||
'USE_ACL': config.getboolean(section, 'USE_ACL'),
|
||||
'SUB_ACL': config.get(section, 'SUB_ACL'),
|
||||
'TG1_ACL': config.get(section, 'TGID_TS1_ACL'),
|
||||
'TG2_ACL': config.get(section, 'TGID_TS2_ACL')
|
||||
'TG2_ACL': config.get(section, 'TGID_TS2_ACL'),
|
||||
'OTHER_OPTIONS': config.get(section, 'OTHER_OPTIONS'),
|
||||
|
||||
}})
|
||||
CONFIG['SYSTEMS'][section].update({'XLXSTATS': {
|
||||
'CONNECTION': 'NO', # NO, RTPL_SENT, AUTHENTICATED, CONFIG-SENT, YES
|
||||
|
@ -279,6 +276,7 @@ def build_config(_config_file):
|
|||
CONFIG['SYSTEMS'].update({section: {
|
||||
'MODE': config.get(section, 'MODE'),
|
||||
'ENABLED': config.getboolean(section, 'ENABLED'),
|
||||
'USE_USER_MAN': config.getboolean(section, 'USE_USER_MAN'),
|
||||
'REPEAT': config.getboolean(section, 'REPEAT'),
|
||||
'MAX_PEERS': config.getint(section, 'MAX_PEERS'),
|
||||
'IP': gethostbyname(config.get(section, 'IP')),
|
||||
|
@ -289,7 +287,8 @@ def build_config(_config_file):
|
|||
'REG_ACL': config.get(section, 'REG_ACL'),
|
||||
'SUB_ACL': config.get(section, 'SUB_ACL'),
|
||||
'TG1_ACL': config.get(section, 'TGID_TS1_ACL'),
|
||||
'TG2_ACL': config.get(section, 'TGID_TS2_ACL')
|
||||
'TG2_ACL': config.get(section, 'TGID_TS2_ACL'),
|
||||
'OTHER_OPTIONS': config.get(section, 'OTHER_OPTIONS'),
|
||||
}})
|
||||
CONFIG['SYSTEMS'][section].update({'PEERS': {}})
|
||||
|
||||
|
@ -308,9 +307,32 @@ def build_config(_config_file):
|
|||
'USE_ACL': config.getboolean(section, 'USE_ACL'),
|
||||
'SUB_ACL': config.get(section, 'SUB_ACL'),
|
||||
'TG1_ACL': config.get(section, 'TGID_ACL'),
|
||||
'TG2_ACL': 'PERMIT:ALL'
|
||||
'TG2_ACL': 'PERMIT:ALL',
|
||||
'USE_ENCRYPTION': config.getboolean(section, 'USE_ENCRYPTION'),
|
||||
'ENCRYPTION_KEY': bytes(config.get(section, 'ENCRYPTION_KEY'), 'utf-8'),
|
||||
'OTHER_OPTIONS': config.get(section, 'OTHER_OPTIONS'),
|
||||
}})
|
||||
|
||||
elif config.get(section, 'MODE') == 'PROXY':
|
||||
CONFIG['SYSTEMS'].update({section: {
|
||||
'MODE': config.get(section, 'MODE'),
|
||||
'ENABLED': config.getboolean(section, 'ENABLED'),
|
||||
'EXTERNAL_PROXY_SCRIPT': config.getboolean(section, 'EXTERNAL_PROXY_SCRIPT'),
|
||||
'STATIC_APRS_POSITION_ENABLED': config.getboolean(section, 'STATIC_APRS_POSITION_ENABLED'),
|
||||
'USE_USER_MAN': config.getboolean(section, 'USE_USER_MAN'),
|
||||
'REPEAT': config.getboolean(section, 'REPEAT'),
|
||||
'PASSPHRASE': bytes(config.get(section, 'PASSPHRASE'), 'utf-8'),
|
||||
'EXTERNAL_PORT': config.getint(section, 'EXTERNAL_PORT'),
|
||||
'INTERNAL_PORT_START': config.getint(section, 'INTERNAL_PORT_START'),
|
||||
'INTERNAL_PORT_STOP': config.getint(section, 'INTERNAL_PORT_STOP'),
|
||||
'GROUP_HANGTIME': config.getint(section, 'GROUP_HANGTIME'),
|
||||
'USE_ACL': config.getboolean(section, 'USE_ACL'),
|
||||
'REG_ACL': config.get(section, 'REG_ACL'),
|
||||
'SUB_ACL': config.get(section, 'SUB_ACL'),
|
||||
'TG1_ACL': config.get(section, 'TG1_ACL'),
|
||||
'TG2_ACL': config.get(section, 'TG2_ACL'),
|
||||
'OTHER_OPTIONS': config.get(section, 'OTHER_OPTIONS'),
|
||||
}})
|
||||
CONFIG['SYSTEMS'][section].update({'PEERS': {}})
|
||||
|
||||
except configparser.Error as err:
|
||||
sys.exit('Error processing configuration file -- {}'.format(err))
|
||||
|
|
4
const.py
4
const.py
|
@ -69,6 +69,10 @@ RPTP = b'RPTP'
|
|||
RPTA = b'RPTA'
|
||||
RPTO = b'RPTO'
|
||||
|
||||
# Sever Data and Encrypted OBP
|
||||
SVRD = b'SVRD'
|
||||
EOBP = b'EOBP'
|
||||
|
||||
|
||||
# Higheset peer ID permitted by HBP
|
||||
PEER_MAX = 4294967295
|
||||
|
|
|
@ -46,19 +46,6 @@ SUB_ACL: DENY:1
|
|||
TGID_TS1_ACL: PERMIT:ALL
|
||||
TGID_TS2_ACL: PERMIT:ALL
|
||||
|
||||
# APRS - BY IU7IGU
|
||||
# Enabling "APRS" will configure APRS-Beaconing of Master's connection
|
||||
# like repeater and hotspots.
|
||||
# REPORT_INTERVAL in Minute (ALLOW only > 3 Minutes)
|
||||
# CALLSIGN: Callsign that will pubblish data on aprs server
|
||||
# MESSAGE: This message will print on APRS description together RX and TX Frequency
|
||||
|
||||
[APRS]
|
||||
ENABLED: False
|
||||
REPORT_INTERVAL: 15
|
||||
CALLSIGN:HB1LNK-11
|
||||
SERVER:euro.aprs2.net
|
||||
MESSAGE:Connesso ad HBLINK
|
||||
|
||||
# NOT YET WORKING: NETWORK REPORTING CONFIGURATION
|
||||
# Enabling "REPORT" will configure a socket-based reporting
|
||||
|
@ -76,7 +63,7 @@ MESSAGE:Connesso ad HBLINK
|
|||
[REPORTS]
|
||||
REPORT: True
|
||||
REPORT_INTERVAL: 60
|
||||
REPORT_PORT: 4321
|
||||
REPORT_PORT: 4329
|
||||
REPORT_CLIENTS: 127.0.0.1
|
||||
|
||||
|
||||
|
@ -116,28 +103,42 @@ SUBSCRIBER_FILE: subscriber_ids.json
|
|||
TGID_FILE: talkgroup_ids.json
|
||||
PEER_URL: https://www.radioid.net/static/rptrs.json
|
||||
SUBSCRIBER_URL: https://www.radioid.net/static/users.json
|
||||
STALE_DAYS: 1
|
||||
STALE_DAYS: 7
|
||||
|
||||
# GPS/Data Application - by KF7EEL
|
||||
# Configure the settings for the DMR GPS to APRS position application here.
|
||||
#
|
||||
# DATA_DMR_ID - This is the DMR ID that users send DMR GPS data.
|
||||
# CALL_TYPE - group, unit, or both. Group if you want users to send data to a talkgroup,
|
||||
# unit if you want users to send data as a private call, or both if you want both options.
|
||||
# USER_APRS_SSID - Default APRS SSID assigned to user APRS positions.
|
||||
# USER_APRS_COMMENT - Default Comment attached to user APRS positions.
|
||||
# APRS_LOGIN_CALL, PASSCODE, SERVER, and PORT - Login settings for APRS-IS.
|
||||
[GPS_DATA]
|
||||
# USER MANAGER
|
||||
# This is where to configure the details for use with a user managment script
|
||||
[WEB_SERVICE]
|
||||
THIS_SERVER_NAME: DATA_GATEWAY
|
||||
REMOTE_CONFIG_ENABLED: False
|
||||
# URL of the user managment server
|
||||
URL: http://localhost:8080/svr
|
||||
# Integer appended to DMR ID during the generation of a passphrase
|
||||
APPEND_INT: 1
|
||||
EXTRA_INT_1: 5
|
||||
EXTRA_INT_2: 8
|
||||
EXTRA_1: TeSt
|
||||
EXTRA_2: DmR4
|
||||
# Secret used to authenticate with user managment server, before checking if user login is approved
|
||||
SHARED_SECRET: test
|
||||
# Shorten passphrases
|
||||
SHORTEN_PASSPHRASE: True
|
||||
SHORTEN_SAMPLE: 4
|
||||
SHORTEN_LENGTH: 4
|
||||
BURN_FILE: ./burn_ids.txt
|
||||
BURN_INT: 5
|
||||
|
||||
[DATA_CONFIG]
|
||||
DATA_DMR_ID: 9099
|
||||
CALL_TYPE: both
|
||||
USER_APRS_SSID: 15
|
||||
USER_APRS_COMMENT: HBLink3 D-APRS -
|
||||
UNIT_SMS_TS: 2
|
||||
|
||||
# Setting APRS_LOGIN_CALL to N0CALL will cause the gateway to not upload packets to APRS server.
|
||||
USER_APRS_SSID: 5
|
||||
USER_APRS_COMMENT: HBNet APRS Gateway
|
||||
APRS_SERVER: hbl.ink
|
||||
APRS_PORT: 14580
|
||||
APRS_LOGIN_CALL: N0CALL
|
||||
APRS_LOGIN_PASSCODE: 12345
|
||||
APRS_SERVER: rotate.aprs2.net
|
||||
APRS_PORT: 14580
|
||||
APRS_FILTER: r/47/-120/500 t/m
|
||||
|
||||
# The following settings are only applicable if you are using the gps_data_beacon_igate script.
|
||||
# They do not affect the operation gps_data itself.
|
||||
|
@ -145,23 +146,15 @@ APRS_PORT: 14580
|
|||
IGATE_BEACON_TIME = 45
|
||||
IGATE_BEACON_COMMENT = HBLink3 D-APRS Gateway
|
||||
IGATE_BEACON_ICON = /I
|
||||
IGATE_LATITUDE = 0000.00N
|
||||
IGATE_LONGITUDE = 00000.00W
|
||||
IGATE_LATITUDE = 4730. N
|
||||
IGATE_LONGITUDE = 11930. W
|
||||
|
||||
# User settings file, MUST configure using absolute path.
|
||||
USER_SETTINGS_FILE: /path/to/user_settings.txt
|
||||
|
||||
# The APRS filter below is used for the message received script. See http://www.aprs-is.net/javAPRSFilter.aspx for details
|
||||
# about APRS filters.
|
||||
APRS_RECEIVE_LOGIN_CALL: N0CALL-1
|
||||
APRS_FILTER: r/47/-120/500 t/m
|
||||
|
||||
# The email gateway settingns below are OPTIONAL. They are NOT REQUIRED if you don't want
|
||||
# to enable the email gateway. Leave as is to disable.
|
||||
EMAIL_SENDER:
|
||||
EMAIL_PASSWORD:
|
||||
SMTP_SERVER: smtp.gmail.com
|
||||
SMTP_PORT: 465
|
||||
# The following settings are for the static positions only, for hotspots or repeaters connected to MASTER stanzas.
|
||||
# Implementation by IU7IGU
|
||||
# REPORT_INTERVAL in Minute (ALLOW only > 3 Minutes)
|
||||
# MESSAGE: This message will print on APRS description together RX and TX Frequency
|
||||
APRS_STATIC_REPORT_INTERVAL: 15
|
||||
APRS_STATIC_MESSAGE:Connected to HBLink
|
||||
|
||||
# The options below are required for operation of the dashboard and will cause errors in gps_data.py
|
||||
# if configured wrong. Leave them as default unless you know what you are doing.
|
||||
|
@ -170,10 +163,29 @@ LOCATION_FILE: /tmp/gps_data_user_loc.txt
|
|||
BULLETIN_BOARD_FILE: /tmp/gps_data_user_bb.txt
|
||||
MAILBOX_FILE: /tmp/gps_data_user_mailbox.txt
|
||||
EMERGENCY_SOS_FILE: /tmp/gps_data_user_sos.txt
|
||||
SMS_FILE: /tmp/gps_data_user_sms.txt
|
||||
|
||||
# User settings file, MUST configure using absolute path.
|
||||
USER_SETTINGS_FILE: /tmp/user_settings.txt
|
||||
|
||||
# API settings
|
||||
# Authorized Apps file - data used for the dashboard API
|
||||
USE_API: True
|
||||
AUTHORIZED_APPS_FILE: /tmp/authorized_apps.txt
|
||||
AUTHORIZED_TOKENS_FILE: /tmp/hblink_auth_tokens.txt
|
||||
AUTHORIZED_USERS_FILE: /home/eric/Sync/hblink3_sms_dev/authorized_users.txt
|
||||
ACCESS_SYSTEMS_FILE: /home/eric/Sync/hblink3_sms_dev/access_systems.txt
|
||||
MY_SERVER_SHORTCUT: XYZ
|
||||
SERVER_NAME: Test HBLink Network
|
||||
USE_PUBLIC_APPS: True
|
||||
PUBLIC_APPS_LIST: https://raw.githubusercontent.com/kf7eel/hblink_sms_external_apps/main/public_systems.txt
|
||||
RULES_PATH: /home/eric/Sync/hblink3_sms_dev/rules.py
|
||||
|
||||
# The following options are used for the dashboard. The dashboard is optional.
|
||||
# Title of the Dashboard
|
||||
DASHBOARD_TITLE: HBLink3 D-APRS Dashboard
|
||||
DASHBOARD_TITLE: HBNet D-APRS Dashboard
|
||||
# Used for API, RSS feed link, etc
|
||||
DASHBOARD_URL: http://localhost:8092
|
||||
|
||||
# Logo used on dashboard page
|
||||
LOGO: https://raw.githubusercontent.com/kf7eel/hblink3/gps/HBlink.png
|
||||
|
@ -205,8 +217,6 @@ ZOOM_LEVEL: 7
|
|||
# The following are options for map themes and just work, you should use one of these: “OpenStreetMap”, “Stamen” (Terrain, Toner, and Watercolor),
|
||||
MAP_THEME: Stamen Toner
|
||||
|
||||
# RSS feed link, shows in the link section of each RSS item.
|
||||
RSS_LINK: http://localhost:8092
|
||||
|
||||
# OPENBRIDGE INSTANCES - DUPLICATE SECTION FOR MULTIPLE CONNECTIONS
|
||||
# OpenBridge is a protocol originall created by DMR+ for connection between an
|
||||
|
@ -229,17 +239,19 @@ RSS_LINK: http://localhost:8092
|
|||
# Otherwise ACLs work as described in the global stanza
|
||||
[OBP-1]
|
||||
MODE: OPENBRIDGE
|
||||
ENABLED: False
|
||||
ENABLED: True
|
||||
IP:
|
||||
PORT: 62035
|
||||
NETWORK_ID: 3129100
|
||||
PASSPHRASE: password
|
||||
TARGET_IP: 1.2.3.4
|
||||
TARGET_PORT: 62035
|
||||
PORT: 62036
|
||||
NETWORK_ID: 1234
|
||||
PASSPHRASE: passw0rd
|
||||
TARGET_IP: 127.0.0.1
|
||||
TARGET_PORT: 62037
|
||||
BOTH_SLOTS: True
|
||||
USE_ACL: True
|
||||
SUB_ACL: DENY:1
|
||||
TGID_ACL: PERMIT:ALL
|
||||
USE_ENCRYPTION: False
|
||||
ENCRYPTION_KEY:
|
||||
|
||||
# MASTER INSTANCES - DUPLICATE SECTION FOR MULTIPLE MASTERS
|
||||
# HomeBrew Protocol Master instances go here.
|
||||
|
@ -257,30 +269,15 @@ TGID_ACL: PERMIT:ALL
|
|||
[MASTER-1]
|
||||
MODE: MASTER
|
||||
ENABLED: True
|
||||
# The APRS setting below has to do with the beaconing of PEER conections, and not GPS positions
|
||||
# from radios. This setting will not affect gps_data.py
|
||||
APRS: False
|
||||
REPEAT: True
|
||||
MAX_PEERS: 10
|
||||
EXPORT_AMBE: False
|
||||
IP:
|
||||
PORT: 54000
|
||||
PASSPHRASE: s3cr37w0rd
|
||||
GROUP_HANGTIME: 5
|
||||
USE_ACL: True
|
||||
REG_ACL: DENY:1
|
||||
SUB_ACL: DENY:1
|
||||
TGID_TS1_ACL: PERMIT:ALL
|
||||
TGID_TS2_ACL: PERMIT:ALL
|
||||
|
||||
[D-APRS]
|
||||
MODE: MASTER
|
||||
ENABLED: True
|
||||
# Use the user manager? If False, MASTER instance will operate as normal.
|
||||
USE_USER_MAN: False
|
||||
|
||||
REPEAT: True
|
||||
MAX_PEERS: 2
|
||||
MAX_PEERS: 3
|
||||
EXPORT_AMBE: False
|
||||
IP:
|
||||
PORT: 54070
|
||||
PORT: 62033
|
||||
PASSPHRASE: passw0rd
|
||||
GROUP_HANGTIME: 5
|
||||
USE_ACL: True
|
||||
|
@ -333,38 +330,6 @@ SUB_ACL: DENY:1
|
|||
TGID_TS1_ACL: PERMIT:ALL
|
||||
TGID_TS2_ACL: PERMIT:ALL
|
||||
|
||||
[ECHO]
|
||||
MODE: PEER
|
||||
ENABLED: True
|
||||
LOOSE: False
|
||||
EXPORT_AMBE: False
|
||||
IP:
|
||||
PORT: 54073
|
||||
MASTER_IP: localhost
|
||||
MASTER_PORT: 54072
|
||||
passphrase: passw0rd
|
||||
CALLSIGN: ECHO
|
||||
RADIO_ID: 9999
|
||||
RX_FREQ: 000000000
|
||||
TX_FREQ: 000000000
|
||||
TX_POWER: 0
|
||||
COLORCODE: 1
|
||||
SLOTS: 1
|
||||
LATITUDE: 00.0000
|
||||
LONGITUDE: 000.0000
|
||||
HEIGHT: 0
|
||||
LOCATION: This Server
|
||||
DESCRIPTION: Echo Server
|
||||
URL: www.github.com/kf7eel/hblink3
|
||||
SOFTWARE_ID: 20170620
|
||||
PACKAGE_ID: MMDVM_HBlink
|
||||
GROUP_HANGTIME: 5
|
||||
OPTIONS:
|
||||
USE_ACL: True
|
||||
SUB_ACL: DENY:1
|
||||
TGID_TS1_ACL: PERMIT:ALL
|
||||
TGID_TS2_ACL: PERMIT:ALL
|
||||
|
||||
[XLX-1]
|
||||
MODE: XLXPEER
|
||||
ENABLED: False
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,404 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
###############################################################################
|
||||
# Copyright (C) 2016-2018 Cortney T. Buffington, N0MJS <n0mjs@me.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
###############################################################################
|
||||
|
||||
'''
|
||||
This module generates the configuration data structure for hblink.py and
|
||||
assoicated programs that use it. It has been seaparated into a different
|
||||
module so as to keep hblink.py easeier to navigate. This file only needs
|
||||
updated if the items in the main configuraiton file (usually hblink.cfg)
|
||||
change.
|
||||
'''
|
||||
|
||||
import configparser
|
||||
import sys
|
||||
import const
|
||||
|
||||
from socket import gethostbyname
|
||||
|
||||
# Does anybody read this stuff? There's a PEP somewhere that says I should do this.
|
||||
__author__ = 'Cortney T. Buffington, N0MJS'
|
||||
__copyright__ = 'Copyright (c) 2016-2018 Cortney T. Buffington, N0MJS and the K0USY Group'
|
||||
__credits__ = 'Colin Durbridge, G4EML, Steve Zingman, N4IRS; Mike Zingman, N4IRR; Jonathan Naylor, G4KLX; Hans Barthen, DL5DI; Torsten Shultze, DG1HT'
|
||||
__license__ = 'GNU GPLv3'
|
||||
__maintainer__ = 'Cort Buffington, N0MJS'
|
||||
__email__ = 'n0mjs@me.com'
|
||||
|
||||
# Processing of ALS goes here. It's separated from the acl_build function because this
|
||||
# code is hblink config-file format specific, and acl_build is abstracted
|
||||
def process_acls(_config):
|
||||
# Global registration ACL
|
||||
_config['GLOBAL']['REG_ACL'] = acl_build(_config['GLOBAL']['REG_ACL'], const.PEER_MAX)
|
||||
|
||||
# Global subscriber and TGID ACLs
|
||||
for acl in ['SUB_ACL', 'TG1_ACL', 'TG2_ACL']:
|
||||
_config['GLOBAL'][acl] = acl_build(_config['GLOBAL'][acl], const.ID_MAX)
|
||||
|
||||
# System level ACLs
|
||||
for system in _config['SYSTEMS']:
|
||||
# Registration ACLs (which make no sense for peer systems)
|
||||
if _config['SYSTEMS'][system]['MODE'] == 'MASTER':
|
||||
_config['SYSTEMS'][system]['REG_ACL'] = acl_build(_config['SYSTEMS'][system]['REG_ACL'], const.PEER_MAX)
|
||||
|
||||
# Subscriber and TGID ACLs (valid for all system types)
|
||||
for acl in ['SUB_ACL', 'TG1_ACL', 'TG2_ACL']:
|
||||
_config['SYSTEMS'][system][acl] = acl_build(_config['SYSTEMS'][system][acl], const.ID_MAX)
|
||||
|
||||
# Create an access control list that is programatically useable from human readable:
|
||||
# ORIGINAL: 'DENY:1-5,3120101,3120124'
|
||||
# PROCESSED: (False, set([(1, 5), (3120124, 3120124), (3120101, 3120101)]))
|
||||
def acl_build(_acl, _max):
|
||||
if not _acl:
|
||||
return(True, set((const.ID_MIN, _max)))
|
||||
|
||||
acl = [] #set()
|
||||
if type(_acl) == tuple:
|
||||
_acl = ''.join(_acl)
|
||||
sections = _acl.split(':')
|
||||
|
||||
if sections[0] == 'PERMIT':
|
||||
action = True
|
||||
else:
|
||||
action = False
|
||||
|
||||
for entry in sections[1].split(','):
|
||||
if entry == 'ALL':
|
||||
acl.append((const.ID_MIN, _max))
|
||||
break
|
||||
|
||||
elif '-' in entry:
|
||||
start,end = entry.split('-')
|
||||
start,end = int(start), int(end)
|
||||
if (const.ID_MIN <= start <= _max) or (const.ID_MIN <= end <= _max):
|
||||
acl.append((start, end))
|
||||
else:
|
||||
sys.exit('ACL CREATION ERROR, VALUE OUT OF RANGE ({} - {})IN RANGE-BASED ENTRY: {}'.format(const.ID_MIN, _max, entry))
|
||||
else:
|
||||
id = int(entry)
|
||||
if (const.ID_MIN <= id <= _max):
|
||||
acl.append((id, id))
|
||||
else:
|
||||
sys.exit('ACL CREATION ERROR, VALUE OUT OF RANGE ({} - {}) IN SINGLE ID ENTRY: {}'.format(const.ID_MIN, _max, entry))
|
||||
|
||||
return (action, acl)
|
||||
|
||||
def build_config(_config_file):
|
||||
config = configparser.ConfigParser()
|
||||
|
||||
if not config.read(_config_file):
|
||||
sys.exit('Configuration file \''+_config_file+'\' is not a valid configuration file! Exiting...')
|
||||
|
||||
CONFIG = {}
|
||||
CONFIG['GLOBAL'] = {}
|
||||
CONFIG['REPORTS'] = {}
|
||||
CONFIG['LOGGER'] = {}
|
||||
CONFIG['ALIASES'] = {}
|
||||
CONFIG['WEB_SERVICE'] = {}
|
||||
CONFIG['DATA_CONFIG'] = {}
|
||||
CONFIG['SYSTEMS'] = {}
|
||||
|
||||
try:
|
||||
for section in config.sections():
|
||||
if section == 'GLOBAL':
|
||||
CONFIG['GLOBAL'].update({
|
||||
'PATH': config.get(section, 'PATH'),
|
||||
'PING_TIME': config.getint(section, 'PING_TIME'),
|
||||
'MAX_MISSED': config.getint(section, 'MAX_MISSED'),
|
||||
'USE_ACL': config.get(section, 'USE_ACL'),
|
||||
'REG_ACL': config.get(section, 'REG_ACL'),
|
||||
'SUB_ACL': config.get(section, 'SUB_ACL'),
|
||||
'TG1_ACL': config.get(section, 'TGID_TS1_ACL'),
|
||||
'TG2_ACL': config.get(section, 'TGID_TS2_ACL')
|
||||
})
|
||||
|
||||
elif section == 'REPORTS':
|
||||
CONFIG['REPORTS'].update({
|
||||
'REPORT': config.getboolean(section, 'REPORT'),
|
||||
'REPORT_INTERVAL': config.getint(section, 'REPORT_INTERVAL'),
|
||||
'REPORT_PORT': config.getint(section, 'REPORT_PORT'),
|
||||
'REPORT_CLIENTS': config.get(section, 'REPORT_CLIENTS').split(',')
|
||||
})
|
||||
|
||||
elif section == 'LOGGER':
|
||||
CONFIG['LOGGER'].update({
|
||||
'LOG_FILE': config.get(section, 'LOG_FILE'),
|
||||
'LOG_HANDLERS': config.get(section, 'LOG_HANDLERS'),
|
||||
'LOG_LEVEL': config.get(section, 'LOG_LEVEL'),
|
||||
'LOG_NAME': config.get(section, 'LOG_NAME')
|
||||
})
|
||||
if not CONFIG['LOGGER']['LOG_FILE']:
|
||||
CONFIG['LOGGER']['LOG_FILE'] = '/dev/null'
|
||||
|
||||
elif section == 'ALIASES':
|
||||
CONFIG['ALIASES'].update({
|
||||
'TRY_DOWNLOAD': config.getboolean(section, 'TRY_DOWNLOAD'),
|
||||
'PATH': config.get(section, 'PATH'),
|
||||
'PEER_FILE': config.get(section, 'PEER_FILE'),
|
||||
'SUBSCRIBER_FILE': config.get(section, 'SUBSCRIBER_FILE'),
|
||||
'TGID_FILE': config.get(section, 'TGID_FILE'),
|
||||
'PEER_URL': config.get(section, 'PEER_URL'),
|
||||
'SUBSCRIBER_URL': config.get(section, 'SUBSCRIBER_URL'),
|
||||
'STALE_TIME': config.getint(section, 'STALE_DAYS') * 86400,
|
||||
})
|
||||
|
||||
elif section == 'WEB_SERVICE':
|
||||
CONFIG['WEB_SERVICE'].update({
|
||||
'THIS_SERVER_NAME': config.get(section, 'THIS_SERVER_NAME'),
|
||||
'URL': config.get(section, 'URL'),
|
||||
'REMOTE_CONFIG_ENABLED': config.getboolean(section, 'REMOTE_CONFIG_ENABLED'),
|
||||
'SHARED_SECRET': config.get(section, 'SHARED_SECRET'),
|
||||
})
|
||||
|
||||
elif section == 'DATA_CONFIG':
|
||||
CONFIG['DATA_CONFIG'].update({
|
||||
'DATA_DMR_ID': config.get(section, 'DATA_DMR_ID'),
|
||||
'USER_APRS_SSID': config.get(section, 'USER_APRS_SSID'),
|
||||
'CALL_TYPE': config.get(section, 'CALL_TYPE'),
|
||||
## 'UNIT_SMS_TS': config.get(section, 'UNIT_SMS_TS'),
|
||||
'USER_APRS_COMMENT': config.get(section, 'USER_APRS_COMMENT'),
|
||||
'APRS_LOGIN_CALL': config.get(section, 'APRS_LOGIN_CALL'),
|
||||
'APRS_LOGIN_PASSCODE': config.get(section, 'APRS_LOGIN_PASSCODE'),
|
||||
'APRS_SERVER': config.get(section, 'APRS_SERVER'),
|
||||
'APRS_PORT': config.get(section, 'APRS_PORT'),
|
||||
'APRS_FILTER': config.get(section, 'APRS_FILTER'),
|
||||
'IGATE_BEACON_TIME': config.get(section, 'IGATE_BEACON_TIME'),
|
||||
'IGATE_BEACON_ICON': config.get(section, 'IGATE_BEACON_ICON'),
|
||||
'IGATE_BEACON_COMMENT': config.get(section, 'IGATE_BEACON_COMMENT'),
|
||||
'IGATE_LATITUDE': config.get(section, 'IGATE_LATITUDE'),
|
||||
'IGATE_LONGITUDE': config.get(section, 'IGATE_LONGITUDE'),
|
||||
'APRS_STATIC_REPORT_INTERVAL': config.get(section, 'APRS_STATIC_REPORT_INTERVAL'),
|
||||
'APRS_STATIC_MESSAGE': config.get(section, 'APRS_STATIC_MESSAGE'),
|
||||
## 'EMAIL_SENDER': config.get(section, 'EMAIL_SENDER'),
|
||||
## 'EMAIL_PASSWORD': config.get(section, 'EMAIL_PASSWORD'),
|
||||
## 'SMTP_SERVER': config.get(section, 'SMTP_SERVER'),
|
||||
## 'SMTP_PORT': config.get(section, 'SMTP_PORT'),
|
||||
'LOCATION_FILE': config.get(section, 'LOCATION_FILE'),
|
||||
'BULLETIN_BOARD_FILE': config.get(section, 'BULLETIN_BOARD_FILE'),
|
||||
'MAILBOX_FILE': config.get(section, 'MAILBOX_FILE'),
|
||||
'SMS_FILE': config.get(section, 'SMS_FILE'),
|
||||
'EMERGENCY_SOS_FILE': config.get(section, 'EMERGENCY_SOS_FILE'),
|
||||
'USER_SETTINGS_FILE': config.get(section, 'USER_SETTINGS_FILE'),
|
||||
## 'USE_API': config.getboolean(section, 'USE_API'),
|
||||
## 'AUTHORIZED_TOKENS_FILE': config.get(section, 'AUTHORIZED_TOKENS_FILE'),
|
||||
## 'USE_PUBLIC_APPS': config.getboolean(section, 'USE_PUBLIC_APPS'),
|
||||
## 'PUBLIC_APPS_LIST': config.get(section, 'PUBLIC_APPS_LIST'),
|
||||
## 'MY_SERVER_SHORTCUT': config.get(section, 'MY_SERVER_SHORTCUT'),
|
||||
## 'DASHBOARD_URL': config.get(section, 'DASHBOARD_URL'),
|
||||
## 'SERVER_NAME': config.get(section, 'SERVER_NAME'),
|
||||
## 'RULES_PATH': config.get(section, 'RULES_PATH'),
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
elif config.getboolean(section, 'ENABLED'):
|
||||
if config.get(section, 'MODE') == 'PEER':
|
||||
CONFIG['SYSTEMS'].update({section: {
|
||||
'MODE': config.get(section, 'MODE'),
|
||||
'ENABLED': config.getboolean(section, 'ENABLED'),
|
||||
'LOOSE': config.getboolean(section, 'LOOSE'),
|
||||
'SOCK_ADDR': (gethostbyname(config.get(section, 'IP')), config.getint(section, 'PORT')),
|
||||
'IP': gethostbyname(config.get(section, 'IP')),
|
||||
'PORT': config.getint(section, 'PORT'),
|
||||
'MASTER_SOCKADDR': (gethostbyname(config.get(section, 'MASTER_IP')), config.getint(section, 'MASTER_PORT')),
|
||||
'MASTER_IP': gethostbyname(config.get(section, 'MASTER_IP')),
|
||||
'MASTER_PORT': config.getint(section, 'MASTER_PORT'),
|
||||
'PASSPHRASE': bytes(config.get(section, 'PASSPHRASE'), 'utf-8'),
|
||||
'CALLSIGN': bytes(config.get(section, 'CALLSIGN').ljust(8)[:8], 'utf-8'),
|
||||
'RADIO_ID': config.getint(section, 'RADIO_ID').to_bytes(4, 'big'),
|
||||
'RX_FREQ': bytes(config.get(section, 'RX_FREQ').ljust(9)[:9], 'utf-8'),
|
||||
'TX_FREQ': bytes(config.get(section, 'TX_FREQ').ljust(9)[:9], 'utf-8'),
|
||||
'TX_POWER': bytes(config.get(section, 'TX_POWER').rjust(2,'0'), 'utf-8'),
|
||||
'COLORCODE': bytes(config.get(section, 'COLORCODE').rjust(2,'0'), 'utf-8'),
|
||||
'LATITUDE': bytes(config.get(section, 'LATITUDE').ljust(8)[:8], 'utf-8'),
|
||||
'LONGITUDE': bytes(config.get(section, 'LONGITUDE').ljust(9)[:9], 'utf-8'),
|
||||
'HEIGHT': bytes(config.get(section, 'HEIGHT').rjust(3,'0'), 'utf-8'),
|
||||
'LOCATION': bytes(config.get(section, 'LOCATION').ljust(20)[:20], 'utf-8'),
|
||||
'DESCRIPTION': bytes(config.get(section, 'DESCRIPTION').ljust(19)[:19], 'utf-8'),
|
||||
'SLOTS': bytes(config.get(section, 'SLOTS'), 'utf-8'),
|
||||
'URL': bytes(config.get(section, 'URL').ljust(124)[:124], 'utf-8'),
|
||||
'SOFTWARE_ID': bytes(config.get(section, 'SOFTWARE_ID').ljust(40)[:40], 'utf-8'),
|
||||
'PACKAGE_ID': bytes(config.get(section, 'PACKAGE_ID').ljust(40)[:40], 'utf-8'),
|
||||
'GROUP_HANGTIME': config.getint(section, 'GROUP_HANGTIME'),
|
||||
'OPTIONS': b''.join([b'Type=HBlink;', bytes(config.get(section, 'OPTIONS'), 'utf-8')]),
|
||||
'USE_ACL': config.getboolean(section, 'USE_ACL'),
|
||||
'SUB_ACL': config.get(section, 'SUB_ACL'),
|
||||
'TG1_ACL': config.get(section, 'TGID_TS1_ACL'),
|
||||
'TG2_ACL': config.get(section, 'TGID_TS2_ACL'),
|
||||
'OTHER_OPTIONS': config.get(section, 'OTHER_OPTIONS'),
|
||||
}})
|
||||
CONFIG['SYSTEMS'][section].update({'STATS': {
|
||||
'CONNECTION': 'NO', # NO, RTPL_SENT, AUTHENTICATED, CONFIG-SENT, YES
|
||||
'CONNECTED': None,
|
||||
'PINGS_SENT': 0,
|
||||
'PINGS_ACKD': 0,
|
||||
'NUM_OUTSTANDING': 0,
|
||||
'PING_OUTSTANDING': False,
|
||||
'LAST_PING_TX_TIME': 0,
|
||||
'LAST_PING_ACK_TIME': 0,
|
||||
}})
|
||||
|
||||
if config.get(section, 'MODE') == 'XLXPEER':
|
||||
CONFIG['SYSTEMS'].update({section: {
|
||||
'MODE': config.get(section, 'MODE'),
|
||||
'ENABLED': config.getboolean(section, 'ENABLED'),
|
||||
'LOOSE': config.getboolean(section, 'LOOSE'),
|
||||
'SOCK_ADDR': (gethostbyname(config.get(section, 'IP')), config.getint(section, 'PORT')),
|
||||
'IP': gethostbyname(config.get(section, 'IP')),
|
||||
'PORT': config.getint(section, 'PORT'),
|
||||
'MASTER_SOCKADDR': (gethostbyname(config.get(section, 'MASTER_IP')), config.getint(section, 'MASTER_PORT')),
|
||||
'MASTER_IP': gethostbyname(config.get(section, 'MASTER_IP')),
|
||||
'MASTER_PORT': config.getint(section, 'MASTER_PORT'),
|
||||
'PASSPHRASE': bytes(config.get(section, 'PASSPHRASE'), 'utf-8'),
|
||||
'CALLSIGN': bytes(config.get(section, 'CALLSIGN').ljust(8)[:8], 'utf-8'),
|
||||
'RADIO_ID': config.getint(section, 'RADIO_ID').to_bytes(4, 'big'),
|
||||
'RX_FREQ': bytes(config.get(section, 'RX_FREQ').ljust(9)[:9], 'utf-8'),
|
||||
'TX_FREQ': bytes(config.get(section, 'TX_FREQ').ljust(9)[:9], 'utf-8'),
|
||||
'TX_POWER': bytes(config.get(section, 'TX_POWER').rjust(2,'0'), 'utf-8'),
|
||||
'COLORCODE': bytes(config.get(section, 'COLORCODE').rjust(2,'0'), 'utf-8'),
|
||||
'LATITUDE': bytes(config.get(section, 'LATITUDE').ljust(8)[:8], 'utf-8'),
|
||||
'LONGITUDE': bytes(config.get(section, 'LONGITUDE').ljust(9)[:9], 'utf-8'),
|
||||
'HEIGHT': bytes(config.get(section, 'HEIGHT').rjust(3,'0'), 'utf-8'),
|
||||
'LOCATION': bytes(config.get(section, 'LOCATION').ljust(20)[:20], 'utf-8'),
|
||||
'DESCRIPTION': bytes(config.get(section, 'DESCRIPTION').ljust(19)[:19], 'utf-8'),
|
||||
'SLOTS': bytes(config.get(section, 'SLOTS'), 'utf-8'),
|
||||
'URL': bytes(config.get(section, 'URL').ljust(124)[:124], 'utf-8'),
|
||||
'SOFTWARE_ID': bytes(config.get(section, 'SOFTWARE_ID').ljust(40)[:40], 'utf-8'),
|
||||
'PACKAGE_ID': bytes(config.get(section, 'PACKAGE_ID').ljust(40)[:40], 'utf-8'),
|
||||
'GROUP_HANGTIME': config.getint(section, 'GROUP_HANGTIME'),
|
||||
'XLXMODULE': config.getint(section, 'XLXMODULE'),
|
||||
'OPTIONS': '',
|
||||
'USE_ACL': config.getboolean(section, 'USE_ACL'),
|
||||
'SUB_ACL': config.get(section, 'SUB_ACL'),
|
||||
'TG1_ACL': config.get(section, 'TGID_TS1_ACL'),
|
||||
'TG2_ACL': config.get(section, 'TGID_TS2_ACL'),
|
||||
'OTHER_OPTIONS': config.get(section, 'OTHER_OPTIONS'),
|
||||
}})
|
||||
CONFIG['SYSTEMS'][section].update({'XLXSTATS': {
|
||||
'CONNECTION': 'NO', # NO, RTPL_SENT, AUTHENTICATED, CONFIG-SENT, YES
|
||||
'CONNECTED': None,
|
||||
'PINGS_SENT': 0,
|
||||
'PINGS_ACKD': 0,
|
||||
'NUM_OUTSTANDING': 0,
|
||||
'PING_OUTSTANDING': False,
|
||||
'LAST_PING_TX_TIME': 0,
|
||||
'LAST_PING_ACK_TIME': 0,
|
||||
}})
|
||||
|
||||
elif config.get(section, 'MODE') == 'MASTER':
|
||||
CONFIG['SYSTEMS'].update({section: {
|
||||
'MODE': config.get(section, 'MODE'),
|
||||
'ENABLED': config.getboolean(section, 'ENABLED'),
|
||||
'USE_USER_MAN': config.getboolean(section, 'USE_USER_MAN'),
|
||||
'REPEAT': config.getboolean(section, 'REPEAT'),
|
||||
'MAX_PEERS': config.getint(section, 'MAX_PEERS'),
|
||||
'IP': gethostbyname(config.get(section, 'IP')),
|
||||
'PORT': config.getint(section, 'PORT'),
|
||||
'PASSPHRASE': bytes(config.get(section, 'PASSPHRASE'), 'utf-8'),
|
||||
'GROUP_HANGTIME': config.getint(section, 'GROUP_HANGTIME'),
|
||||
'USE_ACL': config.getboolean(section, 'USE_ACL'),
|
||||
'REG_ACL': config.get(section, 'REG_ACL'),
|
||||
'SUB_ACL': config.get(section, 'SUB_ACL'),
|
||||
'TG1_ACL': config.get(section, 'TGID_TS1_ACL'),
|
||||
'TG2_ACL': config.get(section, 'TGID_TS2_ACL'),
|
||||
'OTHER_OPTIONS': config.get(section, 'OTHER_OPTIONS'),
|
||||
}})
|
||||
CONFIG['SYSTEMS'][section].update({'PEERS': {}})
|
||||
|
||||
elif config.get(section, 'MODE') == 'OPENBRIDGE':
|
||||
CONFIG['SYSTEMS'].update({section: {
|
||||
'MODE': config.get(section, 'MODE'),
|
||||
'ENABLED': config.getboolean(section, 'ENABLED'),
|
||||
'NETWORK_ID': config.getint(section, 'NETWORK_ID').to_bytes(4, 'big'),
|
||||
'IP': gethostbyname(config.get(section, 'IP')),
|
||||
'PORT': config.getint(section, 'PORT'),
|
||||
'PASSPHRASE': bytes(config.get(section, 'PASSPHRASE').ljust(20,'\x00')[:20], 'utf-8'),
|
||||
'TARGET_SOCK': (gethostbyname(config.get(section, 'TARGET_IP')), config.getint(section, 'TARGET_PORT')),
|
||||
'TARGET_IP': gethostbyname(config.get(section, 'TARGET_IP')),
|
||||
'TARGET_PORT': config.getint(section, 'TARGET_PORT'),
|
||||
'BOTH_SLOTS': config.getboolean(section, 'BOTH_SLOTS'),
|
||||
'USE_ACL': config.getboolean(section, 'USE_ACL'),
|
||||
'SUB_ACL': config.get(section, 'SUB_ACL'),
|
||||
'TG1_ACL': config.get(section, 'TGID_ACL'),
|
||||
'TG2_ACL': 'PERMIT:ALL',
|
||||
'USE_ENCRYPTION': config.getboolean(section, 'USE_ENCRYPTION'),
|
||||
'ENCRYPTION_KEY': bytes(config.get(section, 'ENCRYPTION_KEY'), 'utf-8'),
|
||||
'OTHER_OPTIONS': config.get(section, 'OTHER_OPTIONS'),
|
||||
}})
|
||||
elif config.get(section, 'MODE') == 'PROXY':
|
||||
CONFIG['SYSTEMS'].update({section: {
|
||||
'MODE': config.get(section, 'MODE'),
|
||||
'ENABLED': config.getboolean(section, 'ENABLED'),
|
||||
'EXTERNAL_PROXY_SCRIPT': config.getboolean(section, 'EXTERNAL_PROXY_SCRIPT'),
|
||||
'STATIC_APRS_POSITION_ENABLED': config.getboolean(section, 'STATIC_APRS_POSITION_ENABLED'),
|
||||
'REPEAT': config.getboolean(section, 'REPEAT'),
|
||||
'PASSPHRASE': bytes(config.get(section, 'PASSPHRASE'), 'utf-8'),
|
||||
'EXTERNAL_PORT': config.getint(section, 'EXTERNAL_PORT'),
|
||||
'INTERNAL_PORT_START': config.getint(section, 'INTERNAL_PORT_START'),
|
||||
'INTERNAL_PORT_STOP': config.getint(section, 'INTERNAL_PORT_STOP'),
|
||||
'GROUP_HANGTIME': config.getint(section, 'GROUP_HANGTIME'),
|
||||
'USE_ACL': config.getboolean(section, 'USE_ACL'),
|
||||
'REG_ACL': config.get(section, 'REG_ACL'),
|
||||
'SUB_ACL': config.get(section, 'SUB_ACL'),
|
||||
'TG1_ACL': config.get(section, 'TG1_ACL'),
|
||||
'TG2_ACL': config.get(section, 'TG2_ACL'),
|
||||
'OTHER_OPTIONS': config.get(section, 'OTHER_OPTIONS'),
|
||||
}})
|
||||
CONFIG['SYSTEMS'][section].update({'PEERS': {}})
|
||||
|
||||
except configparser.Error as err:
|
||||
sys.exit('Error processing configuration file -- {}'.format(err))
|
||||
|
||||
process_acls(CONFIG)
|
||||
|
||||
return CONFIG
|
||||
|
||||
# Used to run this file direclty and print the config,
|
||||
# which might be useful for debugging
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
import os
|
||||
import argparse
|
||||
from pprint import pprint
|
||||
from dmr_utils3.utils import int_id
|
||||
|
||||
# Change the current directory to the location of the application
|
||||
os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])))
|
||||
|
||||
# CLI argument parser - handles picking up the config file from the command line, and sending a "help" message
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-c', '--config', action='store', dest='CONFIG_FILE', help='/full/path/to/config.file (usually hblink.cfg)')
|
||||
cli_args = parser.parse_args()
|
||||
|
||||
|
||||
# Ensure we have a path for the config file, if one wasn't specified, then use the execution directory
|
||||
if not cli_args.CONFIG_FILE:
|
||||
cli_args.CONFIG_FILE = os.path.dirname(os.path.abspath(__file__))+'/hblink.cfg'
|
||||
|
||||
CONFIG = build_config(cli_args.CONFIG_FILE)
|
||||
pprint(CONFIG)
|
||||
|
||||
def acl_check(_id, _acl):
|
||||
id = int_id(_id)
|
||||
for entry in _acl[1]:
|
||||
if entry[0] <= id <= entry[1]:
|
||||
return _acl[0]
|
||||
return not _acl[0]
|
||||
|
||||
print(acl_check(b'\x00\x01\x37', CONFIG['GLOBAL']['TG1_ACL']))
|
|
@ -1,307 +0,0 @@
|
|||
# PROGRAM-WIDE PARAMETERS GO HERE
|
||||
# PATH - working path for files, leave it alone unless you NEED to change it
|
||||
# PING_TIME - the interval that peers will ping the master, and re-try registraion
|
||||
# - how often the Master maintenance loop runs
|
||||
# MAX_MISSED - how many pings are missed before we give up and re-register
|
||||
# - number of times the master maintenance loop runs before de-registering a peer
|
||||
#
|
||||
# ACLs:
|
||||
#
|
||||
# Access Control Lists are a very powerful tool for administering your system.
|
||||
# But they consume packet processing time. Disable them if you are not using them.
|
||||
# But be aware that, as of now, the configuration stanzas still need the ACL
|
||||
# sections configured even if you're not using them.
|
||||
#
|
||||
# REGISTRATION ACLS ARE ALWAYS USED, ONLY SUBSCRIBER AND TGID MAY BE DISABLED!!!
|
||||
#
|
||||
# The 'action' May be PERMIT|DENY
|
||||
# Each entry may be a single radio id, or a hypenated range (e.g. 1-2999)
|
||||
# Format:
|
||||
# ACL = 'action:id|start-end|,id|start-end,....'
|
||||
# --for example--
|
||||
# SUB_ACL: DENY:1,1000-2000,4500-60000,17
|
||||
#
|
||||
# ACL Types:
|
||||
# REG_ACL: peer radio IDs for registration (only used on HBP master systems)
|
||||
# SUB_ACL: subscriber IDs for end-users
|
||||
# TGID_TS1_ACL: destination talkgroup IDs on Timeslot 1
|
||||
# TGID_TS2_ACL: destination talkgroup IDs on Timeslot 2
|
||||
#
|
||||
# ACLs may be repeated for individual systems if needed for granularity
|
||||
# Global ACLs will be processed BEFORE the system level ACLs
|
||||
# Packets will be matched against all ACLs, GLOBAL first. If a packet 'passes'
|
||||
# All elements, processing continues. Packets are discarded at the first
|
||||
# negative match, or 'reject' from an ACL element.
|
||||
#
|
||||
# If you do not wish to use ACLs, set them to 'PERMIT:ALL'
|
||||
# TGID_TS1_ACL in the global stanza is used for OPENBRIDGE systems, since all
|
||||
# traffic is passed as TS 1 between OpenBridges
|
||||
[GLOBAL]
|
||||
PATH: ./
|
||||
PING_TIME: 5
|
||||
MAX_MISSED: 3
|
||||
USE_ACL: True
|
||||
REG_ACL: PERMIT:ALL
|
||||
SUB_ACL: DENY:1
|
||||
TGID_TS1_ACL: PERMIT:ALL
|
||||
TGID_TS2_ACL: PERMIT:ALL
|
||||
|
||||
|
||||
# NOT YET WORKING: NETWORK REPORTING CONFIGURATION
|
||||
# Enabling "REPORT" will configure a socket-based reporting
|
||||
# system that will send the configuration and other items
|
||||
# to a another process (local or remote) that may process
|
||||
# the information for some useful purpose, like a web dashboard.
|
||||
#
|
||||
# REPORT - True to enable, False to disable
|
||||
# REPORT_INTERVAL - Seconds between reports
|
||||
# REPORT_PORT - TCP port to listen on if "REPORT_NETWORKS" = NETWORK
|
||||
# REPORT_CLIENTS - comma separated list of IPs you will allow clients
|
||||
# to connect on. Entering a * will allow all.
|
||||
#
|
||||
# ****FOR NOW MUST BE TRUE - USE THE LOOPBACK IF YOU DON'T USE THIS!!!****
|
||||
[REPORTS]
|
||||
REPORT: True
|
||||
REPORT_INTERVAL: 60
|
||||
REPORT_PORT: 4323
|
||||
REPORT_CLIENTS: 127.0.0.1
|
||||
|
||||
|
||||
# SYSTEM LOGGER CONFIGURAITON
|
||||
# This allows the logger to be configured without chaning the individual
|
||||
# python logger stuff. LOG_FILE should be a complete path/filename for *your*
|
||||
# system -- use /dev/null for non-file handlers.
|
||||
# LOG_HANDLERS may be any of the following, please, no spaces in the
|
||||
# list if you use several:
|
||||
# null
|
||||
# console
|
||||
# console-timed
|
||||
# file
|
||||
# file-timed
|
||||
# syslog
|
||||
# LOG_LEVEL may be any of the standard syslog logging levels, though
|
||||
# as of now, DEBUG, INFO, WARNING and CRITICAL are the only ones
|
||||
# used.
|
||||
#
|
||||
[LOGGER]
|
||||
LOG_FILE: /tmp/gps_data.log
|
||||
LOG_HANDLERS: console-timed
|
||||
LOG_LEVEL: DEBUG
|
||||
LOG_NAME: HBlink3 GPS/Data
|
||||
|
||||
# DOWNLOAD AND IMPORT SUBSCRIBER, PEER and TGID ALIASES
|
||||
# Ok, not the TGID, there's no master list I know of to download
|
||||
# This is intended as a facility for other applcations built on top of
|
||||
# HBlink to use, and will NOT be used in HBlink directly.
|
||||
# STALE_DAYS is the number of days since the last download before we
|
||||
# download again. Don't be an ass and change this to less than a few days.
|
||||
[ALIASES]
|
||||
TRY_DOWNLOAD: True
|
||||
PATH: ./
|
||||
PEER_FILE: peer_ids.json
|
||||
SUBSCRIBER_FILE: subscriber_ids.json
|
||||
TGID_FILE: talkgroup_ids.json
|
||||
PEER_URL: https://www.radioid.net/static/rptrs.json
|
||||
SUBSCRIBER_URL: https://www.radioid.net/static/users.json
|
||||
STALE_DAYS: 1
|
||||
|
||||
#####################################################################
|
||||
# GPS/Data Application - by KF7EEL
|
||||
# Configure the settings for the DMR GPS to APRS position application here.
|
||||
#
|
||||
# DATA_DMR_ID - This is the DMR ID that users send DMR GPS data.
|
||||
# CALL_TYPE - group, unit, or both. Group if you want users to send data to a talkgroup,
|
||||
# unit if you want users to send data as a private call, or both if you want both options.
|
||||
# USER_APRS_SSID - Default APRS SSID assigned to user APRS positions.
|
||||
# USER_APRS_COMMENT - Default Comment attached to user APRS positions.
|
||||
# APRS_LOGIN_CALL, PASSCODE, SERVER, and PORT - Login settings for APRS-IS.
|
||||
[GPS_DATA]
|
||||
DATA_DMR_ID: 9099
|
||||
CALL_TYPE: unit
|
||||
USER_APRS_SSID: 15
|
||||
USER_APRS_COMMENT: HBLink3 D-APRS -
|
||||
|
||||
# Setting APRS_LOGIN_CALL to N0CALL will cause the gateway to not upload packets to APRS server.
|
||||
APRS_LOGIN_CALL: N0CALL
|
||||
APRS_LOGIN_PASSCODE: 12345
|
||||
APRS_SERVER: rotate.aprs2.net
|
||||
APRS_PORT: 14580
|
||||
|
||||
# The APRS filter below is used for the message received script. See http://www.aprs-is.net/javAPRSFilter.aspx for details
|
||||
# about APRS filters.
|
||||
APRS_RECEIVE_LOGIN_CALL: N0CALL-1
|
||||
APRS_FILTER: r/47/-120/500 t/m
|
||||
|
||||
# The following settings are only applicable if you are using the gps_data_beacon_igate script.
|
||||
# They do not affect the operation gps_data itself.
|
||||
# Time in minutes.
|
||||
IGATE_BEACON_TIME = 45
|
||||
IGATE_BEACON_COMMENT = HBLink3 D-APRS Gateway
|
||||
IGATE_BEACON_ICON = /I
|
||||
IGATE_LATITUDE = 0000.00N
|
||||
IGATE_LONGITUDE = 00000.00W
|
||||
|
||||
# User settings file, MUST configure using absolute path.
|
||||
USER_SETTINGS_FILE: /path/to/user_settings.txt
|
||||
|
||||
# The email gateway settingns below are OPTIONAL. They are NOT REQUIRED if you don't want
|
||||
http://www.aprs-is.net/javAPRSFilter.aspx# to enable the email gateway. Leave as is to disable.
|
||||
EMAIL_SENDER: test@example.org
|
||||
EMAIL_PASSWORD: letmein
|
||||
SMTP_SERVER: smtp.gmail.com
|
||||
SMTP_PORT: 465
|
||||
|
||||
# The options below are required for operation of the dashboard and will cause errors in gps_data.py
|
||||
# if configured wrong. Leave them as default unless you know what you are doing.
|
||||
# If you do change, you must use absolute paths.
|
||||
LOCATION_FILE: /tmp/gps_data_user_loc.txt
|
||||
BULLETIN_BOARD_FILE: /tmp/gps_data_user_bb.txt
|
||||
MAILBOX_FILE: /tmp/gps_data_user_mailbox.txt
|
||||
EMERGENCY_SOS_FILE: /tmp/gps_data_user_sos.txt
|
||||
|
||||
# The following options are used for the dashboard. The dashboard is optional.
|
||||
# Title of the Dashboard
|
||||
DASHBOARD_TITLE: HBLink3 D-APRS Dashboard
|
||||
|
||||
# Logo used on dashboard page
|
||||
LOGO: https://raw.githubusercontent.com/kf7eel/hblink3/gps/HBlink.png
|
||||
|
||||
# Port to run server
|
||||
DASH_PORT: 8092
|
||||
|
||||
# IP to run server on
|
||||
DASH_HOST: 127.0.0.1
|
||||
|
||||
#Description of dashboard to show on main page
|
||||
DESCRIPTION: Welcome to the dashboard.
|
||||
|
||||
# Gateway contact info displayed on about page.
|
||||
CONTACT_NAME: your name
|
||||
CONTACT_CALL: N0CALL
|
||||
CONTACT_EMAIL: email@example.org
|
||||
CONTACT_WEBSITE: https://hbl.ink
|
||||
|
||||
# Time format for display
|
||||
TIME_FORMAT: %%H:%%M:%%S - %%m/%%d/%%y
|
||||
|
||||
# Center dashboard map over these coordinates
|
||||
MAP_CENTER_LAT: 47.00
|
||||
MAP_CENTER_LON: -120.00
|
||||
ZOOM_LEVEL: 7
|
||||
|
||||
# List and preview of some map themes at http://leaflet-extras.github.io/leaflet-providers/preview/
|
||||
# The following are options for map themes and just work, you should use one of these: “OpenStreetMap”, “Stamen” (Terrain, Toner, and Watercolor),
|
||||
MAP_THEME: Stamen Toner
|
||||
|
||||
# RSS feed link, shows in the link section of each RSS item.
|
||||
RSS_LINK: http://localhost:8092
|
||||
|
||||
#####################################################################
|
||||
# OPENBRIDGE INSTANCES - DUPLICATE SECTION FOR MULTIPLE CONNECTIONS
|
||||
# OpenBridge is a protocol originall created by DMR+ for connection between an
|
||||
# IPSC2 server and Brandmeister. It has been implemented here at the suggestion
|
||||
# of the Brandmeister team as a way to legitimately connect HBlink to the
|
||||
# Brandemiester network.
|
||||
# It is recommended to name the system the ID of the Brandmeister server that
|
||||
# it connects to, but is not necessary. TARGET_IP and TARGET_PORT are of the
|
||||
# Brandmeister or IPSC2 server you are connecting to. PASSPHRASE is the password
|
||||
# that must be agreed upon between you and the operator of the server you are
|
||||
# connecting to. NETWORK_ID is a number in the format of a DMR Radio ID that
|
||||
# will be sent to the other server to identify this connection.
|
||||
# other parameters follow the other system types.
|
||||
#
|
||||
# ACLs:
|
||||
# OpenBridge does not 'register', so registration ACL is meaningless.
|
||||
# Proper OpenBridge passes all traffic on TS1.
|
||||
# HBlink can extend OPB to use both slots for unit calls only.
|
||||
# Setting "BOTH_SLOTS" True ONLY affects unit traffic!
|
||||
# Otherwise ACLs work as described in the global stanza
|
||||
|
||||
##[OBP-1]
|
||||
##MODE: OPENBRIDGE
|
||||
##ENABLED: True
|
||||
##IP:
|
||||
##PORT: 62035
|
||||
##NETWORK_ID: 3129100
|
||||
##PASSPHRASE: password
|
||||
##TARGET_IP: 1.2.3.4
|
||||
##TARGET_PORT: 62035
|
||||
##BOTH_SLOTS: True
|
||||
##USE_ACL: True
|
||||
##SUB_ACL: DENY:1
|
||||
##TGID_ACL: PERMIT:ALL
|
||||
|
||||
# MASTER INSTANCES - DUPLICATE SECTION FOR MULTIPLE MASTERS
|
||||
# HomeBrew Protocol Master instances go here.
|
||||
# IP may be left blank if there's one interface on your system.
|
||||
# Port should be the port you want this master to listen on. It must be unique
|
||||
# and unused by anything else.
|
||||
# Repeat - if True, the master repeats traffic to peers, False, it does nothing.
|
||||
#
|
||||
# MAX_PEERS -- maximun number of peers that may be connect to this master
|
||||
# at any given time. This is very handy if you're allowing hotspots to
|
||||
# connect, or using a limited computer like a Raspberry Pi.
|
||||
#
|
||||
# ACLs:
|
||||
# See comments in the GLOBAL stanza
|
||||
[MASTER-1]
|
||||
MODE: MASTER
|
||||
ENABLED: False
|
||||
REPEAT: True
|
||||
MAX_PEERS: 10
|
||||
EXPORT_AMBE: False
|
||||
IP:
|
||||
PORT: 54000
|
||||
PASSPHRASE: password
|
||||
GROUP_HANGTIME: 5
|
||||
USE_ACL: True
|
||||
REG_ACL: DENY:1
|
||||
SUB_ACL: DENY:1
|
||||
TGID_TS1_ACL: PERMIT:ALL
|
||||
TGID_TS2_ACL: PERMIT:ALL
|
||||
|
||||
# PEER INSTANCES - DUPLICATE SECTION FOR MULTIPLE PEERS
|
||||
# There are a LOT of errors in the HB Protocol specifications on this one!
|
||||
# MOST of these items are just strings and will be properly dealt with by the program
|
||||
# The TX & RX Frequencies are 9-digit numbers, and are the frequency in Hz.
|
||||
# Latitude is an 8-digit unsigned floating point number.
|
||||
# Longitude is a 9-digit signed floating point number.
|
||||
# Height is in meters
|
||||
# Setting Loose to True relaxes the validation on packets received from the master.
|
||||
# This will allow HBlink to connect to a non-compliant system such as XLXD, DMR+ etc.
|
||||
#
|
||||
# ACLs:
|
||||
# See comments in the GLOBAL stanza
|
||||
|
||||
[D-APRS]
|
||||
MODE: PEER
|
||||
ENABLED: True
|
||||
LOOSE: True
|
||||
EXPORT_AMBE: False
|
||||
IP:
|
||||
PORT: 54071
|
||||
MASTER_IP: localhost
|
||||
MASTER_PORT: 54070
|
||||
PASSPHRASE: passw0rd
|
||||
CALLSIGN: D-APRS
|
||||
RADIO_ID: 9099
|
||||
RX_FREQ: 000000000
|
||||
TX_FREQ: 000000000
|
||||
TX_POWER: 0
|
||||
COLORCODE: 1
|
||||
SLOTS: 1
|
||||
LATITUDE: 00.0000
|
||||
LONGITUDE: 000.0000
|
||||
HEIGHT: 0
|
||||
LOCATION: This Server
|
||||
DESCRIPTION: GPS to APRS
|
||||
URL: www.github.com/kf7eel/hblink3
|
||||
SOFTWARE_ID: 20170620
|
||||
PACKAGE_ID: MMDVM_HBlink
|
||||
GROUP_HANGTIME: 5
|
||||
OPTIONS:
|
||||
USE_ACL: True
|
||||
SUB_ACL: DENY:1
|
||||
TGID_TS1_ACL: PERMIT:ALL
|
||||
TGID_TS2_ACL: PERMIT:ALL
|
||||
|
820
gps_data.py
820
gps_data.py
|
@ -1,820 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
#
|
||||
###############################################################################
|
||||
# HBLink - Copyright (C) 2020 Cortney T. Buffington, N0MJS <n0mjs@me.com>
|
||||
# GPS/Data - Copyright (C) 2020 Eric Craw, KF7EEL <kf7eel@qsl.net>
|
||||
# Annotated modifications Copyright (C) 2021 Xavier FRS2013
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
###############################################################################
|
||||
|
||||
'''
|
||||
This is a GPS and Data application. It decodes and reassambles DMR GPS packets and
|
||||
uploads them th APRS-IS.
|
||||
'''
|
||||
|
||||
# Python modules we need
|
||||
import sys
|
||||
from bitarray import bitarray
|
||||
from time import time
|
||||
from importlib import import_module
|
||||
from types import ModuleType
|
||||
|
||||
# Twisted is pretty important, so I keep it separate
|
||||
from twisted.internet.protocol import Factory, Protocol
|
||||
from twisted.protocols.basic import NetstringReceiver
|
||||
from twisted.internet import reactor, task
|
||||
|
||||
# Things we import from the main hblink module
|
||||
from hblink import HBSYSTEM, OPENBRIDGE, systems, hblink_handler, reportFactory, REPORT_OPCODES, config_reports, mk_aliases, acl_check
|
||||
from dmr_utils3.utils import bytes_3, int_id, get_alias
|
||||
from dmr_utils3 import decode, bptc, const
|
||||
import config
|
||||
import log
|
||||
import const
|
||||
|
||||
# The module needs logging logging, but handlers, etc. are controlled by the parent
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
import traceback
|
||||
|
||||
# Other modules we need for data and GPS
|
||||
from bitarray import bitarray
|
||||
from binascii import b2a_hex as ahex
|
||||
import re
|
||||
##from binascii import a2b_hex as bhex
|
||||
import aprslib
|
||||
import datetime
|
||||
from bitarray.util import ba2int as ba2num
|
||||
from bitarray.util import ba2hex as ba2hx
|
||||
import codecs
|
||||
import time
|
||||
#Needed for working with NMEA
|
||||
import pynmea2
|
||||
|
||||
# Modules for executing commands/scripts
|
||||
import os
|
||||
from gps_functions import cmd_list
|
||||
|
||||
# Module for maidenhead grids
|
||||
try:
|
||||
import maidenhead as mh
|
||||
except Exception as error_exception:
|
||||
logger.info('Error importing maidenhead module, make sure it is installed.')
|
||||
# Module for sending email
|
||||
try:
|
||||
import smtplib
|
||||
except Exception as error_exception:
|
||||
logger.info('Error importing smtplib module, make sure it is installed.')
|
||||
|
||||
#Modules for APRS settings
|
||||
import ast
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
# Does anybody read this stuff? There's a PEP somewhere that says I should do this.
|
||||
__author__ = 'Cortney T. Buffington, N0MJS; Eric Craw, KF7EEL'
|
||||
__copyright__ = 'Copyright (c) 2020 Cortney T. Buffington'
|
||||
__credits__ = 'Colin Durbridge, G4EML, Steve Zingman, N4IRS; Mike Zingman, N4IRR; Jonathan Naylor, G4KLX; Hans Barthen, DL5DI; Torsten Shultze, DG1HT'
|
||||
__license__ = 'GNU GPLv3'
|
||||
__maintainer__ = 'Eric Craw, KF7EEL'
|
||||
__email__ = 'kf7eel@qsl.net'
|
||||
__status__ = 'pre-alpha'
|
||||
|
||||
# Known to work with: AT-D878
|
||||
|
||||
# Must have the following at line 1054 in bridge.py to forward group vcsbk, also there is a typo there:
|
||||
# self.group_received(_peer_id, _rf_src, _dst_id, _seq, _slot, _frame_type, _dtype_vseq, _stream_id, _data)
|
||||
|
||||
##################################################################################################
|
||||
|
||||
# Headers for GPS by model of radio:
|
||||
# AT-D878 - Compressed UDP
|
||||
# MD-380 - Unified Data Transport
|
||||
hdr_type = ''
|
||||
btf = -1
|
||||
ssid = ''
|
||||
|
||||
# From dmr_utils3, modified to decode entire packet. Works for 1/2 rate coded data.
|
||||
def decode_full(_data):
|
||||
binlc = bitarray(endian='big')
|
||||
binlc.extend([_data[136],_data[121],_data[106],_data[91], _data[76], _data[61], _data[46], _data[31]])
|
||||
binlc.extend([_data[152],_data[137],_data[122],_data[107],_data[92], _data[77], _data[62], _data[47], _data[32], _data[17], _data[2] ])
|
||||
binlc.extend([_data[123],_data[108],_data[93], _data[78], _data[63], _data[48], _data[33], _data[18], _data[3], _data[184],_data[169]])
|
||||
binlc.extend([_data[94], _data[79], _data[64], _data[49], _data[34], _data[19], _data[4], _data[185],_data[170],_data[155],_data[140]])
|
||||
binlc.extend([_data[65], _data[50], _data[35], _data[20], _data[5], _data[186],_data[171],_data[156],_data[141],_data[126],_data[111]])
|
||||
binlc.extend([_data[36], _data[21], _data[6], _data[187],_data[172],_data[157],_data[142],_data[127],_data[112],_data[97], _data[82] ])
|
||||
binlc.extend([_data[7], _data[188],_data[173],_data[158],_data[143],_data[128],_data[113],_data[98], _data[83]])
|
||||
#This is the rest of the Full LC data -- the RS1293 FEC that we don't need
|
||||
# This is extremely important for SMS and GPS though.
|
||||
binlc.extend([_data[68],_data[53],_data[174],_data[159],_data[144],_data[129],_data[114],_data[99],_data[84],_data[69],_data[54],_data[39]])
|
||||
binlc.extend([_data[24],_data[145],_data[130],_data[115],_data[100],_data[85],_data[70],_data[55],_data[40],_data[25],_data[10],_data[191]])
|
||||
return binlc
|
||||
|
||||
|
||||
n_packet_assembly = 0
|
||||
|
||||
packet_assembly = ''
|
||||
|
||||
final_packet = ''
|
||||
|
||||
#Convert DMR packet to binary from MMDVM packet and remove Slot Type and EMB Sync stuff to allow for BPTC 196,96 decoding
|
||||
def bptc_decode(_data):
|
||||
binary_packet = bitarray(decode.to_bits(_data[20:]))
|
||||
del binary_packet[98:166]
|
||||
return decode_full(binary_packet)
|
||||
# Placeholder for future header id
|
||||
def header_ID(_data):
|
||||
hex_hdr = str(ahex(bptc_decode(_data)))
|
||||
return hex_hdr[2:6]
|
||||
# Work in progress, used to determine data format
|
||||
## pass
|
||||
|
||||
def aprs_send(packet):
|
||||
if aprs_callsign == 'N0CALL':
|
||||
logger.info('APRS callsighn set to N0CALL, packet not sent.')
|
||||
pass
|
||||
else:
|
||||
AIS = aprslib.IS(aprs_callsign, passwd=aprs_passcode,host=aprs_server, port=aprs_port)
|
||||
AIS.connect()
|
||||
AIS.sendall(packet)
|
||||
AIS.close()
|
||||
logger.info('Packet sent to APRS-IS.')
|
||||
# For future use
|
||||
##def position_timer(aprs_call):
|
||||
## dash_entries = ast.literal_eval(os.popen('cat ' + loc_file).read())
|
||||
## for i in dash_entries:
|
||||
## if aprs_call == i['call']:
|
||||
## if time.time()
|
||||
|
||||
|
||||
def dashboard_loc_write(call, lat, lon, time, comment):
|
||||
dash_entries = ast.literal_eval(os.popen('cat /tmp/gps_data_user_loc.txt').read())
|
||||
dash_entries.insert(0, {'call': call, 'lat': lat, 'lon': lon, 'time':time, 'comment':comment})
|
||||
# Clear old entries
|
||||
list_index = 0
|
||||
call_count = 0
|
||||
new_dash_entries = []
|
||||
for i in dash_entries:
|
||||
if i['call'] == call:
|
||||
if call_count >= 25:
|
||||
pass
|
||||
else:
|
||||
new_dash_entries.append(i)
|
||||
call_count = call_count + 1
|
||||
|
||||
if call != i['call']:
|
||||
new_dash_entries.append(i)
|
||||
pass
|
||||
list_index = list_index + 1
|
||||
with open(loc_file, 'w') as user_loc_file:
|
||||
user_loc_file.write(str(new_dash_entries[:500]))
|
||||
user_loc_file.close()
|
||||
logger.info('User location saved for dashboard')
|
||||
#logger.info(dash_entries)
|
||||
|
||||
def dashboard_bb_write(call, dmr_id, time, bulletin):
|
||||
#try:
|
||||
dash_bb = ast.literal_eval(os.popen('cat ' + bb_file).read())
|
||||
# except:
|
||||
# dash_entries = []
|
||||
dash_bb.insert(0, {'call': call, 'dmr_id': dmr_id, 'time': time, 'bulletin':bulletin})
|
||||
with open(bb_file, 'w') as user_bb_file:
|
||||
user_bb_file.write(str(dash_bb[:20]))
|
||||
user_bb_file.close()
|
||||
logger.info('User bulletin entry saved.')
|
||||
#logger.info(dash_bb)
|
||||
|
||||
def mailbox_write(call, dmr_id, time, message, recipient):
|
||||
#try:
|
||||
mail_file = ast.literal_eval(os.popen('cat ' + the_mailbox_file).read())
|
||||
mail_file.insert(0, {'call': call, 'dmr_id': dmr_id, 'time': time, 'message':message, 'recipient': recipient})
|
||||
with open(the_mailbox_file, 'w') as mailbox_file:
|
||||
mailbox_file.write(str(mail_file[:100]))
|
||||
mailbox_file.close()
|
||||
logger.info('User mail saved.')
|
||||
|
||||
def mailbox_delete(dmr_id):
|
||||
mail_file = ast.literal_eval(os.popen('cat ' + the_mailbox_file).read())
|
||||
call = str(get_alias((dmr_id), subscriber_ids))
|
||||
new_data = []
|
||||
for message in mail_file:
|
||||
if message['recipient'] != call:
|
||||
new_data.append(message)
|
||||
with open(the_mailbox_file, 'w') as mailbox_file:
|
||||
mailbox_file.write(str(new_data[:100]))
|
||||
mailbox_file.close()
|
||||
logger.info('Mailbox updated. Delete occurred.')
|
||||
|
||||
|
||||
def sos_write(dmr_id, time, message):
|
||||
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
|
||||
try:
|
||||
if user_settings[dmr_id][1]['ssid'] == '':
|
||||
sos_call = user_settings[dmr_id][0]['call'] + '-' + user_ssid
|
||||
else:
|
||||
sos_call = user_settings[dmr_id][0]['call'] + '-' + user_settings[dmr_id][1]['ssid']
|
||||
except:
|
||||
sos_call = str(get_alias((dmr_id), subscriber_ids))
|
||||
sos_info = {'call': sos_call, 'dmr_id': dmr_id, 'time': time, 'message':message}
|
||||
with open(emergency_sos_file, 'w') as sos_file:
|
||||
sos_file.write(str(sos_info))
|
||||
sos_file.close()
|
||||
logger.info('Saved SOS.')
|
||||
|
||||
# Send email via SMTP function
|
||||
def send_email(to_email, email_subject, email_message):
|
||||
global smtp_server
|
||||
sender_address = email_sender
|
||||
account_password = email_password
|
||||
smtp_server = smtplib.SMTP_SSL(smtp_server, int(smtp_port))
|
||||
smtp_server.login(sender_address, account_password)
|
||||
message = "From: " + aprs_callsign + " D-APRS Gateway\nTo: " + to_email + "\nContent-type: text/html\nSubject: " + email_subject + "\n\n" + '<strong>' + email_subject + '</strong><p> </p><h3>' + email_message + '</h3><p> </p><p>This message was sent to you from a D-APRS gateway operated by <strong>' + aprs_callsign + '</strong>. Do not reply as this gateway is only one way at this time.</p>'
|
||||
smtp_server.sendmail(sender_address, to_email, message)
|
||||
smtp_server.close()
|
||||
|
||||
# Thanks for this forum post for this - https://stackoverflow.com/questions/2579535/convert-dd-decimal-degrees-to-dms-degrees-minutes-seconds-in-python
|
||||
|
||||
def decdeg2dms(dd):
|
||||
is_positive = dd >= 0
|
||||
dd = abs(dd)
|
||||
minutes,seconds = divmod(dd*3600,60)
|
||||
degrees,minutes = divmod(minutes,60)
|
||||
degrees = degrees if is_positive else -degrees
|
||||
return (degrees,minutes,seconds)
|
||||
|
||||
def user_setting_write(dmr_id, setting, value):
|
||||
## try:
|
||||
# Open file and load as dict for modification
|
||||
with open(user_settings_file, 'r') as f:
|
||||
## if f.read() == '{}':
|
||||
## user_dict = {}
|
||||
user_dict = ast.literal_eval(f.read())
|
||||
logger.info('Current settings: ' + str(user_dict))
|
||||
if dmr_id not in user_dict:
|
||||
user_dict[dmr_id] = [{'call': str(get_alias((dmr_id), subscriber_ids))}, {'ssid': ''}, {'icon': ''}, {'comment': ''}]
|
||||
if setting.upper() == 'ICON':
|
||||
user_dict[dmr_id][2]['icon'] = value
|
||||
if setting.upper() == 'SSID':
|
||||
user_dict[dmr_id][1]['ssid'] = value
|
||||
if setting.upper() == 'COM':
|
||||
user_comment = user_dict[dmr_id][3]['comment'] = value[0:35]
|
||||
if setting.upper() == 'APRS':
|
||||
user_dict[dmr_id] = [{'call': str(get_alias((dmr_id), subscriber_ids))}, {'ssid': ''}, {'icon': ''}, {'comment': ''}]
|
||||
if setting.upper() == 'PIN':
|
||||
try:
|
||||
if user_dict[dmr_id]:
|
||||
user_dict[dmr_id][4]['pin'] = value
|
||||
if not user_dict[dmr_id]:
|
||||
user_dict[dmr_id] = [{'call': str(get_alias((dmr_id), subscriber_ids))}, {'ssid': ''}, {'icon': ''}, {'comment': ''}, {'pin': pin}]
|
||||
except:
|
||||
user_dict[dmr_id].append({'pin': value})
|
||||
f.close()
|
||||
logger.info('Loaded user settings. Preparing to write...')
|
||||
# Write modified dict to file
|
||||
with open(user_settings_file, 'w') as user_dict_file:
|
||||
user_dict_file.write(str(user_dict))
|
||||
user_dict_file.close()
|
||||
logger.info('User setting saved')
|
||||
f.close()
|
||||
packet_assembly = ''
|
||||
|
||||
# Process SMS, do something bases on message
|
||||
|
||||
def process_sms(_rf_src, sms):
|
||||
if sms == 'ID':
|
||||
logger.info(str(get_alias(int_id(_rf_src), subscriber_ids)) + ' - ' + str(int_id(_rf_src)))
|
||||
elif sms == 'TEST':
|
||||
logger.info('It works!')
|
||||
elif '@ICON' in sms:
|
||||
user_setting_write(int_id(_rf_src), re.sub(' .*|@','',sms), re.sub('@ICON| ','',sms))
|
||||
elif '@SSID' in sms:
|
||||
user_setting_write(int_id(_rf_src), re.sub(' .*|@','',sms), re.sub('@SSID| ','',sms))
|
||||
elif '@COM' in sms:
|
||||
user_setting_write(int_id(_rf_src), re.sub(' .*|@','',sms), re.sub('@COM |@COM','',sms))
|
||||
elif '@PIN' in sms:
|
||||
user_setting_write(int_id(_rf_src), re.sub(' .*|@','',sms), int(re.sub('@PIN |@PIN','',sms)))
|
||||
# Write blank entry to cause APRS receive to look for packets for this station.
|
||||
elif '@APRS' in sms:
|
||||
user_setting_write(int_id(_rf_src), 'APRS', '')
|
||||
elif '@BB' in sms:
|
||||
dashboard_bb_write(get_alias(int_id(_rf_src), subscriber_ids), int_id(_rf_src), time.time(), re.sub('@BB|@BB ','',sms))
|
||||
elif '@' and ' E-' in sms:
|
||||
email_message = str(re.sub('.*@|.* E-', '', sms))
|
||||
to_email = str(re.sub(' E-.*', '', sms))
|
||||
email_subject = 'New message from ' + str(get_alias(int_id(_rf_src), subscriber_ids))
|
||||
logger.info('Email to: ' + to_email)
|
||||
logger.info('Message: ' + email_message)
|
||||
try:
|
||||
send_email(to_email, email_subject, email_message)
|
||||
logger.info('Email sent.')
|
||||
except Exception as error_exception:
|
||||
logger.info('Failed to send email.')
|
||||
logger.info(error_exception)
|
||||
logger.info(str(traceback.extract_tb(error_exception.__traceback__)))
|
||||
elif '@SOS' in sms or '@NOTICE' in sms:
|
||||
sos_write(int_id(_rf_src), time.time(), sms)
|
||||
elif '@REM SOS' == sms:
|
||||
os.remove(emergency_sos_file)
|
||||
logger.info('Removing SOS or Notice')
|
||||
elif '@' and 'M-' in sms:
|
||||
message = re.sub('^@|.* M-|','',sms)
|
||||
recipient = re.sub('@| M-.*','',sms)
|
||||
mailbox_write(get_alias(int_id(_rf_src), subscriber_ids), int_id(_rf_src), time.time(), message, str(recipient).upper())
|
||||
elif '@REM MAIL' == sms:
|
||||
mailbox_delete(_rf_src)
|
||||
elif '@MH' in sms:
|
||||
grid_square = re.sub('@MH ', '', sms)
|
||||
if len(grid_square) < 6:
|
||||
pass
|
||||
else:
|
||||
lat = decdeg2dms(mh.to_location(grid_square)[0])
|
||||
lon = decdeg2dms(mh.to_location(grid_square)[1])
|
||||
|
||||
if lon[0] < 0:
|
||||
lon_dir = 'W'
|
||||
if lon[0] > 0:
|
||||
lon_dir = 'E'
|
||||
if lat[0] < 0:
|
||||
lat_dir = 'S'
|
||||
if lat[0] > 0:
|
||||
lat_dir = 'N'
|
||||
#logger.info(lat)
|
||||
#logger.info(lat_dir)
|
||||
aprs_lat = str(str(re.sub('\..*|-', '', str(lat[0]))) + str(re.sub('\..*', '', str(lat[1])) + '.')).zfill(5) + ' ' + lat_dir
|
||||
aprs_lon = str(str(re.sub('\..*|-', '', str(lon[0]))) + str(re.sub('\..*', '', str(lon[1])) + '.')).zfill(6) + ' ' + lon_dir
|
||||
logger.info('Latitude: ' + str(aprs_lat))
|
||||
logger.info('Longitude: ' + str(aprs_lon))
|
||||
# 14FRS2013 simplified and moved settings retrieval
|
||||
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
|
||||
if int_id(_rf_src) not in user_settings:
|
||||
ssid = str(user_ssid)
|
||||
icon_table = '/'
|
||||
icon_icon = '['
|
||||
comment = aprs_comment + ' DMR ID: ' + str(int_id(_rf_src))
|
||||
else:
|
||||
if user_settings[int_id(_rf_src)][1]['ssid'] == '':
|
||||
ssid = user_ssid
|
||||
if user_settings[int_id(_rf_src)][3]['comment'] == '':
|
||||
comment = aprs_comment + ' DMR ID: ' + str(int_id(_rf_src))
|
||||
if user_settings[int_id(_rf_src)][2]['icon'] == '':
|
||||
icon_table = '/'
|
||||
icon_icon = '['
|
||||
if user_settings[int_id(_rf_src)][2]['icon'] != '':
|
||||
icon_table = user_settings[int_id(_rf_src)][2]['icon'][0]
|
||||
icon_icon = user_settings[int_id(_rf_src)][2]['icon'][1]
|
||||
if user_settings[int_id(_rf_src)][1]['ssid'] != '':
|
||||
ssid = user_settings[int_id(_rf_src)][1]['ssid']
|
||||
if user_settings[int_id(_rf_src)][3]['comment'] != '':
|
||||
comment = user_settings[int_id(_rf_src)][3]['comment']
|
||||
aprs_loc_packet = str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid + '>APHBL3,TCPIP*:@' + str(datetime.datetime.utcnow().strftime("%H%M%Sh")) + str(aprs_lat) + icon_table + str(aprs_lon) + icon_icon + '/' + str(comment)
|
||||
logger.info(aprs_loc_packet)
|
||||
logger.info('User comment: ' + comment)
|
||||
logger.info('User SSID: ' + ssid)
|
||||
logger.info('User icon: ' + icon_table + icon_icon)
|
||||
try:
|
||||
aprslib.parse(aprs_loc_packet)
|
||||
aprs_send(aprs_loc_packet)
|
||||
dashboard_loc_write(str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid, aprs_lat, aprs_lon, time.time(), comment)
|
||||
#logger.info('Sent manual position to APRS')
|
||||
except Exception as error_exception:
|
||||
logger.info('Exception. Not uploaded')
|
||||
logger.info(error_exception)
|
||||
logger.info(str(traceback.extract_tb(error_exception.__traceback__)))
|
||||
packet_assembly = ''
|
||||
|
||||
|
||||
elif 'A-' in sms and '@' in sms:
|
||||
#Example SMS text: @ARMDS A-This is a test.
|
||||
aprs_dest = re.sub('@| A-.*','',sms)
|
||||
aprs_msg = re.sub('^@|.* A-|','',sms)
|
||||
logger.info('APRS message to ' + aprs_dest.upper() + '. Message: ' + aprs_msg)
|
||||
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
|
||||
if int_id(_rf_src) in user_settings and user_settings[int_id(_rf_src)][1]['ssid'] != '':
|
||||
ssid = user_settings[int_id(_rf_src)][1]['ssid']
|
||||
else:
|
||||
ssid = user_ssid
|
||||
aprs_msg_pkt = str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + str(ssid) + '>APHBL3,TCPIP*::' + str(aprs_dest).ljust(9).upper() + ':' + aprs_msg[0:73]
|
||||
logger.info(aprs_msg_pkt)
|
||||
try:
|
||||
aprslib.parse(aprs_msg_pkt)
|
||||
aprs_send(aprs_msg_pkt)
|
||||
#logger.info('Packet sent.')
|
||||
except Exception as error_exception:
|
||||
logger.info('Error uploading MSG packet.')
|
||||
logger.info(error_exception)
|
||||
logger.info(str(traceback.extract_tb(error_exception.__traceback__)))
|
||||
try:
|
||||
if sms in cmd_list:
|
||||
logger.info('Executing command/script.')
|
||||
os.popen(cmd_list[sms]).read()
|
||||
packet_assembly = ''
|
||||
except Exception as error_exception:
|
||||
logger.info('Exception. Command possibly not in list, or other error.')
|
||||
packet_assembly = ''
|
||||
logger.info(error_exception)
|
||||
logger.info(str(traceback.extract_tb(error_exception.__traceback__)))
|
||||
else:
|
||||
pass
|
||||
|
||||
###########
|
||||
|
||||
|
||||
class DATA_SYSTEM(HBSYSTEM):
|
||||
## global n_packet_assembly, packet_assembly
|
||||
|
||||
def __init__(self, _name, _config, _report):
|
||||
HBSYSTEM.__init__(self, _name, _config, _report)
|
||||
|
||||
def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data):
|
||||
# Capture data headers
|
||||
global n_packet_assembly, hdr_type
|
||||
#logger.info(_dtype_vseq)
|
||||
logger.info(time.strftime('%H:%M:%S - %m/%d/%y'))
|
||||
#logger.info('Special debug for developement:')
|
||||
#logger.info(ahex(bptc_decode(_data)))
|
||||
#logger.info(hdr_type)
|
||||
#logger.info((ba2num(bptc_decode(_data)[8:12])))
|
||||
if int_id(_dst_id) == data_id:
|
||||
#logger.info(type(_seq))
|
||||
if type(_seq) is bytes:
|
||||
pckt_seq = int.from_bytes(_seq, 'big')
|
||||
else:
|
||||
pckt_seq = _seq
|
||||
# Try to classify header
|
||||
# UDT header has DPF of 0101, which is 5.
|
||||
# If 5 is at position 3, then this should be a UDT header for MD-380 type radios.
|
||||
# Coordinates are usually in the very next block after the header, we will discard the rest.
|
||||
#logger.info(ahex(bptc_decode(_data)[0:10]))
|
||||
if _call_type == call_type and header_ID(_data)[3] == '5' and ba2num(bptc_decode(_data)[69:72]) == 0 and ba2num(bptc_decode(_data)[8:12]) == 0 or (_call_type == 'vcsbk' and header_ID(_data)[3] == '5' and ba2num(bptc_decode(_data)[69:72]) == 0 and ba2num(bptc_decode(_data)[8:12]) == 0):
|
||||
global udt_block
|
||||
logger.info('MD-380 type UDT header detected. Very next packet should be location.')
|
||||
hdr_type = '380'
|
||||
if _dtype_vseq == 6 and hdr_type == '380' or _dtype_vseq == 'group' and hdr_type == '380':
|
||||
udt_block = 1
|
||||
if _dtype_vseq == 7 and hdr_type == '380':
|
||||
udt_block = udt_block - 1
|
||||
if udt_block == 0:
|
||||
logger.info('MD-380 type packet. This should contain the GPS location.')
|
||||
logger.info('Packet: ' + str(ahex(bptc_decode(_data))))
|
||||
if ba2num(bptc_decode(_data)[1:2]) == 1:
|
||||
lat_dir = 'N'
|
||||
if ba2num(bptc_decode(_data)[1:2]) == 0:
|
||||
lat_dir = 'S'
|
||||
if ba2num(bptc_decode(_data)[2:3]) == 1:
|
||||
lon_dir = 'E'
|
||||
if ba2num(bptc_decode(_data)[2:3]) == 0:
|
||||
lon_dir = 'W'
|
||||
lat_deg = ba2num(bptc_decode(_data)[11:18])
|
||||
lon_deg = ba2num(bptc_decode(_data)[38:46])
|
||||
lat_min = ba2num(bptc_decode(_data)[18:24])
|
||||
lon_min = ba2num(bptc_decode(_data)[46:52])
|
||||
lat_min_dec = str(ba2num(bptc_decode(_data)[24:38])).zfill(4)
|
||||
lon_min_dec = str(ba2num(bptc_decode(_data)[52:66])).zfill(4)
|
||||
# Old MD-380 coordinate format, keep here until new is confirmed working.
|
||||
#aprs_lat = str(str(lat_deg) + str(lat_min) + '.' + str(lat_min_dec)[0:2]).zfill(7) + lat_dir
|
||||
#aprs_lon = str(str(lon_deg) + str(lon_min) + '.' + str(lon_min_dec)[0:2]).zfill(8) + lon_dir
|
||||
# Fix for MD-380 by G7HIF
|
||||
aprs_lat = str(str(lat_deg) + str(lat_min).zfill(2) + '.' + str(lat_min_dec)[0:2]).zfill(7) + lat_dir
|
||||
aprs_lon = str(str(lon_deg) + str(lon_min).zfill(2) + '.' + str(lon_min_dec)[0:2]).zfill(8) + lon_dir
|
||||
|
||||
# Form APRS packet
|
||||
#logger.info(aprs_loc_packet)
|
||||
logger.info('Lat: ' + str(aprs_lat) + ' Lon: ' + str(aprs_lon))
|
||||
# 14FRS2013 simplified and moved settings retrieval
|
||||
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
|
||||
if int_id(_rf_src) not in user_settings:
|
||||
ssid = str(user_ssid)
|
||||
icon_table = '/'
|
||||
icon_icon = '['
|
||||
comment = aprs_comment + ' DMR ID: ' + str(int_id(_rf_src))
|
||||
else:
|
||||
if user_settings[int_id(_rf_src)][1]['ssid'] == '':
|
||||
ssid = user_ssid
|
||||
if user_settings[int_id(_rf_src)][3]['comment'] == '':
|
||||
comment = aprs_comment + ' DMR ID: ' + str(int_id(_rf_src))
|
||||
if user_settings[int_id(_rf_src)][2]['icon'] == '':
|
||||
icon_table = '/'
|
||||
icon_icon = '['
|
||||
if user_settings[int_id(_rf_src)][2]['icon'] != '':
|
||||
icon_table = user_settings[int_id(_rf_src)][2]['icon'][0]
|
||||
icon_icon = user_settings[int_id(_rf_src)][2]['icon'][1]
|
||||
if user_settings[int_id(_rf_src)][1]['ssid'] != '':
|
||||
ssid = user_settings[int_id(_rf_src)][1]['ssid']
|
||||
if user_settings[int_id(_rf_src)][3]['comment'] != '':
|
||||
comment = user_settings[int_id(_rf_src)][3]['comment']
|
||||
aprs_loc_packet = str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid + '>APHBL3,TCPIP*:@' + str(datetime.datetime.utcnow().strftime("%H%M%Sh")) + str(aprs_lat) + icon_table + str(aprs_lon) + icon_icon + '/' + str(comment)
|
||||
logger.info(aprs_loc_packet)
|
||||
logger.info('User comment: ' + comment)
|
||||
logger.info('User SSID: ' + ssid)
|
||||
logger.info('User icon: ' + icon_table + icon_icon)
|
||||
# Attempt to prevent malformed packets from being uploaded.
|
||||
try:
|
||||
aprslib.parse(aprs_loc_packet)
|
||||
float(lat_deg) < 91
|
||||
float(lon_deg) < 121
|
||||
aprs_send(aprs_loc_packet)
|
||||
dashboard_loc_write(str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid, aprs_lat, aprs_lon, time.time(), comment)
|
||||
#logger.info('Sent APRS packet')
|
||||
except Exception as error_exception:
|
||||
logger.info('Error. Failed to send packet. Packet may be malformed.')
|
||||
logger.info(error_exception)
|
||||
logger.info(str(traceback.extract_tb(error_exception.__traceback__)))
|
||||
udt_block = 1
|
||||
hdr_type = ''
|
||||
else:
|
||||
pass
|
||||
#NMEA type packets for Anytone like radios.
|
||||
#if _call_type == call_type or (_call_type == 'vcsbk' and pckt_seq > 3): #int.from_bytes(_seq, 'big') > 3 ):
|
||||
# 14FRS2013 contributed improved header filtering, KF7EEL added conditions to allow both call types at the same time
|
||||
if _call_type == call_type or (_call_type == 'vcsbk' and pckt_seq > 3 and call_type != 'unit') or (_call_type == 'group' and pckt_seq > 3 and call_type != 'unit') or (_call_type == 'group' and pckt_seq > 3 and call_type == 'both') or (_call_type == 'vcsbk' and pckt_seq > 3 and call_type == 'both') or (_call_type == 'unit' and pckt_seq > 3 and call_type == 'both'): #int.from_bytes(_seq, 'big') > 3 ):
|
||||
global packet_assembly, btf
|
||||
if _dtype_vseq == 6 or _dtype_vseq == 'group':
|
||||
global btf, hdr_start
|
||||
hdr_start = str(header_ID(_data))
|
||||
logger.info('Header from ' + str(get_alias(int_id(_rf_src), subscriber_ids)) + '. DMR ID: ' + str(int_id(_rf_src)))
|
||||
logger.info(ahex(bptc_decode(_data)))
|
||||
logger.info('Blocks to follow: ' + str(ba2num(bptc_decode(_data)[65:72])))
|
||||
btf = ba2num(bptc_decode(_data)[65:72])
|
||||
# Try resetting packet_assembly
|
||||
packet_assembly = ''
|
||||
# Data blocks at 1/2 rate, see https://github.com/g4klx/MMDVM/blob/master/DMRDefines.h for data types. _dtype_seq defined here also
|
||||
if _dtype_vseq == 7:
|
||||
btf = btf - 1
|
||||
logger.info('Block #: ' + str(btf))
|
||||
#logger.info(_seq)
|
||||
logger.info('Data block from ' + str(get_alias(int_id(_rf_src), subscriber_ids)) + '. DMR ID: ' + str(int_id(_rf_src)))
|
||||
logger.info(ahex(bptc_decode(_data)))
|
||||
if _seq == 0:
|
||||
n_packet_assembly = 0
|
||||
packet_assembly = ''
|
||||
|
||||
#if btf < btf + 1:
|
||||
# 14FRS2013 removed condition, works great!
|
||||
n_packet_assembly = n_packet_assembly + 1
|
||||
packet_assembly = packet_assembly + str(bptc_decode(_data)) #str((decode_full_lc(b_packet)).strip('bitarray('))
|
||||
# Use block 0 as trigger. $GPRMC must also be in string to indicate NMEA.
|
||||
# This triggers the APRS upload
|
||||
if btf == 0:
|
||||
final_packet = str(bitarray(re.sub("\)|\(|bitarray|'", '', packet_assembly)).tobytes().decode('utf-8', 'ignore'))
|
||||
sms_hex = str(ba2hx(bitarray(re.sub("\)|\(|bitarray|'", '', packet_assembly))))
|
||||
sms_hex_string = re.sub("b'|'", '', str(sms_hex))
|
||||
#NMEA GPS sentence
|
||||
if '$GPRMC' in final_packet or '$GNRMC' in final_packet:
|
||||
logger.info(final_packet + '\n')
|
||||
# Eliminate excess bytes based on NMEA type
|
||||
# GPRMC
|
||||
if 'GPRMC' in final_packet:
|
||||
logger.info('GPRMC location')
|
||||
#nmea_parse = re.sub('A\*.*|.*\$', '', str(final_packet))
|
||||
nmea_parse = re.sub('A\*.*|.*\$|\n.*', '', str(final_packet))
|
||||
# GNRMC
|
||||
if 'GNRMC' in final_packet:
|
||||
logger.info('GNRMC location')
|
||||
nmea_parse = re.sub('.*\$|\n.*|V\*.*', '', final_packet)
|
||||
loc = pynmea2.parse(nmea_parse, check=False)
|
||||
logger.info('Latitude: ' + str(loc.lat) + str(loc.lat_dir) + ' Longitude: ' + str(loc.lon) + str(loc.lon_dir) + ' Direction: ' + str(loc.true_course) + ' Speed: ' + str(loc.spd_over_grnd) + '\n')
|
||||
try:
|
||||
# Begin APRS format and upload
|
||||
# Disable opening file for reading to reduce "collision" or reading and writing at same time.
|
||||
# 14FRS2013 simplified and moved settings retrieval
|
||||
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
|
||||
if int_id(_rf_src) not in user_settings:
|
||||
ssid = str(user_ssid)
|
||||
icon_table = '/'
|
||||
icon_icon = '['
|
||||
comment = aprs_comment + ' DMR ID: ' + str(int_id(_rf_src))
|
||||
else:
|
||||
if user_settings[int_id(_rf_src)][1]['ssid'] == '':
|
||||
ssid = user_ssid
|
||||
if user_settings[int_id(_rf_src)][3]['comment'] == '':
|
||||
comment = aprs_comment + ' DMR ID: ' + str(int_id(_rf_src))
|
||||
if user_settings[int_id(_rf_src)][2]['icon'] == '':
|
||||
icon_table = '/'
|
||||
icon_icon = '['
|
||||
if user_settings[int_id(_rf_src)][2]['icon'] != '':
|
||||
icon_table = user_settings[int_id(_rf_src)][2]['icon'][0]
|
||||
icon_icon = user_settings[int_id(_rf_src)][2]['icon'][1]
|
||||
if user_settings[int_id(_rf_src)][1]['ssid'] != '':
|
||||
ssid = user_settings[int_id(_rf_src)][1]['ssid']
|
||||
if user_settings[int_id(_rf_src)][3]['comment'] != '':
|
||||
comment = user_settings[int_id(_rf_src)][3]['comment']
|
||||
aprs_loc_packet = str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid + '>APHBL3,TCPIP*:@' + str(datetime.datetime.utcnow().strftime("%H%M%Sh")) + str(loc.lat[0:7]) + str(loc.lat_dir) + icon_table + str(loc.lon[0:8]) + str(loc.lon_dir) + icon_icon + str(round(loc.true_course)).zfill(3) + '/' + str(round(loc.spd_over_grnd)).zfill(3) + '/' + str(comment)
|
||||
logger.info(aprs_loc_packet)
|
||||
logger.info('User comment: ' + comment)
|
||||
logger.info('User SSID: ' + ssid)
|
||||
logger.info('User icon: ' + icon_table + icon_icon)
|
||||
except Exception as error_exception:
|
||||
logger.info('Error or user settings file not found, proceeding with default settings.')
|
||||
aprs_loc_packet = str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + str(user_ssid) + '>APHBL3,TCPIP*:@' + str(datetime.datetime.utcnow().strftime("%H%M%Sh")) + str(loc.lat[0:7]) + str(loc.lat_dir) + '/' + str(loc.lon[0:8]) + str(loc.lon_dir) + '[' + str(round(loc.true_course)).zfill(3) + '/' + str(round(loc.spd_over_grnd)).zfill(3) + '/' + aprs_comment + ' DMR ID: ' + str(int_id(_rf_src))
|
||||
logger.info(error_exception)
|
||||
logger.info(str(traceback.extract_tb(error_exception.__traceback__)))
|
||||
try:
|
||||
# Try parse of APRS packet. If it fails, it will not upload to APRS-IS
|
||||
aprslib.parse(aprs_loc_packet)
|
||||
# Float values of lat and lon. Anything that is not a number will cause it to fail.
|
||||
float(loc.lat)
|
||||
float(loc.lon)
|
||||
aprs_send(aprs_loc_packet)
|
||||
dashboard_loc_write(str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid, str(loc.lat[0:7]) + str(loc.lat_dir), str(loc.lon[0:8]) + str(loc.lon_dir), time.time(), comment)
|
||||
except Exception as error_exception:
|
||||
logger.info('Failed to parse packet. Packet may be deformed. Not uploaded.')
|
||||
logger.info(error_exception)
|
||||
logger.info(str(traceback.extract_tb(error_exception.__traceback__)))
|
||||
#final_packet = ''
|
||||
# Get callsign based on DMR ID
|
||||
# End APRS-IS upload
|
||||
# Assume this is an SMS message
|
||||
elif '$GPRMC' not in final_packet or '$GNRMC' not in final_packet:
|
||||
|
||||
#### # Motorola type SMS header
|
||||
## if '824a' in hdr_start or '024a' in hdr_start:
|
||||
## logger.info('\nMotorola type SMS')
|
||||
## sms = codecs.decode(bytes.fromhex(''.join(sms_hex[74:-8].split('00'))), 'utf-8')
|
||||
## logger.info('\n\n' + 'Received SMS from ' + str(get_alias(int_id(_rf_src), subscriber_ids)) + ', DMR ID: ' + str(int_id(_rf_src)) + ': ' + str(sms) + '\n')
|
||||
## process_sms(_rf_src, sms)
|
||||
## packet_assembly = ''
|
||||
## # ETSI? type SMS header
|
||||
## elif '0244' in hdr_start or '8244' in hdr_start:
|
||||
## logger.info('ETSI? type SMS')
|
||||
## sms = codecs.decode(bytes.fromhex(''.join(sms_hex[64:-8].split('00'))), 'utf-8')
|
||||
## logger.info('\n\n' + 'Received SMS from ' + str(get_alias(int_id(_rf_src), subscriber_ids)) + ', DMR ID: ' + str(int_id(_rf_src)) + ': ' + str(sms) + '\n')
|
||||
## #logger.info(final_packet)
|
||||
## #logger.info(sms_hex[64:-8])
|
||||
## process_sms(_rf_src, sms)
|
||||
## packet_assembly = ''
|
||||
####
|
||||
## else:
|
||||
logger.info('\nSMS detected. Attempting to parse.')
|
||||
#logger.info(final_packet)
|
||||
logger.info(sms_hex)
|
||||
## logger.info(type(sms_hex))
|
||||
logger.info('Attempting to find command...')
|
||||
## sms = codecs.decode(bytes.fromhex(''.join(sms_hex[:-8].split('00'))), 'utf-8', 'ignore')
|
||||
sms = codecs.decode(bytes.fromhex(''.join(sms_hex_string[:-8].split('00'))), 'utf-8', 'ignore')
|
||||
msg_found = re.sub('.*\n', '', sms)
|
||||
logger.info('\n\n' + 'Received SMS from ' + str(get_alias(int_id(_rf_src), subscriber_ids)) + ', DMR ID: ' + str(int_id(_rf_src)) + ': ' + str(msg_found) + '\n')
|
||||
process_sms(_rf_src, msg_found)
|
||||
#packet_assembly = ''
|
||||
pass
|
||||
#logger.info(bitarray(re.sub("\)|\(|bitarray|'", '', str(bptc_decode(_data)).tobytes().decode('utf-8', 'ignore'))))
|
||||
#logger.info('\n\n' + 'Received SMS from ' + str(get_alias(int_id(_rf_src), subscriber_ids)) + ', DMR ID: ' + str(int_id(_rf_src)) + ': ' + str(sms) + '\n')
|
||||
# Reset the packet assembly to prevent old data from returning.
|
||||
# 14FRS2013 moved variable reset
|
||||
hdr_start = ''
|
||||
n_packet_assembly = 0
|
||||
packet_assembly = ''
|
||||
btf = 0
|
||||
#logger.info(_seq)
|
||||
#packet_assembly = '' #logger.info(_dtype_vseq)
|
||||
#logger.info(ahex(bptc_decode(_data)).decode('utf-8', 'ignore'))
|
||||
#logger.info(bitarray(re.sub("\)|\(|bitarray|'", '', str(bptc_decode(_data)).tobytes().decode('utf-8', 'ignore'))))
|
||||
|
||||
else:
|
||||
pass
|
||||
|
||||
|
||||
#************************************************
|
||||
# MAIN PROGRAM LOOP STARTS HERE
|
||||
#************************************************
|
||||
|
||||
if __name__ == '__main__':
|
||||
#global aprs_callsign, aprs_passcode, aprs_server, aprs_port, user_ssid, aprs_comment, call_type, data_id
|
||||
import argparse
|
||||
import sys
|
||||
import os
|
||||
import signal
|
||||
from dmr_utils3.utils import try_download, mk_id_dict
|
||||
|
||||
# Change the current directory to the location of the application
|
||||
os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])))
|
||||
|
||||
|
||||
# CLI argument parser - handles picking up the config file from the command line, and sending a "help" message
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-c', '--config', action='store', dest='CONFIG_FILE', help='/full/path/to/config.file (usually gps_data.cfg)')
|
||||
parser.add_argument('-l', '--logging', action='store', dest='LOG_LEVEL', help='Override config file logging level.')
|
||||
cli_args = parser.parse_args()
|
||||
|
||||
# Ensure we have a path for the config file, if one wasn't specified, then use the default (top of file)
|
||||
if not cli_args.CONFIG_FILE:
|
||||
cli_args.CONFIG_FILE = os.path.dirname(os.path.abspath(__file__))+'/gps_data.cfg'
|
||||
|
||||
# Call the external routine to build the configuration dictionary
|
||||
CONFIG = config.build_config(cli_args.CONFIG_FILE)
|
||||
|
||||
data_id = int(CONFIG['GPS_DATA']['DATA_DMR_ID'])
|
||||
|
||||
# Group call or Unit (private) call
|
||||
call_type = CONFIG['GPS_DATA']['CALL_TYPE']
|
||||
# APRS-IS login information
|
||||
aprs_callsign = CONFIG['GPS_DATA']['APRS_LOGIN_CALL']
|
||||
aprs_passcode = int(CONFIG['GPS_DATA']['APRS_LOGIN_PASSCODE'])
|
||||
aprs_server = CONFIG['GPS_DATA']['APRS_SERVER']
|
||||
aprs_port = int(CONFIG['GPS_DATA']['APRS_PORT'])
|
||||
user_ssid = CONFIG['GPS_DATA']['USER_APRS_SSID']
|
||||
aprs_comment = CONFIG['GPS_DATA']['USER_APRS_COMMENT']
|
||||
# EMAIL variables
|
||||
email_sender = CONFIG['GPS_DATA']['EMAIL_SENDER']
|
||||
email_password = CONFIG['GPS_DATA']['EMAIL_PASSWORD']
|
||||
smtp_server = CONFIG['GPS_DATA']['SMTP_SERVER']
|
||||
smtp_port = CONFIG['GPS_DATA']['SMTP_PORT']
|
||||
|
||||
# Dashboard files
|
||||
bb_file = CONFIG['GPS_DATA']['BULLETIN_BOARD_FILE']
|
||||
loc_file = CONFIG['GPS_DATA']['LOCATION_FILE']
|
||||
the_mailbox_file = CONFIG['GPS_DATA']['MAILBOX_FILE']
|
||||
emergency_sos_file = CONFIG['GPS_DATA']['EMERGENCY_SOS_FILE']
|
||||
|
||||
# User APRS settings
|
||||
user_settings_file = CONFIG['GPS_DATA']['USER_SETTINGS_FILE']
|
||||
|
||||
# Check if user_settings (for APRS settings of users) exists. Creat it if not.
|
||||
if Path(user_settings_file).is_file():
|
||||
pass
|
||||
else:
|
||||
Path(user_settings_file).touch()
|
||||
with open(user_settings_file, 'w') as user_dict_file:
|
||||
user_dict_file.write("{1: [{'call': 'N0CALL'}, {'ssid': ''}, {'icon': ''}, {'comment': ''}]}")
|
||||
user_dict_file.close()
|
||||
# Check to see if dashboard files exist
|
||||
if Path(loc_file).is_file():
|
||||
pass
|
||||
else:
|
||||
Path(loc_file).touch()
|
||||
with open(loc_file, 'w') as user_loc_file:
|
||||
user_loc_file.write("[]")
|
||||
user_loc_file.close()
|
||||
if Path(bb_file).is_file():
|
||||
pass
|
||||
else:
|
||||
Path(bb_file).touch()
|
||||
with open(bb_file, 'w') as user_bb_file:
|
||||
user_bb_file.write("[]")
|
||||
user_bb_file.close()
|
||||
if Path(the_mailbox_file).is_file():
|
||||
pass
|
||||
else:
|
||||
Path(the_mailbox_file).touch()
|
||||
with open(the_mailbox_file, 'w') as user_mail_file:
|
||||
user_mail_file.write("[]")
|
||||
user_mail_file.close()
|
||||
|
||||
# Start the system logger
|
||||
if cli_args.LOG_LEVEL:
|
||||
CONFIG['LOGGER']['LOG_LEVEL'] = cli_args.LOG_LEVEL
|
||||
logger = log.config_logging(CONFIG['LOGGER'])
|
||||
logger.info('\n\nCopyright (c) 2013, 2014, 2015, 2016, 2018, 2019\n\tThe Regents of the K0USY Group. All rights reserved.\n GPS and Data decoding by Eric, KF7EEL')
|
||||
logger.debug('Logging system started, anything from here on gets logged')
|
||||
|
||||
# Set up the signal handler
|
||||
def sig_handler(_signal, _frame):
|
||||
logger.info('SHUTDOWN: >>>GPS and Data Decoder<<< IS TERMINATING WITH SIGNAL %s', str(_signal))
|
||||
hblink_handler(_signal, _frame)
|
||||
logger.info('SHUTDOWN: ALL SYSTEM HANDLERS EXECUTED - STOPPING REACTOR')
|
||||
reactor.stop()
|
||||
|
||||
# Set signal handers so that we can gracefully exit if need be
|
||||
for sig in [signal.SIGTERM, signal.SIGINT]:
|
||||
signal.signal(sig, sig_handler)
|
||||
|
||||
# Create the name-number mapping dictionaries
|
||||
peer_ids, subscriber_ids, talkgroup_ids = mk_aliases(CONFIG)
|
||||
|
||||
|
||||
# INITIALIZE THE REPORTING LOOP
|
||||
if CONFIG['REPORTS']['REPORT']:
|
||||
report_server = config_reports(CONFIG, reportFactory)
|
||||
else:
|
||||
report_server = None
|
||||
logger.info('(REPORT) TCP Socket reporting not configured')
|
||||
|
||||
# HBlink instance creation
|
||||
logger.info('HBlink \'gps_data.py\' -- SYSTEM STARTING...')
|
||||
for system in CONFIG['SYSTEMS']:
|
||||
if CONFIG['SYSTEMS'][system]['ENABLED']:
|
||||
if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE':
|
||||
systems[system] = OPENBRIDGE(system, CONFIG, report_server)
|
||||
else:
|
||||
systems[system] = DATA_SYSTEM(system, CONFIG, report_server)
|
||||
|
||||
reactor.listenUDP(CONFIG['SYSTEMS'][system]['PORT'], systems[system], interface=CONFIG['SYSTEMS'][system]['IP'])
|
||||
logger.debug('%s instance created: %s, %s', CONFIG['SYSTEMS'][system]['MODE'], system, systems[system])
|
||||
|
||||
reactor.run()
|
||||
|
||||
|
||||
# John 3:16 - For God so loved the world, that he gave his only Son,
|
||||
# that whoever believes in him should not perish but have eternal life.
|
|
@ -1,60 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
###############################################################################
|
||||
# HBLink - Copyright (C) 2020 Cortney T. Buffington, N0MJS <n0mjs@me.com>
|
||||
# GPS/Data - Copyright (C) 2020 Eric Craw, KF7EEL <kf7eel@qsl.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
###############################################################################
|
||||
|
||||
'''
|
||||
This script uploads a beacon to APRS-IS for the GPS/Data Application itself, cuasing it to appear as an igate
|
||||
an aprs.fi.
|
||||
'''
|
||||
|
||||
import aprslib
|
||||
import argparse
|
||||
import os
|
||||
import config
|
||||
import time
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-c', '--config', action='store', dest='CONFIG_FILE', help='/full/path/to/config.file (usually gps_data.cfg)')
|
||||
cli_args = parser.parse_args()
|
||||
|
||||
if not cli_args.CONFIG_FILE:
|
||||
cli_args.CONFIG_FILE = os.path.dirname(os.path.abspath(__file__))+'/gps_data.cfg'
|
||||
CONFIG = config.build_config(cli_args.CONFIG_FILE)
|
||||
|
||||
print('''
|
||||
GPS/Data Application Beacon Script by Eric, KF7EEL. https://github.com/kf7eel/hblink3 \n
|
||||
This script will upload an APRS position for the GPS/Data Application. This usually causes most APRS-IS clients to see the GPS/Data Application
|
||||
as an i-gate. \n
|
||||
Using the following setting to upload beacon.\n
|
||||
Callsign: ''' + CONFIG['GPS_DATA']['APRS_LOGIN_CALL'] + ''' - Position comment: ''' + CONFIG['GPS_DATA']['IGATE_BEACON_COMMENT'] + '''
|
||||
Beacon time: ''' + CONFIG['GPS_DATA']['IGATE_BEACON_TIME'] + '''
|
||||
''')
|
||||
|
||||
beacon_packet = CONFIG['GPS_DATA']['APRS_LOGIN_CALL'] + '>APHBL3,TCPIP*:!' + CONFIG['GPS_DATA']['IGATE_LATITUDE'] + str(CONFIG['GPS_DATA']['IGATE_BEACON_ICON'][0]) + CONFIG['GPS_DATA']['IGATE_LONGITUDE'] + str(CONFIG['GPS_DATA']['IGATE_BEACON_ICON'][1]) + '/' + CONFIG['GPS_DATA']['IGATE_BEACON_COMMENT']
|
||||
#print(beacon_packet)
|
||||
AIS = aprslib.IS(CONFIG['GPS_DATA']['APRS_LOGIN_CALL'], passwd=CONFIG['GPS_DATA']['APRS_LOGIN_PASSCODE'],host=CONFIG['GPS_DATA']['APRS_SERVER'], port=CONFIG['GPS_DATA']['APRS_PORT'])
|
||||
|
||||
while int(CONFIG['GPS_DATA']['IGATE_BEACON_TIME']) > 15:
|
||||
|
||||
AIS.connect()
|
||||
AIS.sendall(beacon_packet)
|
||||
print(beacon_packet)
|
||||
AIS.close()
|
||||
time.sleep(int(CONFIG['GPS_DATA']['IGATE_BEACON_TIME'])*60)
|
|
@ -1,11 +0,0 @@
|
|||
# Various configurable options used in the GPS/Data application.
|
||||
|
||||
# SMS message that triggers command
|
||||
|
||||
|
||||
cmd_list = {
|
||||
|
||||
'COMMAND' : 'echo "command to execute"',
|
||||
'UPTIME' : 'uptime'
|
||||
|
||||
}
|
|
@ -105,6 +105,29 @@ PEER_URL: https://www.radioid.net/static/rptrs.json
|
|||
SUBSCRIBER_URL: https://www.radioid.net/static/users.json
|
||||
STALE_DAYS: 7
|
||||
|
||||
# USER MANAGER
|
||||
# This is where to configure the details for use with a user managment script
|
||||
[WEB_SERVICE]
|
||||
THIS_SERVER_NAME: MMDVM_Server
|
||||
REMOTE_CONFIG_ENABLED: True
|
||||
# URL of the user managment server
|
||||
URL: http://localhost:8080/svr
|
||||
# Integer appended to DMR ID during the generation of a passphrase
|
||||
APPEND_INT: 1
|
||||
EXTRA_INT_1: 5
|
||||
EXTRA_INT_2: 8
|
||||
EXTRA_1: TeSt
|
||||
EXTRA_2: DmR4
|
||||
# Secret used to authenticate with user managment server, before checking if user login is approved
|
||||
SHARED_SECRET: test
|
||||
# Shorten passphrases
|
||||
SHORTEN_PASSPHRASE: True
|
||||
SHORTEN_SAMPLE: 4
|
||||
SHORTEN_LENGTH: 4
|
||||
BURN_FILE: ./burn_ids.txt
|
||||
BURN_INT: 5
|
||||
|
||||
|
||||
# OPENBRIDGE INSTANCES - DUPLICATE SECTION FOR MULTIPLE CONNECTIONS
|
||||
# OpenBridge is a protocol originall created by DMR+ for connection between an
|
||||
# IPSC2 server and Brandmeister. It has been implemented here at the suggestion
|
||||
|
@ -137,6 +160,9 @@ BOTH_SLOTS: True
|
|||
USE_ACL: True
|
||||
SUB_ACL: DENY:1
|
||||
TGID_ACL: PERMIT:ALL
|
||||
# Experimental encryption
|
||||
ENCRYPTION_KEY:
|
||||
USE_ENCRYPTION: False
|
||||
|
||||
# MASTER INSTANCES - DUPLICATE SECTION FOR MULTIPLE MASTERS
|
||||
# HomeBrew Protocol Master instances go here.
|
||||
|
@ -154,6 +180,10 @@ TGID_ACL: PERMIT:ALL
|
|||
[MASTER-1]
|
||||
MODE: MASTER
|
||||
ENABLED: True
|
||||
|
||||
# Use the user manager? If False, MASTER instance will operate as normal.
|
||||
USE_USER_MAN: False
|
||||
|
||||
REPEAT: True
|
||||
MAX_PEERS: 10
|
||||
EXPORT_AMBE: False
|
||||
|
@ -167,22 +197,6 @@ SUB_ACL: DENY:1
|
|||
TGID_TS1_ACL: PERMIT:ALL
|
||||
TGID_TS2_ACL: PERMIT:ALL
|
||||
|
||||
[D-APRS]
|
||||
MODE: MASTER
|
||||
ENABLED: True
|
||||
REPEAT: True
|
||||
MAX_PEERS: 2
|
||||
EXPORT_AMBE: False
|
||||
IP:
|
||||
PORT: 54070
|
||||
PASSPHRASE: passw0rd
|
||||
GROUP_HANGTIME: 5
|
||||
USE_ACL: True
|
||||
REG_ACL: DENY:1
|
||||
SUB_ACL: DENY:1
|
||||
TGID_TS1_ACL: PERMIT:ALL
|
||||
TGID_TS2_ACL: PERMIT:ALL
|
||||
|
||||
# PEER INSTANCES - DUPLICATE SECTION FOR MULTIPLE PEERS
|
||||
# There are a LOT of errors in the HB Protocol specifications on this one!
|
||||
# MOST of these items are just strings and will be properly dealt with by the program
|
||||
|
@ -227,38 +241,6 @@ SUB_ACL: DENY:1
|
|||
TGID_TS1_ACL: PERMIT:ALL
|
||||
TGID_TS2_ACL: PERMIT:ALL
|
||||
|
||||
[ECHO]
|
||||
MODE: PEER
|
||||
ENABLED: True
|
||||
LOOSE: False
|
||||
EXPORT_AMBE: False
|
||||
IP:
|
||||
PORT: 54073
|
||||
MASTER_IP: localhost
|
||||
MASTER_PORT: 54072
|
||||
passphrase: passw0rd
|
||||
CALLSIGN: ECHO
|
||||
RADIO_ID: 9999
|
||||
RX_FREQ: 000000000
|
||||
TX_FREQ: 000000000
|
||||
TX_POWER: 0
|
||||
COLORCODE: 1
|
||||
SLOTS: 1
|
||||
LATITUDE: 00.0000
|
||||
LONGITUDE: 000.0000
|
||||
HEIGHT: 0
|
||||
LOCATION: This Server
|
||||
DESCRIPTION: Echo Server
|
||||
URL: www.github.com/kf7eel/hblink3
|
||||
SOFTWARE_ID: 20170620
|
||||
PACKAGE_ID: MMDVM_HBlink
|
||||
GROUP_HANGTIME: 5
|
||||
OPTIONS:
|
||||
USE_ACL: True
|
||||
SUB_ACL: DENY:1
|
||||
TGID_TS1_ACL: PERMIT:ALL
|
||||
TGID_TS2_ACL: PERMIT:ALL
|
||||
|
||||
[XLX-1]
|
||||
MODE: XLXPEER
|
||||
ENABLED: False
|
||||
|
|
|
@ -44,6 +44,7 @@ from twisted.internet import reactor, task
|
|||
# Other files we pull from -- this is mostly for readability and segmentation
|
||||
import log
|
||||
import config
|
||||
from config import acl_build
|
||||
from const import *
|
||||
from dmr_utils3.utils import int_id, bytes_4, try_download, mk_id_dict
|
||||
|
||||
|
@ -55,6 +56,17 @@ from reporting_const import *
|
|||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Used for user auth
|
||||
import os, ast
|
||||
import requests, json
|
||||
import base64
|
||||
import libscrc
|
||||
import re
|
||||
|
||||
# Encryption library
|
||||
from cryptography.fernet import Fernet
|
||||
|
||||
|
||||
# Does anybody read this stuff? There's a PEP somewhere that says I should do this.
|
||||
__author__ = 'Cortney T. Buffington, N0MJS'
|
||||
__copyright__ = 'Copyright (c) 2016-2019 Cortney T. Buffington, N0MJS and the K0USY Group'
|
||||
|
@ -66,6 +78,19 @@ __email__ = 'n0mjs@me.com'
|
|||
# Global variables used whether we are a module or __main__
|
||||
systems = {}
|
||||
|
||||
# Functions that provide a basic symetrical encryption using Fernet
|
||||
def encrypt_packet(key, message):
|
||||
f = Fernet(key)
|
||||
token = f.encrypt(message)
|
||||
|
||||
return token
|
||||
|
||||
def decrypt_packet(key, message):
|
||||
f = Fernet(key)
|
||||
token = f.decrypt(message, ttl=1)
|
||||
|
||||
return token
|
||||
|
||||
# Timed loop used for reporting HBP status
|
||||
def config_reports(_config, _factory):
|
||||
def reporting_loop(_logger, _server):
|
||||
|
@ -94,12 +119,34 @@ def hblink_handler(_signal, _frame):
|
|||
# on matching and the action specified.
|
||||
def acl_check(_id, _acl):
|
||||
id = int_id(_id)
|
||||
|
||||
# if acl string, build tuple
|
||||
if type(_acl) == str:
|
||||
_acl = acl_build(_acl, 4294967295)
|
||||
|
||||
for entry in _acl[1]:
|
||||
if entry[0] <= id <= entry[1]:
|
||||
return _acl[0]
|
||||
return not _acl[0]
|
||||
|
||||
|
||||
def download_burnlist(_CONFIG):
|
||||
user_man_url = _CONFIG['WEB_SERVICE']['URL']
|
||||
shared_secret = str(sha256(_CONFIG['WEB_SERVICE']['SHARED_SECRET'].encode()).hexdigest())
|
||||
burn_check = {
|
||||
'burn_list':True,
|
||||
'secret':shared_secret
|
||||
}
|
||||
json_object = json.dumps(burn_check, indent = 4)
|
||||
try:
|
||||
req = requests.post(user_man_url, data=json_object, headers={'Content-Type': 'application/json'})
|
||||
resp = json.loads(req.text)
|
||||
return resp['burn_list']
|
||||
# For exception, write blank dict
|
||||
except requests.ConnectionError:
|
||||
return {}
|
||||
|
||||
|
||||
#************************************************
|
||||
# OPENBRIDGE CLASS
|
||||
#************************************************
|
||||
|
@ -117,84 +164,142 @@ class OPENBRIDGE(DatagramProtocol):
|
|||
logger.info('(%s) is mode OPENBRIDGE. No De-Registration required, continuing shutdown', self._system)
|
||||
|
||||
def send_system(self, _packet):
|
||||
if _packet[:4] == DMRD:
|
||||
if _packet[:4] == DMRD or _packet[:4] == EOBP:
|
||||
#_packet = _packet[:11] + self._config['NETWORK_ID'] + _packet[15:]
|
||||
_packet = b''.join([_packet[:11], self._config['NETWORK_ID'], _packet[15:]])
|
||||
#_packet += hmac_new(self._config['PASSPHRASE'],_packet,sha1).digest()
|
||||
_packet = b''.join([_packet, (hmac_new(self._config['PASSPHRASE'],_packet,sha1).digest())])
|
||||
if self._config['USE_ENCRYPTION'] == True or _packet[:4] == EOBP:
|
||||
_enc_pkt = encrypt_packet(self._config['ENCRYPTION_KEY'], _packet)
|
||||
_packet = b'EOBP' + _enc_pkt
|
||||
self.transport.write(_packet, (self._config['TARGET_IP'], self._config['TARGET_PORT']))
|
||||
# KEEP THE FOLLOWING COMMENTED OUT UNLESS YOU'RE DEBUGGING DEEPLY!!!!
|
||||
# logger.debug('(%s) TX Packet to OpenBridge %s:%s -- %s', self._system, self._config['TARGET_IP'], self._config['TARGET_PORT'], ahex(_packet))
|
||||
# Special Server Data packet, encrypted using frenet, send
|
||||
elif _packet[:4] == SVRD:
|
||||
_enc_pkt = encrypt_packet(self._config['ENCRYPTION_KEY'], _packet)
|
||||
_packet = b'SVRD' + _enc_pkt
|
||||
self.transport.write(_packet, (self._config['TARGET_IP'], self._config['TARGET_PORT']))
|
||||
logger.info('SVRD packet')
|
||||
else:
|
||||
logger.error('(%s) OpenBridge system was asked to send non DMRD packet: %s', self._system, _packet)
|
||||
|
||||
def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data):
|
||||
pass
|
||||
#print(int_id(_peer_id), int_id(_rf_src), int_id(_dst_id), int_id(_seq), _slot, _call_type, _frame_type, repr(_dtype_vseq), int_id(_stream_id))
|
||||
|
||||
def svrd_received(self, _mode, _data):
|
||||
pass
|
||||
|
||||
def datagramReceived(self, _packet, _sockaddr):
|
||||
## print(_packet[:4])
|
||||
# Keep This Line Commented Unless HEAVILY Debugging!
|
||||
#logger.debug('(%s) RX packet from %s -- %s', self._system, _sockaddr, ahex(_packet))
|
||||
## logger.debug('(%s) RX packet from %s -- %s', self._system, _sockaddr, ahex(_packet))
|
||||
if _packet[:4] == DMRD or _packet[:4] == EOBP:
|
||||
if _packet[:4] == EOBP:
|
||||
_d_pkt = decrypt_packet(self._config['ENCRYPTION_KEY'], _packet[4:])
|
||||
_packet = _d_pkt
|
||||
|
||||
if _packet[:4] == DMRD: # DMRData -- encapsulated DMR data frame
|
||||
_data = _packet[:53]
|
||||
_hash = _packet[53:]
|
||||
_ckhs = hmac_new(self._config['PASSPHRASE'],_data,sha1).digest()
|
||||
# DMRData -- encapsulated DMR data frame
|
||||
if _packet[:4] == DMRD:
|
||||
_data = _packet[:53]
|
||||
_hash = _packet[53:]
|
||||
_ckhs = hmac_new(self._config['PASSPHRASE'],_data,sha1).digest()
|
||||
|
||||
if compare_digest(_hash, _ckhs) and _sockaddr == self._config['TARGET_SOCK']:
|
||||
_peer_id = _data[11:15]
|
||||
_seq = _data[4]
|
||||
_rf_src = _data[5:8]
|
||||
_dst_id = _data[8:11]
|
||||
_bits = _data[15]
|
||||
_slot = 2 if (_bits & 0x80) else 1
|
||||
#_call_type = 'unit' if (_bits & 0x40) else 'group'
|
||||
if _bits & 0x40:
|
||||
_call_type = 'unit'
|
||||
elif (_bits & 0x23) == 0x23:
|
||||
_call_type = 'vcsbk'
|
||||
## print(compare_digest(_hash, _ckhs))
|
||||
## print(_sockaddr == self._config['TARGET_SOCK'])
|
||||
## print(ahex(_ckhs))
|
||||
## print(ahex(_hash))
|
||||
|
||||
if compare_digest(_hash, _ckhs) and _sockaddr == self._config['TARGET_SOCK']:
|
||||
_peer_id = _data[11:15]
|
||||
_seq = _data[4]
|
||||
_rf_src = _data[5:8]
|
||||
_dst_id = _data[8:11]
|
||||
_bits = _data[15]
|
||||
_slot = 2 if (_bits & 0x80) else 1
|
||||
#_call_type = 'unit' if (_bits & 0x40) else 'group'
|
||||
if _bits & 0x40:
|
||||
_call_type = 'unit'
|
||||
elif (_bits & 0x23) == 0x23:
|
||||
_call_type = 'vcsbk'
|
||||
else:
|
||||
_call_type = 'group'
|
||||
_frame_type = (_bits & 0x30) >> 4
|
||||
_dtype_vseq = (_bits & 0xF) # data, 1=voice header, 2=voice terminator; voice, 0=burst A ... 5=burst F
|
||||
_stream_id = _data[16:20]
|
||||
#logger.debug('(%s) DMRD - Seqence: %s, RF Source: %s, Destination ID: %s', self._system, int_id(_seq), int_id(_rf_src), int_id(_dst_id))
|
||||
|
||||
# Sanity check for OpenBridge -- all calls must be on Slot 1 for Brandmeister or DMR+. Other HBlinks can process timeslot on OPB if the flag is set
|
||||
if _slot != 1 and not self._config['BOTH_SLOTS'] and not _call_type == 'unit':
|
||||
logger.error('(%s) OpenBridge packet discarded because it was not received on slot 1. SID: %s, TGID %s', self._system, int_id(_rf_src), int_id(_dst_id))
|
||||
return
|
||||
|
||||
# ACL Processing
|
||||
if self._CONFIG['GLOBAL']['USE_ACL']:
|
||||
if not acl_check(_rf_src, self._CONFIG['GLOBAL']['SUB_ACL']):
|
||||
if _stream_id not in self._laststrid:
|
||||
logger.info('(%s) CALL DROPPED WITH STREAM ID %s FROM SUBSCRIBER %s BY GLOBAL ACL', self._system, int_id(_stream_id), int_id(_rf_src))
|
||||
self._laststrid.append(_stream_id)
|
||||
return
|
||||
if _slot == 1 and not acl_check(_dst_id, self._CONFIG['GLOBAL']['TG1_ACL']):
|
||||
if _stream_id not in self._laststrid:
|
||||
logger.info('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY GLOBAL TS1 ACL', self._system, int_id(_stream_id), int_id(_dst_id))
|
||||
self._laststrid.append(_stream_id)
|
||||
return
|
||||
if self._config['USE_ACL']:
|
||||
if not acl_check(_rf_src, self._config['SUB_ACL']):
|
||||
if _stream_id not in self._laststrid:
|
||||
logger.info('(%s) CALL DROPPED WITH STREAM ID %s FROM SUBSCRIBER %s BY SYSTEM ACL', self._system, int_id(_stream_id), int_id(_rf_src))
|
||||
self._laststrid.append(_stream_id)
|
||||
return
|
||||
if not acl_check(_dst_id, self._config['TG1_ACL']):
|
||||
if _stream_id not in self._laststrid:
|
||||
logger.info('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY SYSTEM ACL', self._system, int_id(_stream_id), int_id(_dst_id))
|
||||
self._laststrid.append(_stream_id)
|
||||
return
|
||||
|
||||
# Userland actions -- typically this is the function you subclass for an application
|
||||
self.dmrd_received(_peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data)
|
||||
else:
|
||||
_call_type = 'group'
|
||||
_frame_type = (_bits & 0x30) >> 4
|
||||
_dtype_vseq = (_bits & 0xF) # data, 1=voice header, 2=voice terminator; voice, 0=burst A ... 5=burst F
|
||||
_stream_id = _data[16:20]
|
||||
#logger.debug('(%s) DMRD - Seqence: %s, RF Source: %s, Destination ID: %s', self._system, int_id(_seq), int_id(_rf_src), int_id(_dst_id))
|
||||
|
||||
# Sanity check for OpenBridge -- all calls must be on Slot 1 for Brandmeister or DMR+. Other HBlinks can process timeslot on OPB if the flag is set
|
||||
if _slot != 1 and not self._config['BOTH_SLOTS'] and not _call_type == 'unit':
|
||||
logger.error('(%s) OpenBridge packet discarded because it was not received on slot 1. SID: %s, TGID %s', self._system, int_id(_rf_src), int_id(_dst_id))
|
||||
return
|
||||
|
||||
# ACL Processing
|
||||
if self._CONFIG['GLOBAL']['USE_ACL']:
|
||||
if not acl_check(_rf_src, self._CONFIG['GLOBAL']['SUB_ACL']):
|
||||
if _stream_id not in self._laststrid:
|
||||
logger.info('(%s) CALL DROPPED WITH STREAM ID %s FROM SUBSCRIBER %s BY GLOBAL ACL', self._system, int_id(_stream_id), int_id(_rf_src))
|
||||
self._laststrid.append(_stream_id)
|
||||
return
|
||||
if _slot == 1 and not acl_check(_dst_id, self._CONFIG['GLOBAL']['TG1_ACL']):
|
||||
if _stream_id not in self._laststrid:
|
||||
logger.info('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY GLOBAL TS1 ACL', self._system, int_id(_stream_id), int_id(_dst_id))
|
||||
self._laststrid.append(_stream_id)
|
||||
return
|
||||
if self._config['USE_ACL']:
|
||||
if not acl_check(_rf_src, self._config['SUB_ACL']):
|
||||
if _stream_id not in self._laststrid:
|
||||
logger.info('(%s) CALL DROPPED WITH STREAM ID %s FROM SUBSCRIBER %s BY SYSTEM ACL', self._system, int_id(_stream_id), int_id(_rf_src))
|
||||
self._laststrid.append(_stream_id)
|
||||
return
|
||||
if not acl_check(_dst_id, self._config['TG1_ACL']):
|
||||
if _stream_id not in self._laststrid:
|
||||
logger.info('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY SYSTEM ACL', self._system, int_id(_stream_id), int_id(_dst_id))
|
||||
self._laststrid.append(_stream_id)
|
||||
return
|
||||
|
||||
# Userland actions -- typically this is the function you subclass for an application
|
||||
self.dmrd_received(_peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data)
|
||||
else:
|
||||
logger.info('(%s) OpenBridge HMAC failed, packet discarded - OPCODE: %s DATA: %s HMAC LENGTH: %s HMAC: %s', self._system, _packet[:4], repr(_packet[:53]), len(_packet[53:]), repr(_packet[53:]))
|
||||
if not compare_digest(_hash, _ckhs):
|
||||
logger.info('(%s) OpenBridge HMAC failed, packet discarded - OPCODE: %s DATA: %s HMAC LENGTH: %s HMAC: %s', self._system, _packet[:4], repr(_packet[:53]), len(_packet[53:]), repr(_packet[53:]))
|
||||
|
||||
if not _sockaddr == self._config['TARGET_SOCK']:
|
||||
logger.info('(%s) OpenBridge socket mismatch, packet discarded - OPCODE: %s DATA: %s ', self._system, _packet[:4], repr(_packet[:53]))
|
||||
|
||||
|
||||
# Server Data packet, decrypt and process it.
|
||||
elif _packet[:4] == SVRD:
|
||||
_d_pkt = decrypt_packet(self._config['ENCRYPTION_KEY'], _packet[4:])
|
||||
## logger.info('SVRD Received: ' + str(_d_pkt))
|
||||
# DMR Data packet, sent via SVRD
|
||||
## if _d_pkt[4:8] == b'DATA':
|
||||
## print('----------------------')
|
||||
## _data = _d_pkt[4:]
|
||||
## _peer_id = _data[11:15]
|
||||
## _seq = _data[4]
|
||||
## _rf_src = _data[5:8]
|
||||
## _dst_id = _data[8:11]
|
||||
## _bits = _data[15]
|
||||
## _slot = 2 if (_bits & 0x80) else 1
|
||||
## #_call_type = 'unit' if (_bits & 0x40) else 'group'
|
||||
## if _bits & 0x40:
|
||||
## _call_type = 'unit'
|
||||
## elif (_bits & 0x23) == 0x23:
|
||||
## _call_type = 'vcsbk'
|
||||
## else:
|
||||
## _call_type = 'group'
|
||||
## _frame_type = (_bits & 0x30) >> 4
|
||||
## _dtype_vseq = (_bits & 0xF) # data, 1=voice header, 2=voice terminator; voice, 0=burst A ... 5=burst F
|
||||
## _stream_id = _data[16:20]
|
||||
## print(_stream_id)
|
||||
##
|
||||
## print(_call_type)
|
||||
## self.dmrd_received(_peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data)
|
||||
## else:
|
||||
|
||||
self.svrd_received(_d_pkt[4:8], _d_pkt[8:])
|
||||
|
||||
#************************************************
|
||||
# HB MASTER CLASS
|
||||
#************************************************
|
||||
|
@ -229,6 +334,122 @@ class HBSYSTEM(DatagramProtocol):
|
|||
self.maintenance_loop = self.peer_maintenance_loop
|
||||
self.datagramReceived = self.peer_datagramReceived
|
||||
self.dereg = self.peer_dereg
|
||||
|
||||
def check_user_man(self, _id, server_name, peer_ip, _system):
|
||||
#Change this to a config value
|
||||
user_man_url = self._CONFIG['WEB_SERVICE']['URL']
|
||||
shared_secret = str(sha256(self._CONFIG['WEB_SERVICE']['SHARED_SECRET'].encode()).hexdigest())
|
||||
## print(int(str(int_id(_id))[:7]))
|
||||
auth_check = {
|
||||
'secret':shared_secret,
|
||||
'login_id':int(str(int_id(_id))[:7]),
|
||||
'login_ip': peer_ip,
|
||||
'login_server': server_name,
|
||||
'system': _system
|
||||
}
|
||||
json_object = json.dumps(auth_check, indent = 4)
|
||||
try:
|
||||
req = requests.post(user_man_url, data=json_object, headers={'Content-Type': 'application/json'})
|
||||
resp = json.loads(req.text)
|
||||
print(resp)
|
||||
return resp
|
||||
except requests.ConnectionError:
|
||||
return {'allow':True}
|
||||
|
||||
# Sends login confirmation for log
|
||||
def send_login_conf(self, _id, server_name, peer_ip, old_auth):
|
||||
#Change this to a config value
|
||||
user_man_url = self._CONFIG['WEB_SERVICE']['URL']
|
||||
shared_secret = str(sha256(self._CONFIG['WEB_SERVICE']['SHARED_SECRET'].encode()).hexdigest())
|
||||
#print(int(str(int_id(_id))[:7]))
|
||||
auth_conf = {
|
||||
'secret':shared_secret,
|
||||
'login_id':int(str(int_id(_id))[:7]),
|
||||
'login_ip': peer_ip,
|
||||
'login_server': server_name,
|
||||
'login_confirmed': True,
|
||||
'old_auth': old_auth
|
||||
}
|
||||
## print(auth_conf)
|
||||
json_object = json.dumps(auth_conf, indent = 4)
|
||||
try:
|
||||
req = requests.post(user_man_url, data=json_object, headers={'Content-Type': 'application/json'})
|
||||
# resp = json.loads(req.text)
|
||||
#return resp
|
||||
except Exception as e:
|
||||
logger.info(e)
|
||||
# Sends PEER info for map and other stuff
|
||||
def send_peer_loc(self, _id, call, lat, lon, url, description, loc, soft):
|
||||
#Change this to a config value
|
||||
user_man_url = self._CONFIG['WEB_SERVICE']['URL']
|
||||
shared_secret = str(sha256(self._CONFIG['WEB_SERVICE']['SHARED_SECRET'].encode()).hexdigest())
|
||||
peer_loc_conf = {
|
||||
'secret':shared_secret,
|
||||
'loc_callsign':re.sub("b'|'|\s\s+", '', str(call)),
|
||||
'dmr_id' : int(str(int_id(_id))),
|
||||
'lat': re.sub("b'|'|\s\s\s+", '', str(lat)),
|
||||
'lon': re.sub("b'|'|\s\s\s+", '', str(lon)),
|
||||
'url': re.sub("b'|'|\s\s\s+", '', str(url)),
|
||||
'description': re.sub("b'|'|\s\s+", '', str(description)),
|
||||
'loc' : re.sub("b'|'|\s\s+", '', str(loc)),
|
||||
'software': re.sub("b'|'|\s\s+", '', str(soft))
|
||||
}
|
||||
json_object = json.dumps(peer_loc_conf, indent = 4)
|
||||
print(json_object)
|
||||
try:
|
||||
req = requests.post(user_man_url, data=json_object, headers={'Content-Type': 'application/json'})
|
||||
# resp = json.loads(req.text)
|
||||
#return resp
|
||||
except Exception as e:
|
||||
logger.info(e)
|
||||
|
||||
def calc_passphrase(self, peer_id, _salt_str):
|
||||
burn_id = ast.literal_eval(os.popen('cat ' + self._CONFIG['WEB_SERVICE']['BURN_FILE']).read())
|
||||
peer_id_trimmed = int(str(int_id(peer_id))[:7])
|
||||
try:
|
||||
## print(self.ums_response)
|
||||
if self.ums_response['mode'] == 'legacy':
|
||||
_calc_hash = bhex(sha256(_salt_str+self._config['PASSPHRASE']).hexdigest())
|
||||
calc_passphrase = self._config['PASSPHRASE']
|
||||
if self.ums_response['mode'] == 'override':
|
||||
_calc_hash = bhex(sha256(_salt_str+str.encode(self.ums_response['value'])).hexdigest())
|
||||
if self.ums_response['mode'] == 'normal':
|
||||
_new_peer_id = bytes_4(int(str(int_id(peer_id))[:7]))
|
||||
peer_id_trimmed = str(peer_id_trimmed)
|
||||
try:
|
||||
if burn_id[peer_id_trimmed]:
|
||||
logger.info('User ID has been burned. Requiring passphrase version: ' + str(burn_id[peer_id_trimmed]))
|
||||
calc_passphrase = sha256(str(self._CONFIG['WEB_SERVICE']['EXTRA_1']).encode() + str(self._CONFIG['WEB_SERVICE']['EXTRA_INT_1']).encode() + str(_new_peer_id).encode()[-3:]).hexdigest().upper().encode()[::14] + base64.b64encode(bytes.fromhex(str(hex(libscrc.ccitt((_new_peer_id) + burn_id[peer_id_trimmed].to_bytes(2, 'big') + self._CONFIG['WEB_SERVICE']['BURN_INT'].to_bytes(2, 'big') + self._CONFIG['WEB_SERVICE']['APPEND_INT'].to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + burn_id[peer_id_trimmed].to_bytes(2, 'big') + self._CONFIG['WEB_SERVICE']['BURN_INT'].to_bytes(2, 'big') + self._CONFIG['WEB_SERVICE']['APPEND_INT'].to_bytes(2, 'big'))))[2:].zfill(8)))))[2:].zfill(4)) + (_new_peer_id) + burn_id[peer_id_trimmed].to_bytes(2, 'big') + self._CONFIG['WEB_SERVICE']['BURN_INT'].to_bytes(2, 'big') + self._CONFIG['WEB_SERVICE']['APPEND_INT'].to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + burn_id[peer_id_trimmed].to_bytes(2, 'big') + self._CONFIG['WEB_SERVICE']['BURN_INT'].to_bytes(2, 'big') + self._CONFIG['WEB_SERVICE']['APPEND_INT'].to_bytes(2, 'big'))))[2:].zfill(8)))+ sha256(str(self._CONFIG['WEB_SERVICE']['EXTRA_2']).encode() + str(self._CONFIG['WEB_SERVICE']['EXTRA_INT_2']).encode() + str(_new_peer_id).encode()[-3:]).hexdigest().upper().encode()[::14]
|
||||
except:
|
||||
# + base64.b64encode(str.encode(str(_new_peer_id) + self._CONFIG['WEB_SERVICE']['EXTRA_3'] + str(self._CONFIG['WEB_SERVICE']['EXTRA_INT_1'] - self._CONFIG['WEB_SERVICE']['APPEND_INT']) + str(_new_peer_id) + self._CONFIG['WEB_SERVICE']['EXTRA_2']))
|
||||
calc_passphrase = sha256(str(self._CONFIG['WEB_SERVICE']['EXTRA_1']).encode() + str(self._CONFIG['WEB_SERVICE']['EXTRA_INT_1']).encode() + str(_new_peer_id).encode()[-3:]).hexdigest().upper().encode()[::14] + base64.b64encode(bytes.fromhex(str(hex(libscrc.ccitt((_new_peer_id) + self._CONFIG['WEB_SERVICE']['APPEND_INT'].to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + self._CONFIG['WEB_SERVICE']['APPEND_INT'].to_bytes(2, 'big'))))[2:].zfill(8)))))[2:].zfill(4)) + (_new_peer_id) + self._CONFIG['WEB_SERVICE']['APPEND_INT'].to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + self._CONFIG['WEB_SERVICE']['APPEND_INT'].to_bytes(2, 'big'))))[2:].zfill(8))) + sha256(str(self._CONFIG['WEB_SERVICE']['EXTRA_2']).encode() + str(self._CONFIG['WEB_SERVICE']['EXTRA_INT_2']).encode() + str(_new_peer_id).encode()[-3:]).hexdigest().upper().encode()[::14]
|
||||
## print(base64.b64encode(calc_passphrase))
|
||||
if self._CONFIG['WEB_SERVICE']['SHORTEN_PASSPHRASE'] == True:
|
||||
## print(calc_passphrase)
|
||||
calc_passphrase = calc_passphrase[::int(self._CONFIG['WEB_SERVICE']['SHORTEN_SAMPLE'])][-int(self._CONFIG['WEB_SERVICE']['SHORTEN_LENGTH']):]
|
||||
if self._CONFIG['WEB_SERVICE']['SHORTEN_PASSPHRASE'] == False:
|
||||
pass
|
||||
_calc_hash = bhex(sha256(_salt_str+calc_passphrase).hexdigest())
|
||||
#If exception, assume UMS down and default to calculated passphrase
|
||||
except Exception as e:
|
||||
logger.info('Execption, Web Service possibly down')
|
||||
_new_peer_id = bytes_4(int(str(int_id(peer_id))[:7]))
|
||||
if peer_id_trimmed in burn_id:
|
||||
logger.info('User ID has been burned. Requiring passphrase version: ' + str(burn_id[peer_id_trimmed]))
|
||||
calc_passphrase = sha256(str(self._CONFIG['WEB_SERVICE']['EXTRA_1']).encode() + str(self._CONFIG['WEB_SERVICE']['EXTRA_INT_1']).encode() + str(_new_peer_id).encode()[-3:]).hexdigest().upper().encode()[::14] + base64.b64encode(bytes.fromhex(str(hex(libscrc.ccitt((_new_peer_id) + burn_id[peer_id_trimmed].to_bytes(2, 'big') + self._CONFIG['WEB_SERVICE']['BURN_INT'].to_bytes(2, 'big') + self._CONFIG['WEB_SERVICE']['APPEND_INT'].to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + burn_id[peer_id_trimmed].to_bytes(2, 'big') + self._CONFIG['WEB_SERVICE']['BURN_INT'].to_bytes(2, 'big') + self._CONFIG['WEB_SERVICE']['APPEND_INT'].to_bytes(2, 'big'))))[2:].zfill(8)))))[2:].zfill(4)) + (_new_peer_id) + burn_id[peer_id_trimmed].to_bytes(2, 'big') + self._CONFIG['WEB_SERVICE']['BURN_INT'].to_bytes(2, 'big') + self._CONFIG['WEB_SERVICE']['APPEND_INT'].to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + burn_id[peer_id_trimmed].to_bytes(2, 'big') + self._CONFIG['WEB_SERVICE']['BURN_INT'].to_bytes(2, 'big') + self._CONFIG['WEB_SERVICE']['APPEND_INT'].to_bytes(2, 'big'))))[2:].zfill(8))) + sha256(str(self._CONFIG['WEB_SERVICE']['EXTRA_2']).encode() + str(self._CONFIG['WEB_SERVICE']['EXTRA_INT_2']).encode() + str(_new_peer_id).encode()[-3:]).hexdigest().upper().encode()[::14]
|
||||
else:
|
||||
calc_passphrase = sha256(str(self._CONFIG['WEB_SERVICE']['EXTRA_1']).encode() + str(self._CONFIG['WEB_SERVICE']['EXTRA_INT_1']).encode() + str(_new_peer_id).encode()[-3:]).hexdigest().upper().encode()[::14] + base64.b64encode(bytes.fromhex(str(hex(libscrc.ccitt((_new_peer_id) + self._CONFIG['WEB_SERVICE']['APPEND_INT'].to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + self._CONFIG['WEB_SERVICE']['APPEND_INT'].to_bytes(2, 'big'))))[2:].zfill(8)))))[2:].zfill(4)) + (_new_peer_id) + self._CONFIG['WEB_SERVICE']['APPEND_INT'].to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + self._CONFIG['WEB_SERVICE']['APPEND_INT'].to_bytes(2, 'big'))))[2:].zfill(8))) + sha256(str(self._CONFIG['WEB_SERVICE']['EXTRA_2']).encode() + str(self._CONFIG['WEB_SERVICE']['EXTRA_INT_2']).encode() + str(_new_peer_id).encode()[-3:]).hexdigest().upper().encode()[::14]
|
||||
|
||||
#calc_passphrase = base64.b64encode(bytes.fromhex(str(hex(libscrc.ccitt((_new_peer_id) + self._CONFIG['WEB_SERVICE']['APPEND_INT'].to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + self._CONFIG['WEB_SERVICE']['APPEND_INT'].to_bytes(2, 'big'))))[2:].zfill(8)))))[2:].zfill(4)) + (_new_peer_id) + self._CONFIG['WEB_SERVICE']['APPEND_INT'].to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + self._CONFIG['WEB_SERVICE']['APPEND_INT'].to_bytes(2, 'big'))))[2:].zfill(8)))
|
||||
if self._CONFIG['WEB_SERVICE']['SHORTEN_PASSPHRASE'] == True:
|
||||
calc_passphrase = calc_passphrase[::int(self._CONFIG['WEB_SERVICE']['SHORTEN_SAMPLE'])][-int(self._CONFIG['WEB_SERVICE']['SHORTEN_LENGTH']):]
|
||||
if self._CONFIG['WEB_SERVICE']['SHORTEN_PASSPHRASE'] == False:
|
||||
pass
|
||||
_calc_hash = bhex(sha256(_salt_str+calc_passphrase).hexdigest())
|
||||
## print(calc_passphrase)
|
||||
# print(_calc_hash)
|
||||
return _calc_hash
|
||||
|
||||
|
||||
def startProtocol(self):
|
||||
# Set up periodic loop for tracking pings from peers. Run every 'PING_TIME' seconds
|
||||
|
@ -315,6 +536,9 @@ class HBSYSTEM(DatagramProtocol):
|
|||
def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data):
|
||||
pass
|
||||
|
||||
def mmdvm_cmd(self, _cmd):
|
||||
pass
|
||||
|
||||
def master_dereg(self):
|
||||
for _peer in self._peers:
|
||||
self.send_peer(_peer, MSTCL + _peer)
|
||||
|
@ -331,6 +555,7 @@ class HBSYSTEM(DatagramProtocol):
|
|||
|
||||
# Extract the command, which is various length, all but one 4 significant characters -- RPTCL
|
||||
_command = _data[:4]
|
||||
## print(self._config)
|
||||
|
||||
if _command == DMRD: # DMRData -- encapsulated DMR data frame
|
||||
_peer_id = _data[11:15]
|
||||
|
@ -402,11 +627,39 @@ class HBSYSTEM(DatagramProtocol):
|
|||
|
||||
elif _command == RPTL: # RPTLogin -- a repeater wants to login
|
||||
_peer_id = _data[4:8]
|
||||
print()
|
||||
print((self._config['REG_ACL']))
|
||||
print()
|
||||
# Check to see if we've reached the maximum number of allowed peers
|
||||
if len(self._peers) < self._config['MAX_PEERS']:
|
||||
# Check for valid Radio ID
|
||||
if acl_check(_peer_id, self._CONFIG['GLOBAL']['REG_ACL']) and acl_check(_peer_id, self._config['REG_ACL']):
|
||||
# Build the configuration data strcuture for the peer
|
||||
#print(self.check_user_man(_peer_id))
|
||||
if self._config['USE_USER_MAN'] == True:
|
||||
self.ums_response = self.check_user_man(_peer_id, self._CONFIG['WEB_SERVICE']['THIS_SERVER_NAME'], _sockaddr[0], self._system)
|
||||
## print(self.ums_response)
|
||||
#Will allow anyone to attempt authentication, used for a transition period
|
||||
## if acl_check(_peer_id, self._CONFIG['GLOBAL']['REG_ACL']) and self.ums_response['allow'] or acl_check(_peer_id, self._CONFIG['GLOBAL']['REG_ACL']) and acl_check(_peer_id, self._config['REG_ACL']):
|
||||
if acl_check(_peer_id, self._CONFIG['GLOBAL']['REG_ACL']) and self.ums_response['allow']:
|
||||
user_auth = self.ums_response['allow']
|
||||
else:
|
||||
user_auth = False
|
||||
elif self._config['USE_USER_MAN'] == False:
|
||||
print('False')
|
||||
b_acl = self._config['REG_ACL']
|
||||
if self._CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] == True:
|
||||
# If UMS is False, and Rmote Confir True
|
||||
if acl_check(_peer_id, self._CONFIG['GLOBAL']['REG_ACL']) and acl_check(_peer_id, self._config['REG_ACL']):
|
||||
user_auth = True
|
||||
print(self._CONFIG['GLOBAL']['REG_ACL'])
|
||||
else:
|
||||
user_auth = False
|
||||
#If UMS and Remot Config False
|
||||
elif self._CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] == False:
|
||||
user_auth = False
|
||||
if acl_check(_peer_id, self._CONFIG['GLOBAL']['REG_ACL']) and acl_check(_peer_id, b_acl):#acl_check(_peer_id, b_acl):
|
||||
user_auth = True
|
||||
if user_auth == True:
|
||||
# Build the configuration data strcuture for the peer
|
||||
self._peers.update({_peer_id: {
|
||||
'CONNECTION': 'RPTL-RECEIVED',
|
||||
'CONNECTED': time(),
|
||||
|
@ -437,6 +690,7 @@ class HBSYSTEM(DatagramProtocol):
|
|||
self.send_peer(_peer_id, b''.join([RPTACK, _salt_str]))
|
||||
self._peers[_peer_id]['CONNECTION'] = 'CHALLENGE_SENT'
|
||||
logger.info('(%s) Sent Challenge Response to %s for login: %s', self._system, int_id(_peer_id), self._peers[_peer_id]['SALT'])
|
||||
## print(self._peers)
|
||||
else:
|
||||
self.transport.write(b''.join([MSTNAK, _peer_id]), _sockaddr)
|
||||
logger.warning('(%s) Invalid Login from %s Radio ID: %s Denied by Registation ACL', self._system, _sockaddr[0], int_id(_peer_id))
|
||||
|
@ -453,11 +707,27 @@ class HBSYSTEM(DatagramProtocol):
|
|||
_this_peer['LAST_PING'] = time()
|
||||
_sent_hash = _data[8:]
|
||||
_salt_str = bytes_4(_this_peer['SALT'])
|
||||
_calc_hash = bhex(sha256(_salt_str+self._config['PASSPHRASE']).hexdigest())
|
||||
# Used to allow config passphrase AND calculated.
|
||||
_ocalc_hash = bhex(sha256(_salt_str+self._config['PASSPHRASE']).hexdigest())
|
||||
|
||||
#print(self.ums_response)
|
||||
if self._config['USE_USER_MAN'] == True:
|
||||
# print(self.calc_passphrase(_peer_id, _salt_str))
|
||||
_calc_hash = self.calc_passphrase(_peer_id, _salt_str)
|
||||
if self._config['USE_USER_MAN'] == False:
|
||||
_calc_hash = bhex(sha256(_salt_str+self._config['PASSPHRASE']).hexdigest())
|
||||
# Uncomment below to only accept calculated passphrase
|
||||
if _sent_hash == _calc_hash:
|
||||
# Condition below accepts either calculated passphrase or config passphrase
|
||||
## if _sent_hash == _calc_hash or _sent_hash == _ocalc_hash:
|
||||
_this_peer['CONNECTION'] = 'WAITING_CONFIG'
|
||||
self.send_peer(_peer_id, b''.join([RPTACK, _peer_id]))
|
||||
logger.info('(%s) Peer %s has completed the login exchange successfully', self._system, _this_peer['RADIO_ID'])
|
||||
self.send_login_conf(_peer_id, self._CONFIG['WEB_SERVICE']['THIS_SERVER_NAME'], _sockaddr[0], False)
|
||||
## if _sent_hash == _ocalc_hash:
|
||||
## self.send_login_conf(_peer_id, self._CONFIG['WEB_SERVICE']['THIS_SERVER_NAME'], _sockaddr[0], True)
|
||||
## else:
|
||||
## self.send_login_conf(_peer_id, self._CONFIG['WEB_SERVICE']['THIS_SERVER_NAME'], _sockaddr[0], False)
|
||||
else:
|
||||
logger.info('(%s) Peer %s has FAILED the login exchange successfully', self._system, _this_peer['RADIO_ID'])
|
||||
self.transport.write(b''.join([MSTNAK, _peer_id]), _sockaddr)
|
||||
|
@ -474,6 +744,7 @@ class HBSYSTEM(DatagramProtocol):
|
|||
and self._peers[_peer_id]['SOCKADDR'] == _sockaddr:
|
||||
logger.info('(%s) Peer is closing down: %s (%s)', self._system, self._peers[_peer_id]['CALLSIGN'], int_id(_peer_id))
|
||||
self.transport.write(b''.join([MSTNAK, _peer_id]), _sockaddr)
|
||||
self.send_peer_loc(_peer_id, self._peers[_peer_id]['CALLSIGN'], '*', '*', '*', '*', '*', '*')
|
||||
del self._peers[_peer_id]
|
||||
|
||||
else:
|
||||
|
@ -502,6 +773,12 @@ class HBSYSTEM(DatagramProtocol):
|
|||
|
||||
self.send_peer(_peer_id, b''.join([RPTACK, _peer_id]))
|
||||
logger.info('(%s) Peer %s (%s) has sent repeater configuration', self._system, _this_peer['CALLSIGN'], _this_peer['RADIO_ID'])
|
||||
if 'NO_MAP' in str(_this_peer['LOCATION']):
|
||||
self.send_peer_loc(_peer_id, self._peers[_peer_id]['CALLSIGN'], '*', '*', '*', '*', '*', '*')
|
||||
## print(_this_peer['LOCATION'])
|
||||
## pass
|
||||
else:
|
||||
self.send_peer_loc(_peer_id, _this_peer['CALLSIGN'], _this_peer['LATITUDE'], _this_peer['LONGITUDE'], _this_peer['URL'], _this_peer['DESCRIPTION'], _this_peer['LOCATION'], str(_this_peer['PACKAGE_ID']) + ' - ' + str(_this_peer['SOFTWARE_ID']))
|
||||
else:
|
||||
self.transport.write(b''.join([MSTNAK, _peer_id]), _sockaddr)
|
||||
logger.warning('(%s) Peer info from Radio ID that has not logged in: %s', self._system, int_id(_peer_id))
|
||||
|
@ -525,6 +802,10 @@ class HBSYSTEM(DatagramProtocol):
|
|||
and self._peers[_peer_id]['CONNECTION'] == 'YES' \
|
||||
and self._peers[_peer_id]['SOCKADDR'] == _sockaddr:
|
||||
logger.info('(%s) Peer %s (%s) has send options: %s', self._system, self._peers[_peer_id]['CALLSIGN'], int_id(_peer_id), _data[8:])
|
||||
# Send remove from map command
|
||||
## self.mmdvm_cmd(_data)
|
||||
if 'NO_MAP' in str(_data[8:]):
|
||||
self.send_peer_loc(_peer_id, self._peers[_peer_id]['CALLSIGN'], '*', '*', '*', '*', '*', '*')
|
||||
self.transport.write(b''.join([RPTACK, _peer_id]), _sockaddr)
|
||||
|
||||
elif _command == DMRA:
|
||||
|
@ -818,6 +1099,7 @@ if __name__ == '__main__':
|
|||
|
||||
peer_ids, subscriber_ids, talkgroup_ids = mk_aliases(CONFIG)
|
||||
|
||||
|
||||
# INITIALIZE THE REPORTING LOOP
|
||||
if CONFIG['REPORTS']['REPORT']:
|
||||
report_server = config_reports(CONFIG, reportFactory)
|
||||
|
@ -836,4 +1118,8 @@ if __name__ == '__main__':
|
|||
reactor.listenUDP(CONFIG['SYSTEMS'][system]['PORT'], systems[system], interface=CONFIG['SYSTEMS'][system]['IP'])
|
||||
logger.debug('(GLOBAL) %s instance created: %s, %s', CONFIG['SYSTEMS'][system]['MODE'], system, systems[system])
|
||||
|
||||
# Download burn list
|
||||
with open(CONFIG['WEB_SERVICE']['BURN_FILE'], 'w') as f:
|
||||
f.write(str(download_burnlist(CONFIG)))
|
||||
|
||||
reactor.run()
|
||||
|
|
|
@ -0,0 +1,214 @@
|
|||
from twisted.internet.protocol import DatagramProtocol
|
||||
from twisted.internet import reactor, task
|
||||
from time import time
|
||||
from resettabletimer import ResettableTimer
|
||||
from dmr_utils3.utils import int_id
|
||||
import random
|
||||
|
||||
# Does anybody read this stuff? There's a PEP somewhere that says I should do this.
|
||||
__author__ = 'Simon Adlem - G7RZU'
|
||||
__copyright__ = 'Copyright (c) Simon Adlem, G7RZU 2020,2021'
|
||||
__credits__ = 'Jon Lee, G4TSN; Norman Williams, M6NBP'
|
||||
__license__ = 'GNU GPLv3'
|
||||
__maintainer__ = 'Simon Adlem G7RZU'
|
||||
__email__ = 'simon@gb7fr.org.uk'
|
||||
|
||||
class Proxy(DatagramProtocol):
|
||||
|
||||
def __init__(self,Master,ListenPort,connTrack,blackList,Timeout,Debug,DestportStart,DestPortEnd):
|
||||
self.master = Master
|
||||
self.connTrack = connTrack
|
||||
self.peerTrack = {}
|
||||
self.timeout = Timeout
|
||||
self.debug = Debug
|
||||
self.blackList = blackList
|
||||
self.destPortStart = DestportStart
|
||||
self.destPortEnd = DestPortEnd
|
||||
self.numPorts = DestPortEnd - DestportStart
|
||||
|
||||
|
||||
def reaper(self,_peer_id):
|
||||
if self.debug:
|
||||
print("dead",_peer_id)
|
||||
self.transport.write(b'RPTCL'+_peer_id, ('127.0.0.1',self.peerTrack[_peer_id]['dport']))
|
||||
self.connTrack[self.peerTrack[_peer_id]['dport']] = False
|
||||
del self.peerTrack[_peer_id]
|
||||
|
||||
|
||||
def datagramReceived(self, data, addr):
|
||||
|
||||
# HomeBrew Protocol Commands
|
||||
DMRD = b'DMRD'
|
||||
DMRA = b'DMRA'
|
||||
MSTCL = b'MSTCL'
|
||||
MSTNAK = b'MSTNAK'
|
||||
MSTPONG = b'MSTPONG'
|
||||
MSTN = b'MSTN'
|
||||
MSTP = b'MSTP'
|
||||
MSTC = b'MSTC'
|
||||
RPTL = b'RPTL'
|
||||
RPTPING = b'RPTPING'
|
||||
RPTCL = b'RPTCL'
|
||||
RPTL = b'RPTL'
|
||||
RPTACK = b'RPTACK'
|
||||
RPTK = b'RPTK'
|
||||
RPTC = b'RPTC'
|
||||
RPTP = b'RPTP'
|
||||
RPTA = b'RPTA'
|
||||
RPTO = b'RPTO'
|
||||
|
||||
host,port = addr
|
||||
|
||||
nowtime = time()
|
||||
|
||||
Debug = self.debug
|
||||
|
||||
#If the packet comes from the master
|
||||
if host == self.master:
|
||||
_command = data[:4]
|
||||
_lng_command = data[:6]
|
||||
#### print(_lng_command)
|
||||
|
||||
|
||||
if _command == DMRD:
|
||||
_peer_id = data[11:15]
|
||||
## print(self.peerTrack[_peer_id]['timer'])
|
||||
elif _command == RPTA:
|
||||
if data[6:10] in self.peerTrack:
|
||||
_peer_id = data[6:10]
|
||||
else:
|
||||
_peer_id = self.connTrack[port]
|
||||
elif _lng_command == MSTNAK:
|
||||
_peer_id = data[6:10]
|
||||
|
||||
elif _command == MSTN and MSTNAK not in _lng_command:
|
||||
_peer_id = data[6:10]
|
||||
|
||||
self.peerTrack[_peer_id]['timer'].cancel()
|
||||
self.reaper(_peer_id)
|
||||
return
|
||||
elif _command == MSTP:
|
||||
_peer_id = data[7:11]
|
||||
## print(self.peerTrack)
|
||||
elif _command == MSTC:
|
||||
_peer_id = data[5:9]
|
||||
self.peerTrack[_peer_id]['timer'].cancel()
|
||||
self.reaper(_peer_id)
|
||||
return
|
||||
|
||||
# _peer_id = self.connTrack[port]
|
||||
if self.debug:
|
||||
print(data)
|
||||
if _peer_id and _peer_id in self.peerTrack:
|
||||
self.transport.write(data,(self.peerTrack[_peer_id]['shost'],self.peerTrack[_peer_id]['sport']))
|
||||
#self.peerTrack[_peer_id]['timer'].reset()
|
||||
return
|
||||
|
||||
|
||||
|
||||
else:
|
||||
_command = data[:4]
|
||||
|
||||
if _command == DMRD: # DMRData -- encapsulated DMR data frame
|
||||
_peer_id = data[11:15]
|
||||
elif _command == DMRA: # DMRAlias -- Talker Alias information
|
||||
_peer_id = _data[4:8]
|
||||
elif _command == RPTL: # RPTLogin -- a repeater wants to login
|
||||
_peer_id = data[4:8]
|
||||
elif _command == RPTK: # Repeater has answered our login challenge
|
||||
_peer_id = data[4:8]
|
||||
elif _command == RPTC: # Repeater is sending it's configuraiton OR disconnecting
|
||||
if data[:5] == RPTCL: # Disconnect command
|
||||
_peer_id = data[5:9]
|
||||
else:
|
||||
_peer_id = data[4:8] # Configure Command
|
||||
elif _command == RPTO: # options
|
||||
_peer_id = data[4:8]
|
||||
elif _command == RPTP: # RPTPing -- peer is pinging us
|
||||
_peer_id = data[7:11]
|
||||
else:
|
||||
return
|
||||
|
||||
if _peer_id in self.peerTrack:
|
||||
_dport = self.peerTrack[_peer_id]['dport']
|
||||
self.peerTrack[_peer_id]['sport'] = port
|
||||
self.peerTrack[_peer_id]['shost'] = host
|
||||
self.transport.write(data, ('127.0.0.1',_dport))
|
||||
self.peerTrack[_peer_id]['timer'].reset()
|
||||
if self.debug:
|
||||
print(data)
|
||||
print(_dport)
|
||||
return
|
||||
else:
|
||||
|
||||
if int_id(_peer_id) in self.blackList:
|
||||
return
|
||||
#for _dport in self.connTrack:
|
||||
while True:
|
||||
_dport = random.randint(1,(self.numPorts - 1))
|
||||
_dport = _dport + self.destPortStart
|
||||
if not self.connTrack[_dport]:
|
||||
break
|
||||
self.connTrack[_dport] = _peer_id
|
||||
self.peerTrack[_peer_id] = {}
|
||||
self.peerTrack[_peer_id]['dport'] = _dport
|
||||
self.peerTrack[_peer_id]['sport'] = port
|
||||
self.peerTrack[_peer_id]['shost'] = host
|
||||
self.peerTrack[_peer_id]['timer'] = ResettableTimer(self.timeout,self.reaper,[_peer_id])
|
||||
self.peerTrack[_peer_id]['timer'].start()
|
||||
self.transport.write(data, (self.master,_dport))
|
||||
if self.debug:
|
||||
print(data)
|
||||
|
||||
return
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
#*** CONFIG HERE ***
|
||||
|
||||
Master = "127.0.0.1"
|
||||
ListenPort = 62031
|
||||
DestportStart = 54100
|
||||
DestPortEnd = 54102
|
||||
Timeout = 30
|
||||
Stats = True
|
||||
Debug = True
|
||||
BlackList = [1234567]
|
||||
|
||||
#*******************
|
||||
|
||||
|
||||
CONNTRACK = {}
|
||||
|
||||
for port in range(DestportStart,DestPortEnd+1,1):
|
||||
CONNTRACK[port] = False
|
||||
|
||||
|
||||
reactor.listenUDP(ListenPort,Proxy(Master,ListenPort,CONNTRACK,BlackList,Timeout,Debug,DestportStart,DestPortEnd))
|
||||
|
||||
def loopingErrHandle(failure):
|
||||
print('(GLOBAL) STOPPING REACTOR TO AVOID MEMORY LEAK: Unhandled error innowtimed loop.\n {}'.format(failure))
|
||||
reactor.stop()
|
||||
|
||||
def stats():
|
||||
count = 0
|
||||
nowtime = time()
|
||||
for port in CONNTRACK:
|
||||
if CONNTRACK[port]:
|
||||
count = count+1
|
||||
|
||||
totalPorts = DestPortEnd - DestportStart
|
||||
freePorts = totalPorts - count
|
||||
|
||||
print("{} ports out of {} in use ({} free)".format(count,totalPorts,freePorts))
|
||||
|
||||
|
||||
|
||||
if Stats == True:
|
||||
stats_task = task.LoopingCall(stats)
|
||||
statsa = stats_task.start(30)
|
||||
statsa.addErrback(loopingErrHandle)
|
||||
|
||||
reactor.run()
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
#! /bin/bash
|
||||
|
||||
# Install the required support programs
|
||||
apt-get install python3 python3-pip -y
|
||||
pip3 install -r requirements.txt
|
|
@ -0,0 +1,10 @@
|
|||
# Script to generate a key for Encrypted OpenBridge
|
||||
|
||||
from cryptography.fernet import Fernet
|
||||
import re
|
||||
|
||||
def gen_key():
|
||||
key = Fernet.generate_key()
|
||||
return key
|
||||
|
||||
print('Key: ' + str(gen_key())[2:-1])
|
209
playback.cfg
209
playback.cfg
|
@ -1,209 +0,0 @@
|
|||
# PROGRAM-WIDE PARAMETERS GO HERE
|
||||
# PATH - working path for files, leave it alone unless you NEED to change it
|
||||
# PING_TIME - the interval that peers will ping the master, and re-try registraion
|
||||
# - how often the Master maintenance loop runs
|
||||
# MAX_MISSED - how many pings are missed before we give up and re-register
|
||||
# - number of times the master maintenance loop runs before de-registering a peer
|
||||
#
|
||||
# ACLs:
|
||||
#
|
||||
# Access Control Lists are a very powerful tool for administering your system.
|
||||
# But they consume packet processing time. Disable them if you are not using them.
|
||||
# But be aware that, as of now, the configuration stanzas still need the ACL
|
||||
# sections configured even if you're not using them.
|
||||
#
|
||||
# REGISTRATION ACLS ARE ALWAYS USED, ONLY SUBSCRIBER AND TGID MAY BE DISABLED!!!
|
||||
#
|
||||
# The 'action' May be PERMIT|DENY
|
||||
# Each entry may be a single radio id, or a hypenated range (e.g. 1-2999)
|
||||
# Format:
|
||||
# ACL = 'action:id|start-end|,id|start-end,....'
|
||||
# --for example--
|
||||
# SUB_ACL: DENY:1,1000-2000,4500-60000,17
|
||||
#
|
||||
# ACL Types:
|
||||
# REG_ACL: peer radio IDs for registration (only used on HBP master systems)
|
||||
# SUB_ACL: subscriber IDs for end-users
|
||||
# TGID_TS1_ACL: destination talkgroup IDs on Timeslot 1
|
||||
# TGID_TS2_ACL: destination talkgroup IDs on Timeslot 2
|
||||
#
|
||||
# ACLs may be repeated for individual systems if needed for granularity
|
||||
# Global ACLs will be processed BEFORE the system level ACLs
|
||||
# Packets will be matched against all ACLs, GLOBAL first. If a packet 'passes'
|
||||
# All elements, processing continues. Packets are discarded at the first
|
||||
# negative match, or 'reject' from an ACL element.
|
||||
#
|
||||
# If you do not wish to use ACLs, set them to 'PERMIT:ALL'
|
||||
# TGID_TS1_ACL in the global stanza is used for OPENBRIDGE systems, since all
|
||||
# traffic is passed as TS 1 between OpenBridges
|
||||
[GLOBAL]
|
||||
PATH: ./
|
||||
PING_TIME: 5
|
||||
MAX_MISSED: 3
|
||||
USE_ACL: True
|
||||
REG_ACL: PERMIT:ALL
|
||||
SUB_ACL: DENY:1
|
||||
TGID_TS1_ACL: PERMIT:ALL
|
||||
TGID_TS2_ACL: PERMIT:ALL
|
||||
|
||||
|
||||
# NOT YET WORKING: NETWORK REPORTING CONFIGURATION
|
||||
# Enabling "REPORT" will configure a socket-based reporting
|
||||
# system that will send the configuration and other items
|
||||
# to a another process (local or remote) that may process
|
||||
# the information for some useful purpose, like a web dashboard.
|
||||
#
|
||||
# REPORT - True to enable, False to disable
|
||||
# REPORT_INTERVAL - Seconds between reports
|
||||
# REPORT_PORT - TCP port to listen on if "REPORT_NETWORKS" = NETWORK
|
||||
# REPORT_CLIENTS - comma separated list of IPs you will allow clients
|
||||
# to connect on. Entering a * will allow all.
|
||||
#
|
||||
# ****FOR NOW MUST BE TRUE - USE THE LOOPBACK IF YOU DON'T USE THIS!!!****
|
||||
[REPORTS]
|
||||
REPORT: True
|
||||
REPORT_INTERVAL: 60
|
||||
REPORT_PORT: 4322
|
||||
REPORT_CLIENTS: 127.0.0.1
|
||||
|
||||
|
||||
# SYSTEM LOGGER CONFIGURAITON
|
||||
# This allows the logger to be configured without chaning the individual
|
||||
# python logger stuff. LOG_FILE should be a complete path/filename for *your*
|
||||
# system -- use /dev/null for non-file handlers.
|
||||
# LOG_HANDLERS may be any of the following, please, no spaces in the
|
||||
# list if you use several:
|
||||
# null
|
||||
# console
|
||||
# console-timed
|
||||
# file
|
||||
# file-timed
|
||||
# syslog
|
||||
# LOG_LEVEL may be any of the standard syslog logging levels, though
|
||||
# as of now, DEBUG, INFO, WARNING and CRITICAL are the only ones
|
||||
# used.
|
||||
#
|
||||
[LOGGER]
|
||||
LOG_FILE: /tmp/hb-playback.log
|
||||
LOG_HANDLERS: console
|
||||
LOG_LEVEL: DEBUG
|
||||
LOG_NAME: HBlink3 Playback
|
||||
|
||||
# DOWNLOAD AND IMPORT SUBSCRIBER, PEER and TGID ALIASES
|
||||
# Ok, not the TGID, there's no master list I know of to download
|
||||
# This is intended as a facility for other applcations built on top of
|
||||
# HBlink to use, and will NOT be used in HBlink directly.
|
||||
# STALE_DAYS is the number of days since the last download before we
|
||||
# download again. Don't be an ass and change this to less than a few days.
|
||||
[ALIASES]
|
||||
TRY_DOWNLOAD: False
|
||||
PATH: ./
|
||||
PEER_FILE: peer_ids.json
|
||||
SUBSCRIBER_FILE: subscriber_ids.json
|
||||
TGID_FILE: talkgroup_ids.json
|
||||
PEER_URL: https://www.radioid.net/static/rptrs.json
|
||||
SUBSCRIBER_URL: https://www.radioid.net/static/users.json
|
||||
STALE_DAYS: 7
|
||||
|
||||
# OPENBRIDGE INSTANCES - DUPLICATE SECTION FOR MULTIPLE CONNECTIONS
|
||||
# OpenBridge is a protocol originall created by DMR+ for connection between an
|
||||
# IPSC2 server and Brandmeister. It has been implemented here at the suggestion
|
||||
# of the Brandmeister team as a way to legitimately connect HBlink to the
|
||||
# Brandemiester network.
|
||||
# It is recommended to name the system the ID of the Brandmeister server that
|
||||
# it connects to, but is not necessary. TARGET_IP and TARGET_PORT are of the
|
||||
# Brandmeister or IPSC2 server you are connecting to. PASSPHRASE is the password
|
||||
# that must be agreed upon between you and the operator of the server you are
|
||||
# connecting to. NETWORK_ID is a number in the format of a DMR Radio ID that
|
||||
# will be sent to the other server to identify this connection.
|
||||
# other parameters follow the other system types.
|
||||
#
|
||||
# ACLs:
|
||||
# OpenBridge does not 'register', so registration ACL is meaningless.
|
||||
# OpenBridge passes all traffic on TS1, so there is only 1 TGID ACL.
|
||||
# Otherwise ACLs work as described in the global stanza
|
||||
#[OBP-1]
|
||||
#MODE: OPENBRIDGE
|
||||
#ENABLED: True
|
||||
#IP:
|
||||
#PORT: 62035
|
||||
#NETWORK_ID: 3129100
|
||||
#PASSPHRASE: password
|
||||
#TARGET_IP: 1.2.3.4
|
||||
#TARGET_PORT: 62035
|
||||
#USE_ACL: True
|
||||
#SUB_ACL: DENY:1
|
||||
#TGID_ACL: PERMIT:ALL
|
||||
|
||||
# MASTER INSTANCES - DUPLICATE SECTION FOR MULTIPLE MASTERS
|
||||
# HomeBrew Protocol Master instances go here.
|
||||
# IP may be left blank if there's one interface on your system.
|
||||
# Port should be the port you want this master to listen on. It must be unique
|
||||
# and unused by anything else.
|
||||
# Repeat - if True, the master repeats traffic to peers, False, it does nothing.
|
||||
#
|
||||
# MAX_PEERS -- maximun number of peers that may be connect to this master
|
||||
# at any given time. This is very handy if you're allowing hotspots to
|
||||
# connect, or using a limited computer like a Raspberry Pi.
|
||||
#
|
||||
# ACLs:
|
||||
# See comments in the GLOBAL stanza
|
||||
[MASTER]
|
||||
MODE: MASTER
|
||||
ENABLED: True
|
||||
REPEAT: True
|
||||
MAX_PEERS: 1
|
||||
EXPORT_AMBE: False
|
||||
IP:
|
||||
PORT: 54072
|
||||
PASSPHRASE: passw0rd
|
||||
GROUP_HANGTIME: 5
|
||||
USE_ACL: True
|
||||
REG_ACL: DENY:1
|
||||
SUB_ACL: DENY:1
|
||||
TGID_TS1_ACL: PERMIT:ALL
|
||||
TGID_TS2_ACL: PERMIT:ALL
|
||||
|
||||
# PEER INSTANCES - DUPLICATE SECTION FOR MULTIPLE PEERS
|
||||
# There are a LOT of errors in the HB Protocol specifications on this one!
|
||||
# MOST of these items are just strings and will be properly dealt with by the program
|
||||
# The TX & RX Frequencies are 9-digit numbers, and are the frequency in Hz.
|
||||
# Latitude is an 8-digit unsigned floating point number.
|
||||
# Longitude is a 9-digit signed floating point number.
|
||||
# Height is in meters
|
||||
# Setting Loose to True relaxes the validation on packets received from the master.
|
||||
# This will allow HBlink to connect to a non-compliant system such as XLXD, DMR+ etc.
|
||||
#
|
||||
# ACLs:
|
||||
# See comments in the GLOBAL stanza
|
||||
#[REPEATER-1]
|
||||
#MODE: PEER
|
||||
#ENABLED: True
|
||||
#LOOSE: False
|
||||
#EXPORT_AMBE: False
|
||||
#IP:
|
||||
#PORT: 54001
|
||||
#MASTER_IP: 172.16.1.1
|
||||
#MASTER_PORT: 54000
|
||||
#PASSPHRASE: homebrew
|
||||
#CALLSIGN: W1ABC
|
||||
#RADIO_ID: 312000
|
||||
#RX_FREQ: 449000000
|
||||
#TX_FREQ: 444000000
|
||||
#TX_POWER: 25
|
||||
#COLORCODE: 1
|
||||
#SLOTS: 1
|
||||
#LATITUDE: 38.0000
|
||||
#LONGITUDE: -095.0000
|
||||
#HEIGHT: 75
|
||||
#LOCATION: Anywhere, USA
|
||||
#DESCRIPTION: This is a cool repeater
|
||||
#URL: www.w1abc.org
|
||||
#SOFTWARE_ID: 20170620
|
||||
#PACKAGE_ID: MMDVM_HBlink
|
||||
#GROUP_HANGTIME: 5
|
||||
#OPTIONS:
|
||||
#USE_ACL: True
|
||||
#SUB_ACL: DENY:1
|
||||
#TGID_TS1_ACL: PERMIT:ALL
|
||||
#TGID_TS2_ACL: PERMIT:ALL
|
|
@ -169,13 +169,13 @@ if __name__ == '__main__':
|
|||
|
||||
# CLI argument parser - handles picking up the config file from the command line, and sending a "help" message
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-c', '--config', action='store', dest='CONFIG_FILE', help='/full/path/to/config.file (usually playback.cfg)')
|
||||
parser.add_argument('-c', '--config', action='store', dest='CONFIG_FILE', help='/full/path/to/config.file (usually hblink.cfg)')
|
||||
parser.add_argument('-l', '--logging', action='store', dest='LOG_LEVEL', help='Override config file logging level.')
|
||||
cli_args = parser.parse_args()
|
||||
|
||||
# Ensure we have a path for the config file, if one wasn't specified, then use the default (top of file)
|
||||
if not cli_args.CONFIG_FILE:
|
||||
cli_args.CONFIG_FILE = os.path.dirname(os.path.abspath(__file__))+'/playback.cfg'
|
||||
cli_args.CONFIG_FILE = os.path.dirname(os.path.abspath(__file__))+'/hblink.cfg'
|
||||
|
||||
# Call the external routine to build the configuration dictionary
|
||||
CONFIG = config.build_config(cli_args.CONFIG_FILE)
|
||||
|
|
|
@ -6,5 +6,8 @@ configparser>=3.0.0
|
|||
aprslib>=0.6.42
|
||||
pynmea2
|
||||
maidenhead
|
||||
flask
|
||||
folium
|
||||
requests
|
||||
libscrc
|
||||
resettabletimer
|
||||
cryptography
|
||||
|
||||
|
|
|
@ -33,17 +33,17 @@ configuration file.
|
|||
'''
|
||||
|
||||
BRIDGES = {
|
||||
## 'ENGLISH': [
|
||||
## {'SYSTEM': 'CHANGE_ME-1', 'TS': 1, 'TGID': 13, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'NONE', 'ON': [3,], 'OFF': [8,10], 'RESET': []},
|
||||
## {'SYSTEM': 'CHANGE_ME-2', 'TS': 1, 'TGID': 13, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'NONE', 'ON': [3,], 'OFF': [8,10], 'RESET': []},
|
||||
## ],
|
||||
## 'STATEWIDE': [
|
||||
## {'SYSTEM': 'CHANGE_ME-1', 'TS': 2, 'TGID': 3129, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'NONE', 'ON': [4,], 'OFF': [7,10], 'RESET': []},
|
||||
## {'SYSTEM': 'CHANGE_ME-2', 'TS': 2, 'TGID': 3129, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'NONE', 'ON': [4,], 'OFF': [7,10], 'RESET': []},
|
||||
## ],
|
||||
'ECHO': [
|
||||
{'SYSTEM': 'MASTER-1', 'TS': 2, 'TGID': 9999, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'ON', 'ON': [9999,], 'OFF': [9,10], 'RESET': []},
|
||||
{'SYSTEM': 'ECHO', 'TS': 2, 'TGID': 9999, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'ON', 'ON': [9999,], 'OFF': [9,10], 'RESET': []},
|
||||
'WORLDWIDE': [
|
||||
{'SYSTEM': 'MASTER-1', 'TS': 1, 'TGID': 1, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'ON', 'ON': [2,], 'OFF': [9,10], 'RESET': []},
|
||||
{'SYSTEM': 'CLIENT-1', 'TS': 1, 'TGID': 3100, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'ON', 'ON': [2,], 'OFF': [9,10], 'RESET': []},
|
||||
],
|
||||
'ENGLISH': [
|
||||
{'SYSTEM': 'MASTER-1', 'TS': 1, 'TGID': 13, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'NONE', 'ON': [3,], 'OFF': [8,10], 'RESET': []},
|
||||
{'SYSTEM': 'CLIENT-2', 'TS': 1, 'TGID': 13, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'NONE', 'ON': [3,], 'OFF': [8,10], 'RESET': []},
|
||||
],
|
||||
'STATEWIDE': [
|
||||
{'SYSTEM': 'MASTER-1', 'TS': 2, 'TGID': 3129, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'NONE', 'ON': [4,], 'OFF': [7,10], 'RESET': []},
|
||||
{'SYSTEM': 'CLIENT-2', 'TS': 2, 'TGID': 3129, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'NONE', 'ON': [4,], 'OFF': [7,10], 'RESET': []},
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -51,29 +51,7 @@ BRIDGES = {
|
|||
list the names of each system that should bridge unit to unit (individual) calls.
|
||||
'''
|
||||
|
||||
UNIT = ['MASTER-1', 'CHANGE_ME']
|
||||
|
||||
'''
|
||||
Unit Call flood timeout:
|
||||
The amount of time to keep sending private calls to a single system before
|
||||
flooding all systems with the call. A higher value should be set for systems where subscribers
|
||||
are not moving between systems often. A lower value should be set for systems that have subscribers
|
||||
moving between systems often.
|
||||
|
||||
Time is in minutes.
|
||||
'''
|
||||
UNIT_TIME = 1
|
||||
|
||||
'''
|
||||
Input the DMR ID and SYSTEM of a subscriber that you would like to have always have private calls routed.
|
||||
This will not flood all systems.
|
||||
'''
|
||||
STATIC_UNIT = [
|
||||
# [ 456, 'CLIENT-1'],
|
||||
# [ 123, 'MASTER-1'],
|
||||
[ 9099, 'D-APRS']
|
||||
]
|
||||
|
||||
UNIT = ['ONE', 'TWO']
|
||||
|
||||
'''
|
||||
This is for testing the syntax of the file. It won't eliminate all errors, but running this file
|
||||
|
@ -84,4 +62,3 @@ if __name__ == '__main__':
|
|||
from pprint import pprint
|
||||
pprint(BRIDGES)
|
||||
print(UNIT)
|
||||
print(STATIC_UNIT)
|
||||
|
|
|
@ -1,85 +0,0 @@
|
|||
###############################################################################
|
||||
# GPS/Data - Copyright (C) 2020 Eric Craw, KF7EEL <kf7eel@qsl.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
###############################################################################
|
||||
|
||||
import aprslib
|
||||
import ast, os
|
||||
import re
|
||||
from configparser import ConfigParser
|
||||
import time
|
||||
import argparse
|
||||
|
||||
def mailbox_write(call, dmr_id, time, message, recipient):
|
||||
global mailbox_file
|
||||
mail_file = ast.literal_eval(os.popen('cat ' + parser.get('GPS_DATA', 'MAILBOX_FILE')).read())
|
||||
mail_file.insert(0, {'call': call, 'dmr_id': dmr_id, 'time': time, 'message':message, 'recipient': recipient})
|
||||
with open(parser.get('GPS_DATA', 'MAILBOX_FILE'), 'w') as mailbox_file:
|
||||
mailbox_file.write(str(mail_file[:100]))
|
||||
mailbox_file.close()
|
||||
print('User mail saved.')
|
||||
|
||||
def aprs_filter(packet):
|
||||
|
||||
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
|
||||
if 'addresse' in aprslib.parse(packet):
|
||||
#print(aprslib.parse(packet))
|
||||
recipient = re.sub('-.*','', aprslib.parse(packet)['addresse'])
|
||||
recipient_ssid = re.sub('.*-','', aprslib.parse(packet)['addresse'])
|
||||
if recipient == '':
|
||||
pass
|
||||
else:
|
||||
for i in user_settings.items():
|
||||
ssid = i[1][1]['ssid']
|
||||
if i[1][1]['ssid'] == '':
|
||||
ssid = user_aprs_ssid
|
||||
if recipient in i[1][0]['call'] and recipient_ssid in ssid:
|
||||
mailbox_write(re.sub('-.*','', aprslib.parse(packet)['addresse']), aprslib.parse(packet)['from'], time.time(), aprslib.parse(packet)['message_text'], recipient)
|
||||
if 'msgNo' in aprslib.parse(packet):
|
||||
time.sleep(1)
|
||||
AIS.sendall(aprslib.parse(packet)['addresse'] + '>APHBL3,TCPIP*:' + ':' + aprslib.parse(packet)['from'].ljust(9) +':ack'+aprslib.parse(packet)['msgNo'])
|
||||
print('Send ACK')
|
||||
print(aprslib.parse(packet)['addresse'] + '>APHBL3,TCPIP*:' + ':' + aprslib.parse(packet)['from'].ljust(9) +':ack'+aprslib.parse(packet)['msgNo'])
|
||||
|
||||
## else:
|
||||
## print(aprslib.parse(packet)['from'])
|
||||
|
||||
if __name__ == '__main__':
|
||||
arg_parser = argparse.ArgumentParser()
|
||||
arg_parser.add_argument('-c', '--config', action='store', dest='CONFIG_FILE', help='/full/path/to/config.file (usually gps_data.cfg)')
|
||||
cli_args = arg_parser.parse_args()
|
||||
parser = ConfigParser()
|
||||
if not cli_args.CONFIG_FILE:
|
||||
print('\n\nMust specify a config file with -c argument.\n\n')
|
||||
parser.read(cli_args.CONFIG_FILE)
|
||||
|
||||
aprs_server = parser.get('GPS_DATA', 'APRS_SERVER')
|
||||
aprs_port = parser.get('GPS_DATA', 'APRS_PORT')
|
||||
aprs_login = parser.get('GPS_DATA', 'APRS_RECEIVE_LOGIN_CALL')
|
||||
aprs_passcode = parser.get('GPS_DATA', 'APRS_LOGIN_PASSCODE')
|
||||
mailbox_file = parser.get('GPS_DATA', 'MAILBOX_FILE')
|
||||
user_settings_file = parser.get('GPS_DATA', 'USER_SETTINGS_FILE')
|
||||
user_aprs_ssid = parser.get('GPS_DATA', 'USER_APRS_SSID')
|
||||
|
||||
AIS = aprslib.IS(aprs_login, passwd=int(aprs_passcode), host=aprs_server, port=int(aprs_port))
|
||||
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
|
||||
print('APRS message receive script for GPS/Data Application.\nAuthor: Eric, KF7EEL - kf7eel@qsl.net')
|
||||
AIS.set_filter(parser.get('GPS_DATA', 'APRS_FILTER'))
|
||||
AIS.connect()
|
||||
print('Connecting to APRS-IS')
|
||||
AIS.consumer(aprs_filter, raw=True)
|
||||
|
||||
|
|
@ -1,764 +0,0 @@
|
|||
###############################################################################
|
||||
# HBLink - Copyright (C) 2020 Cortney T. Buffington, N0MJS <n0mjs@me.com>
|
||||
# GPS/Data - Copyright (C) 2020 Eric Craw, KF7EEL <kf7eel@qsl.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
###############################################################################
|
||||
|
||||
'''
|
||||
This is a web dashboard for the GPS/Data application.
|
||||
'''
|
||||
|
||||
from flask import Flask, render_template, request, Response, Markup
|
||||
import ast, os
|
||||
#from dashboard_settings import *
|
||||
import folium
|
||||
from folium.plugins import MarkerCluster
|
||||
import re
|
||||
from datetime import datetime
|
||||
import argparse
|
||||
from configparser import ConfigParser
|
||||
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
tbl_hdr = '''
|
||||
<table style="border-color: black; margin-left: auto; margin-right: auto;" border="2" cellspacing="6" cellpadding="2"><tbody>
|
||||
'''
|
||||
tbl_ftr = '''
|
||||
</tbody>
|
||||
</table>
|
||||
'''
|
||||
|
||||
def get_loc_data():
|
||||
try:
|
||||
dash_loc = ast.literal_eval(os.popen('cat ' + loc_file).read())
|
||||
tmp_loc = ''
|
||||
loc_hdr = '''
|
||||
<tr>
|
||||
<td style="text-align: center;">
|
||||
<h2><strong> Callsign </strong></h2>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<h2> <strong>Latitude</strong> </h2>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<h2> <strong>Longitude</strong> </h2>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<h2> <strong>Time</strong> </h2>
|
||||
</td>
|
||||
</tr>
|
||||
'''
|
||||
last_known_loc_list = []
|
||||
display_number = 15
|
||||
for e in dash_loc:
|
||||
if display_number == 0:
|
||||
break
|
||||
else:
|
||||
if e['call'] in last_known_loc_list:
|
||||
pass
|
||||
if e['call'] not in last_known_loc_list:
|
||||
if type(e['time']) == str:
|
||||
loc_time = str(e['time'])
|
||||
if type(e['time']) == int or type(e['time']) == float:
|
||||
loc_time = datetime.fromtimestamp(e['time']).strftime(time_format)
|
||||
last_known_loc_list.append(e['call'])
|
||||
display_number = display_number - 1
|
||||
tmp_loc = tmp_loc + '''<tr>
|
||||
<td style="text-align: center;"><a href="view_map?track=''' + e['call'] + '''"target="_blank"><strong>''' + e['call'] + '''</strong></a></td>
|
||||
<td style="text-align: center;"><strong> ''' + str(e['lat']) + ''' </strong></td>
|
||||
<td style="text-align: center;"><strong> ''' + str(e['lon']) + ''' </strong></td>
|
||||
<td style="text-align: center;"> ''' + loc_time + ''' </td>
|
||||
</tr>'''
|
||||
return str(str('<h1 style="text-align: center;">Last Known Location</h1>') + tbl_hdr + loc_hdr + tmp_loc + tbl_ftr)
|
||||
except:
|
||||
return str('<h1 style="text-align: center;">No data</h1>')
|
||||
|
||||
|
||||
def get_bb_data():
|
||||
try:
|
||||
dash_bb = ast.literal_eval(os.popen('cat ' + bb_file).read())
|
||||
tmp_bb = ''
|
||||
|
||||
bb_hdr = '''
|
||||
<tr>
|
||||
<td style="text-align: center;">
|
||||
<h2><strong> Callsign </strong></h2>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<h2> <strong>ID</strong> </h2>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<h2> <strong>Bulletin</strong> </h2>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<h2> <strong>Time</strong> </h2>
|
||||
</td>
|
||||
</tr>
|
||||
'''
|
||||
display_number = 10
|
||||
|
||||
for e in dash_bb:
|
||||
if display_number == 0:
|
||||
break
|
||||
else:
|
||||
if type(e['time']) == str:
|
||||
loc_time = str(e['time'])
|
||||
if type(e['time']) == int or type(e['time']) == float:
|
||||
loc_time = datetime.fromtimestamp(e['time']).strftime(time_format)
|
||||
display_number = display_number - 1
|
||||
tmp_bb = tmp_bb + '''<tr>
|
||||
<td style="text-align: center;"><strong> ''' + e['call'] + ''' </strong></td>
|
||||
<td style="text-align: center;">''' + str(e['dmr_id']) + '''</td>
|
||||
<td style="text-align: center;"><strong> ''' + e['bulletin'] + ''' </strong></td>
|
||||
<td style="text-align: center;"> ''' + loc_time + ''' </td>
|
||||
</tr>'''
|
||||
|
||||
return str('<h1 style="text-align: center;">Bulletin Board</h1>' + tbl_hdr + bb_hdr + tmp_bb + tbl_ftr)
|
||||
except:
|
||||
return str('<h1 style="text-align: center;">No data</h1>')
|
||||
|
||||
def check_emergency():
|
||||
# open emergency txt
|
||||
try:
|
||||
sos_file = ast.literal_eval(os.popen('cat ' + emergency_sos_file).read())
|
||||
if type(sos_file['time']) == str:
|
||||
loc_time = str(sos_file['time'])
|
||||
if type(sos_file['time']) == int or type(sos_file['time']) == float:
|
||||
loc_time = datetime.fromtimestamp(sos_file['time']).strftime(time_format)
|
||||
if '@NOTICE' in sos_file['message'] and '@SOS' not in sos_file['message']:
|
||||
notice_header = '<span style="background-color: #ffffff; color: #008000;">NOTICE:</span>'
|
||||
else:
|
||||
notice_header = '<span style="background-color: #ff0000; color: #ffffff;">EMERGENCY ACTIVATION</span>'
|
||||
value = Markup("""
|
||||
<h1 style="text-align: center;">""" + notice_header + """</h1>
|
||||
<table style="width: 441px; margin-left: auto; margin-right: auto;" border="3">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width: 78.3667px;"><span style="text-decoration: underline;"><strong>From:</strong></span></td>
|
||||
<td style="width: 345.633px; text-align: center;"><strong>""" + sos_file['call'] + """</strong> - """ + str(sos_file['dmr_id']) + """</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 78.3667px;"><span style="text-decoration: underline;"><strong>Message:</strong></span></td>
|
||||
<td style="width: 345.633px; text-align: center;">""" + sos_file['message'] + """</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 78.3667px;"><span style="text-decoration: underline;"><strong>Time:</strong></span></td>
|
||||
<td style="width: 345.633px; text-align: center;">""" + loc_time + """</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p> </p>
|
||||
<button onclick="window.open('view_map?track=""" + sos_file['call'] + """&reload=30','_blank' );" type="button" class="emergency_button"><h1>View Station on Map</h1></button>
|
||||
<p style="text-align: center;"><a href="https://aprs.fi/""" + sos_file['call'] + """"><strong>View on aprs.fi</strong></a></p>
|
||||
<hr />
|
||||
|
||||
""")
|
||||
return value
|
||||
except Exception as e:
|
||||
return ''
|
||||
|
||||
def aprs_to_latlon(x):
|
||||
degrees = int(x) // 100
|
||||
minutes = x - 100*degrees
|
||||
return degrees + minutes/60
|
||||
|
||||
def user_setting_write(dmr_id, input_ssid, input_icon, input_comment):
|
||||
dmr_id = int(dmr_id)
|
||||
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
|
||||
new_dict = user_settings
|
||||
new_dict[dmr_id][1]['ssid'] = input_ssid
|
||||
new_dict[dmr_id][2]['icon'] = input_icon
|
||||
new_dict[dmr_id][3]['comment'] = input_comment
|
||||
print(input_comment)
|
||||
print(new_dict[dmr_id])
|
||||
|
||||
# Write modified dict to file
|
||||
with open(user_settings_file, 'w') as user_dict_file:
|
||||
user_dict_file.write(str(new_dict))
|
||||
user_dict_file.close()
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
value = Markup('<strong>The HTML String</strong>')
|
||||
#return get_data()
|
||||
return render_template('index.html', title = dashboard_title, logo = logo, emergency = check_emergency())
|
||||
@app.route('/bulletin_board')
|
||||
def dash_bb():
|
||||
return get_bb_data()
|
||||
#return render_template('index.html', data = str(get_data()))
|
||||
@app.route('/positions')
|
||||
def dash_loc():
|
||||
return get_loc_data()
|
||||
|
||||
@app.route('/help/')
|
||||
def help():
|
||||
#return get_data()
|
||||
return render_template('help.html', title = dashboard_title, logo = logo, description = description, data_call_type = data_call_type, data_call_id = data_call_id, aprs_ssid = aprs_ssid)
|
||||
@app.route('/about/')
|
||||
def about():
|
||||
#return get_data()
|
||||
return render_template('about.html', title = dashboard_title, logo = logo, contact_name = contact_name, contact_call = contact_call, contact_email = contact_email, contact_website = contact_website)
|
||||
@app.route('/view_map')
|
||||
def view_map():
|
||||
reload_time = request.args.get('reload')
|
||||
track_call = request.args.get('track')
|
||||
map_size = request.args.get('map_size')
|
||||
user_loc = ast.literal_eval(os.popen('cat ' + loc_file).read())
|
||||
last_known_list = []
|
||||
coord_list = []
|
||||
try:
|
||||
if track_call:
|
||||
#folium_map = folium.Map(location=map_center, zoom_start=int(zoom_level))
|
||||
#marker_cluster = MarkerCluster().add_to(folium_map)
|
||||
for user_coord in user_loc:
|
||||
user_lat = aprs_to_latlon(float(re.sub('[A-Za-z]','', user_coord['lat'])))
|
||||
user_lon = aprs_to_latlon(float(re.sub('[A-Za-z]','', user_coord['lon'])))
|
||||
if type(user_coord['time']) == str:
|
||||
loc_time = str(user_coord['time'])
|
||||
if type(user_coord['time']) == int or type(user_coord['time']) == float:
|
||||
loc_time = datetime.fromtimestamp(user_coord['time']).strftime(time_format)
|
||||
if 'S' in user_coord['lat']:
|
||||
user_lat = -user_lat
|
||||
if 'W' in user_coord['lon']:
|
||||
user_lon = -user_lon
|
||||
loc_comment = ''
|
||||
if 'comment' in user_coord:
|
||||
loc_comment = """
|
||||
<tr>
|
||||
<td style="text-align: center;">Comment:</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><strong>"""+ str(user_coord['comment']) +"""</strong></td>
|
||||
</tr>"""
|
||||
if user_coord['call'] not in last_known_list and user_coord['call'] == track_call:
|
||||
folium_map = folium.Map(location=[user_lat, user_lon], tiles=map_theme, zoom_start=15)
|
||||
marker_cluster = MarkerCluster().add_to(folium_map)
|
||||
folium.Marker([user_lat, user_lon], popup="""<i>
|
||||
<table style="width: 150px;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="text-align: center;">Last Location:</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><strong>"""+ str(user_coord['call']) +"""</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><em>"""+ loc_time +"""</em></td>
|
||||
""" + loc_comment + """
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</i>
|
||||
""", icon=folium.Icon(color="red", icon="record"), tooltip=str(user_coord['call'])).add_to(folium_map)
|
||||
last_known_list.append(user_coord['call'])
|
||||
if user_coord['call'] in last_known_list and user_coord['call'] == track_call:
|
||||
folium.CircleMarker([user_lat, user_lon], popup="""
|
||||
<table style="width: 150px;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="text-align: center;"><strong>""" + user_coord['call'] + """</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><em>""" + loc_time + """</em></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
""", tooltip=str(user_coord['call']), fill=True, fill_color="#3186cc", radius=4).add_to(marker_cluster)
|
||||
#return folium_map._repr_html_()
|
||||
if not reload_time:
|
||||
reload_time = 120
|
||||
if not map_size:
|
||||
map_view = '''<table style="width: 1000px; height: 600px; margin-left: auto; margin-right: auto;" border="1">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
''' + folium_map._repr_html_() + '''</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>'''
|
||||
if map_size == 'full':
|
||||
map_view = folium_map._repr_html_()
|
||||
|
||||
content = '''
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="refresh" content="''' + str(reload_time) + """" >
|
||||
<title>""" + dashboard_title + """ - Tracking """+ track_call + """</title>
|
||||
</head>
|
||||
<p style="text-align: center;"><strong>""" + dashboard_title + """ - Tracking """ + track_call + """</strong></p>
|
||||
<p style="text-align: center;"><em>Page automatically reloads every """ + str(reload_time) + """ seconds.</em></p>
|
||||
<p style="text-align: center;">
|
||||
<select name="sample" onchange="location = this.value;">
|
||||
<option value="view_map?track=""" + track_call + """&reload=120">2 Minutes</option>
|
||||
<option value="view_map?track=""" + track_call + """&reload=">Don't Reload</option>
|
||||
<option value="view_map?track=""" + track_call + """&reload=30">30 Seconds</option>
|
||||
<option value="view_map?track=""" + track_call + """&reload=5">5 Minutes</option>
|
||||
<option value="view_map?track=""" + track_call + """&reload=600">10 Minutes</option>
|
||||
</select>
|
||||
<p style="text-align: center;"><button onclick="self.close()">Close</button><!--<button onclick="history.back()">Back</button>-->
|
||||
</p>
|
||||
""" + map_view
|
||||
return render_template('generic.html', title = dashboard_title, logo = logo, content = Markup(content))
|
||||
except Exception as e:
|
||||
content = """<h1 style="text-align: center;">Station not found.</h1>
|
||||
#<p style="text-align: center;"><button onclick="self.close()">Close Window</button>
|
||||
#</p>"""
|
||||
return render_template('generic.html', title = dashboard_title, logo = logo, content = Markup(content))
|
||||
|
||||
if not track_call:
|
||||
folium_map = folium.Map(location=(map_center_lat, map_center_lon), tiles=map_theme, zoom_start=int(zoom_level))
|
||||
marker_cluster = MarkerCluster().add_to(folium_map)
|
||||
for user_coord in user_loc:
|
||||
user_lat = aprs_to_latlon(float(re.sub('[A-Za-z]','', user_coord['lat'])))
|
||||
user_lon = aprs_to_latlon(float(re.sub('[A-Za-z]','', user_coord['lon'])))
|
||||
if type(user_coord['time']) == str:
|
||||
loc_time = str(user_coord['time'])
|
||||
if type(user_coord['time']) == int or type(user_coord['time']) == float:
|
||||
loc_time = datetime.fromtimestamp(user_coord['time']).strftime(time_format)
|
||||
if 'S' in user_coord['lat']:
|
||||
user_lat = -user_lat
|
||||
if 'W' in user_coord['lon']:
|
||||
user_lon = -user_lon
|
||||
loc_comment = ''
|
||||
coord_list.append([user_lat, user_lon])
|
||||
if 'comment' in user_coord:
|
||||
loc_comment = """
|
||||
<tr>
|
||||
<td style="text-align: center;">Comment:</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><strong>"""+ str(user_coord['comment']) +"""</strong></td>
|
||||
</tr>"""
|
||||
if user_coord['call'] not in last_known_list:
|
||||
folium.Marker([user_lat, user_lon], popup="""<i>
|
||||
<table style="width: 150px;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="text-align: center;">Last Location:</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><strong>""" + user_coord['call'] + """</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><em>""" + loc_time + """</em></td>
|
||||
</tr>
|
||||
""" + loc_comment + """
|
||||
<tr>
|
||||
<td style="text-align: center;"><strong><A href="view_map?track=""" + user_coord['call'] + """" target="_blank">Track Station</A></strong></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</i>""", icon=folium.Icon(color="red", icon="record"), tooltip=str(user_coord['call'])).add_to(folium_map)
|
||||
last_known_list.append(user_coord['call'])
|
||||
if user_coord['call'] in last_known_list:
|
||||
if coord_list.count([user_lat, user_lon]) > 15:
|
||||
pass
|
||||
else:
|
||||
folium.CircleMarker([user_lat, user_lon], popup="""
|
||||
<table style="width: 150px;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="text-align: center;"><strong>""" + user_coord['call'] + """</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><em>""" + loc_time + """</em></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
""", tooltip=str(user_coord['call']), fill=True, fill_color="#3186cc", radius=4).add_to(marker_cluster)
|
||||
|
||||
return folium_map._repr_html_()
|
||||
|
||||
@app.route('/map/')
|
||||
def map():
|
||||
return render_template('map.html', title = dashboard_title, logo = logo)
|
||||
|
||||
@app.route('/user', methods = ['GET', 'POST'])
|
||||
def user_settings():
|
||||
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
|
||||
user_id = request.args.get('user_id')
|
||||
if request.method == 'POST' and request.form.get('dmr_id'):
|
||||
if int(request.form.get('dmr_id')) in user_settings:
|
||||
user_id = request.form.get('dmr_id')
|
||||
ssid = user_settings[int(request.form.get('dmr_id'))][1]['ssid']
|
||||
icon = user_settings[int(request.form.get('dmr_id'))][2]['icon']
|
||||
comment = user_settings[int(request.form.get('dmr_id'))][3]['comment']
|
||||
try:
|
||||
pin = user_settings[int(request.form.get('dmr_id'))][4]['pin']
|
||||
if ssid == '':
|
||||
ssid = aprs_ssid
|
||||
if icon == '':
|
||||
icon = '\['
|
||||
if comment == '':
|
||||
comment = default_comment + ' ' + user_id
|
||||
user_result = """
|
||||
Use this tool to change the stored APRS settings for your DMR ID. When a position is sent, the stored settings will be used to format the APRS packet. Leave field(s) blank for default value.
|
||||
<h2 style="text-align: center;"> Modify Settings for ID: """ + user_id + """</h2>
|
||||
<form action="user" method="post">
|
||||
<table style="margin-left: auto; margin-right: auto; width: 419.367px;" border="1">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width: 82px;"><strong>Callsign:</strong></td>
|
||||
<td style="width: 319.367px; text-align: center;"><strong>""" + str(user_settings[int(user_id)][0]['call']) + """</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 82px;"><strong>SSID:</strong></td>
|
||||
<td style="width: 319.367px; text-align: center;"><input id="ssid" name="ssid" type="text" placeholder='""" + ssid + """' /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 82px;"><strong>Icon:</strong></td>
|
||||
<td style="width: 319.367px; text-align: center;"><input id="icon" name="icon" type="text" placeholder='""" + icon + """' /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 82px;"><strong>Comment:</strong></td>
|
||||
<td style="width: 319.367px; text-align: center;"><input id="comment" name="comment" type="text" placeholder='""" + comment + """'/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 82px;"><strong>DMR ID:</strong></td>
|
||||
<td style="width: 319.367px; text-align: center;"><input id="dmr_id" name="dmr_id" type="text" value='""" + user_id + """'/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 82px;"><strong>PIN:</strong></td>
|
||||
<td style="width: 319.367px; text-align: center;"><input id="pin" name="pin" type="password" /></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p style="text-align: center;"><input type="submit" value="Submit" /></p>
|
||||
</form>
|
||||
<p> </p>
|
||||
|
||||
|
||||
"""
|
||||
except:
|
||||
user_result = """<h2 style="text-align: center;">No PIN set for """ + str(user_settings[int(user_id)][0]['call']) + """ - """ + request.form.get('dmr_id') + """</h2>
|
||||
<p style="text-align: center;"><button onclick="history.back()">Back</button>
|
||||
</p>"""
|
||||
if int(request.form.get('dmr_id')) not in user_settings:
|
||||
user_result = """<h2 style="text-align: center;">DMR ID not found.</h2>
|
||||
<p style="text-align: center;"><button onclick="history.back()">Back</button>
|
||||
</p>"""
|
||||
#if edit_user:
|
||||
|
||||
if request.method == 'POST' and request.form.get('dmr_id') and request.form.get('pin'):
|
||||
if int(request.form.get('pin')) == pin:
|
||||
ssid = request.form.get('ssid')
|
||||
icon = request.form.get('icon')
|
||||
comment = request.form.get('comment')
|
||||
user_setting_write(request.form.get('dmr_id'), request.form.get('ssid'), request.form.get('icon'), request.form.get('comment'))
|
||||
user_result = """<h2 style="text-align: center;">Changed settings for """ + str(user_settings[int(user_id)][0]['call']) + """ - """ + request.form.get('dmr_id') + """</h2>
|
||||
<p style="text-align: center;"><button onclick="history.back()">Back</button>
|
||||
</p>"""
|
||||
if int(request.form.get('pin')) != pin:
|
||||
user_result = """<h2 style="text-align: center;">Incorrect PIN.</h2>
|
||||
<p style="text-align: center;"><button onclick="history.back()">Back</button>
|
||||
</p>"""
|
||||
|
||||
if request.method == 'GET' and not request.args.get('user_id'):
|
||||
user_result = """
|
||||
Use this tool to find, check, and change the stored APRS settings for your DMR ID. When a position is sent, the stored settings will be used to format the APRS packet.
|
||||
<table style="width: 600px; margin-left: auto; margin-right: auto;" border="3">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><form action="user" method="get">
|
||||
<table style="margin-left: auto; margin-right: auto;">
|
||||
<tbody>
|
||||
<tr style="height: 62px;">
|
||||
<td style="text-align: center; height: 62px;">
|
||||
<h2><strong><label for="user_id">Look up DMR ID:</label></strong></h2>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="height: 51.1667px;">
|
||||
<td style="height: 51.1667px;"><input id="user_id" name="user_id" type="text" /></td>
|
||||
</tr>
|
||||
<tr style="height: 27px;">
|
||||
<td style="text-align: center; height: 27px;"><input type="submit" value="Submit" /></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form></td>
|
||||
<td><form action="user" method="post">
|
||||
<table style="margin-left: auto; margin-right: auto;">
|
||||
<tbody>
|
||||
<tr style="height: 62px;">
|
||||
<td style="text-align: center; height: 62px;">
|
||||
<h2><strong><label for="dmr_id">Edit DMR ID:</label></strong></h2>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="height: 51.1667px;">
|
||||
<td style="height: 51.1667px;"><input id="dmr_id" name="dmr_id" type="text" /></td>
|
||||
</tr>
|
||||
<tr style="height: 27px;">
|
||||
<td style="text-align: center; height: 27px;"><input type="submit" value="Submit" /></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p> </p>
|
||||
|
||||
|
||||
"""
|
||||
#else:
|
||||
if request.method == 'GET' and request.args.get('user_id'):
|
||||
try:
|
||||
call = user_settings[int(user_id)][0]['call']
|
||||
ssid = user_settings[int(user_id)][1]['ssid']
|
||||
icon = user_settings[int(user_id)][2]['icon']
|
||||
comment = user_settings[int(user_id)][3]['comment']
|
||||
if ssid == '':
|
||||
ssid = aprs_ssid
|
||||
if icon == '':
|
||||
icon = '\['
|
||||
if comment == '':
|
||||
comment = default_comment + ' ' + user_id
|
||||
#for result in user_settings:
|
||||
#return user_settings[int(user_id)][0]
|
||||
#return user_id
|
||||
#return user_settings
|
||||
user_result = """<h2 style="text-align: center;"> Settings for ID: """ + user_id + """</h2>
|
||||
<table style="margin-left: auto; margin-right: auto; width: 419.367px;" border="1">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width: 82px;"><strong>Callsign:</strong></td>
|
||||
<td style="width: 319.367px; text-align: center;">""" + user_settings[int(user_id)][0]['call'] + """</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 82px;"><strong>SSID:</strong></td>
|
||||
<td style="width: 319.367px; text-align: center;">""" + ssid + """</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 82px;"><strong>Icon:</strong></td>
|
||||
<td style="width: 319.367px; text-align: center;">""" + icon + """</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 82px;"><strong>Comment:</strong></td>
|
||||
<td style="width: 319.367px; text-align: center;">""" + comment + """</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p style="text-align: center;"><button onclick="history.back()">Back</button>
|
||||
</p>
|
||||
"""
|
||||
except:
|
||||
user_result = '''<h2 style="text-align: center;">User ID not found.</h2>
|
||||
<p style="text-align: center;"><button onclick="history.back()">Back</button>
|
||||
</p>'''
|
||||
|
||||
return render_template('generic.html', title = dashboard_title, logo = logo, content = Markup(user_result))
|
||||
|
||||
@app.route('/mailbox')
|
||||
def mailbox():
|
||||
recipient = request.args.get('recipient')
|
||||
if not recipient:
|
||||
mail_content = """
|
||||
<p>The Mailbox is a place where users can leave messages via DMR SMS. A user can leave a message for someone else by sending a specially formatted SMS to <strong>""" + data_call_id + """</strong>.
|
||||
The message recipient can then use the mailbox to check for messages. You can also check for APRS mesages addressed to your DMR radio. Enter your call sign (without APRS SSID) below to check for messages. See the <a href="help">help</a> page for more information.</p>
|
||||
<form action="mailbox" method="get">
|
||||
<table style="margin-left: auto; margin-right: auto;">
|
||||
<tbody>
|
||||
<tr style="height: 62px;">
|
||||
<td style="text-align: center; height: 62px;">
|
||||
<h2><strong><label for="recipient">Callsign:</label></strong></h2>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="height: 51.1667px;">
|
||||
<td style="height: 51.1667px;"><input id="recipient" name="recipient" type="text" /></td>
|
||||
</tr>
|
||||
<tr style="height: 27px;">
|
||||
<td style="text-align: center; height: 27px;"><input type="submit" value="Submit" /></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
<p> </p>
|
||||
|
||||
"""
|
||||
|
||||
else:
|
||||
mailbox_file = ast.literal_eval(os.popen('cat ' + the_mailbox_file).read())
|
||||
mail_content = '<h2 style="text-align: center;">Messages for: ' + recipient.upper() + '''
|
||||
</h2>\n<p style="text-align: center;"><button onclick="history.back()">Back</button></p>\n
|
||||
<h4 style="text-align: center;"><a href="mailbox_rss?recipient=''' + recipient.upper() + '''"><em>Mailbox RSS Feed for ''' + recipient.upper() + '''</em></a><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH5QIcFBAOXAevLAAAAZZJREFUSMftlbtKA0EUhj8jWhi8gaIEC29oxEoRFESLgIXYiWVSKoj6CCrBBwj6CBHNE1hEWy21ETQqiIW1wXhPo81ZOBw2apbdVPvDsDPnP8M/5zKzECJEQKivYO8DFoAYEAGKtTpQEvhW4w3IA+tAVy2F9fgEskA8COHUL8LOKAMZoMmLQF0FewcwImmNAzPANBB18b0BFoGroNLfBiyLgI2+BMwF3XgNwCrwYsQ//BBPSRPdAoeybjE+A8ClS+Sjfnf1E5A2dW4FzoxfwWvD/XWd7oAxI24jz3gVnpS7eiEpt+KvQEL5D5qal/245zFgU+pnXzMd+Zrh9/3q5l7g3CXtTs0bgWvFffn5vDa7iKcVv2K4DS8i3cAOsAuMm8h12ovqqrVL/R3upFrRKPBgHgctvm0iSynuWNnf5bf6byy5dPKe4nukhg6XU9yW2TfsJlDpNCUX27OaP8pD4WBCzQtmX381EUeAI3Xqe6m5xoHpYAezJuJkNb9Fh0tI4+SlXhpTwJBaZ+XbCcwr+6kcPESI2uAHmAijFaMnEmYAAAAASUVORK5CYII=" /></h4>
|
||||
'''
|
||||
for messages in mailbox_file:
|
||||
if messages['recipient'] == recipient.upper():
|
||||
sender = """
|
||||
<tr>
|
||||
<td style="width: 63px;"><strong>DMR ID:</strong></td>
|
||||
<td style="width: 292.55px; text-align: center;">""" + str(messages['dmr_id']) + """</td>
|
||||
</tr>
|
||||
"""
|
||||
if type(messages['time']) == str:
|
||||
loc_time = str(messages['time'])
|
||||
if type(messages['time']) == int or type(messages['time']) == float:
|
||||
loc_time = datetime.fromtimestamp(messages['time']).strftime(time_format)
|
||||
if type(messages['dmr_id']) == str:
|
||||
sender = """
|
||||
<tr>
|
||||
<td style="width: 63px;"><strong>APRS Call:</strong></td>
|
||||
<td style="width: 292.55px; text-align: center;">""" + str(messages['dmr_id']) + """</td>
|
||||
</tr>
|
||||
"""
|
||||
mail_content = mail_content + """
|
||||
<table style="margin-left: auto; margin-right: auto; width: 372.55px;" border="1">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width: 63px;"><strong>From:</strong></td>
|
||||
<td style="text-align: center; width: 292.55px;"><strong>""" + messages['call'] + """</strong></td>
|
||||
</tr>
|
||||
""" + sender + """
|
||||
<tr>
|
||||
<td style="width: 63px;"><strong>Time:</strong></td>
|
||||
<td style="width: 292.55px; text-align: center;">""" + loc_time + """</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 63px;"><strong>Message:</strong></td>
|
||||
<td style="width: 292.55px; text-align: center;"><strong>""" + messages['message'] + """</strong></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p> </p>
|
||||
|
||||
"""
|
||||
return render_template('generic.html', title = dashboard_title, logo = logo, content = Markup(mail_content))
|
||||
|
||||
|
||||
@app.route('/bulletin_rss.xml')
|
||||
def bb_rss():
|
||||
try:
|
||||
dash_bb = ast.literal_eval(os.popen('cat ' + bb_file).read())
|
||||
post_data = ''
|
||||
rss_header = """<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>""" + dashboard_title + """ - Bulletin Board Feed</title>
|
||||
<link>""" + rss_link + """</link>
|
||||
<description>This is the Bulletin Board feed from """ + dashboard_title + """</description>"""
|
||||
for entry in dash_bb:
|
||||
if type(entry['time']) == str:
|
||||
loc_time = str(entry['time'])
|
||||
if type(entry['time']) == int or type(entry['time']) == float:
|
||||
loc_time = datetime.fromtimestamp(entry['time']).strftime(time_format)
|
||||
post_data = post_data + """
|
||||
<item>
|
||||
<title>""" + entry['call'] + ' - ' + str(entry['dmr_id']) + """</title>
|
||||
<link>""" + rss_link + """</link>
|
||||
<description>""" + entry['bulletin'] + """ - """ + loc_time + """</description>
|
||||
<pubDate>""" + datetime.fromtimestamp(entry['time']).strftime('%a, %d %b %y') +"""</pubDate>
|
||||
</item>
|
||||
"""
|
||||
return Response(rss_header + post_data + "\n</channel>\n</rss>", mimetype='text/xml')
|
||||
except Exception as e:
|
||||
#return str('<h1 style="text-align: center;">No data</h1>')
|
||||
return str(e)
|
||||
|
||||
@app.route('/mailbox_rss')
|
||||
def mail_rss():
|
||||
mailbox_file = ast.literal_eval(os.popen('cat ' + the_mailbox_file).read())
|
||||
post_data = ''
|
||||
recipient = request.args.get('recipient').upper()
|
||||
rss_header = """<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>""" + dashboard_title + """ - Mailbox Feed for """ + recipient + """</title>
|
||||
<link>""" + rss_link + """</link>
|
||||
<description>This is a Mailbox feed from """ + dashboard_title + """ for """ + recipient + """.</description>"""
|
||||
for entry in mailbox_file:
|
||||
if type(entry['time']) == str:
|
||||
loc_time = str(entry['time'])
|
||||
if type(entry['time']) == int or type(entry['time']) == float:
|
||||
loc_time = datetime.fromtimestamp(entry['time']).strftime(time_format)
|
||||
if entry['recipient'] == recipient:
|
||||
post_data = post_data + """
|
||||
<item>
|
||||
<title>""" + entry['call'] + ' - ' + str(entry['dmr_id']) + """</title>
|
||||
<link>""" + rss_link + """</link>
|
||||
<description>""" + entry['message'] + """ - """ + loc_time + """</description>
|
||||
<pubDate>""" + datetime.fromtimestamp(entry['time']).strftime('%a, %d %b %y') +"""</pubDate>
|
||||
</item>
|
||||
"""
|
||||
return Response(rss_header + post_data + "\n</channel>\n</rss>", mimetype='text/xml')
|
||||
|
||||
if __name__ == '__main__':
|
||||
arg_parser = argparse.ArgumentParser()
|
||||
arg_parser.add_argument('-c', '--config', action='store', dest='CONFIG_FILE', help='/full/path/to/config.file (usually gps_data.cfg)')
|
||||
cli_args = arg_parser.parse_args()
|
||||
parser = ConfigParser()
|
||||
if not cli_args.CONFIG_FILE:
|
||||
print('\n\nMust specify a config file with -c argument.\n\n')
|
||||
parser.read(cli_args.CONFIG_FILE)
|
||||
###### Definitions #####
|
||||
# Title of the Dashboard
|
||||
dashboard_title = parser.get('GPS_DATA', 'DASHBOARD_TITLE')
|
||||
# Logo used on dashboard page
|
||||
logo = parser.get('GPS_DATA', 'LOGO')
|
||||
dash_port = int(parser.get('GPS_DATA', 'DASH_PORT'))
|
||||
# IP to run server on
|
||||
dash_host = parser.get('GPS_DATA', 'DASH_HOST')
|
||||
#Description of dashboard to show on main page
|
||||
description = parser.get('GPS_DATA', 'DESCRIPTION')
|
||||
# The following will generate a help page for your users.
|
||||
|
||||
# Data call type
|
||||
if parser.get('GPS_DATA', 'CALL_TYPE') == 'unit':
|
||||
data_call_type = 'Private Call'
|
||||
if parser.get('GPS_DATA', 'CALL_TYPE') == 'group':
|
||||
data_call_type = 'Group Call'
|
||||
if parser.get('GPS_DATA', 'CALL_TYPE') == 'both':
|
||||
data_call_type = 'Private or Group Call'
|
||||
# DMR ID of GPS/Data application
|
||||
data_call_id = parser.get('GPS_DATA', 'DATA_DMR_ID')
|
||||
# Default APRS ssid
|
||||
aprs_ssid = parser.get('GPS_DATA', 'USER_APRS_SSID')
|
||||
|
||||
# Gateway contact info displayed on about page.
|
||||
contact_name = parser.get('GPS_DATA', 'CONTACT_NAME')
|
||||
contact_call = parser.get('GPS_DATA', 'CONTACT_CALL')
|
||||
contact_email = parser.get('GPS_DATA', 'CONTACT_EMAIL')
|
||||
contact_website = parser.get('GPS_DATA', 'CONTACT_WEBSITE')
|
||||
|
||||
# Center dashboard map over these coordinates
|
||||
map_center_lat = float(parser.get('GPS_DATA', 'MAP_CENTER_LAT'))
|
||||
map_center_lon = float(parser.get('GPS_DATA', 'MAP_CENTER_LON'))
|
||||
zoom_level = int(parser.get('GPS_DATA', 'ZOOM_LEVEL'))
|
||||
map_theme = parser.get('GPS_DATA', 'MAP_THEME')
|
||||
|
||||
# Time format for display
|
||||
time_format = parser.get('GPS_DATA', 'TIME_FORMAT')
|
||||
|
||||
# RSS feed link, shows in the link section of each RSS item.
|
||||
rss_link = parser.get('GPS_DATA', 'RSS_LINK')
|
||||
|
||||
# Default APRS comment for users.
|
||||
default_comment = parser.get('GPS_DATA', 'USER_APRS_COMMENT')
|
||||
|
||||
|
||||
# DO NOT MODIFY BELOW HERE.
|
||||
bb_file = parser.get('GPS_DATA', 'BULLETIN_BOARD_FILE')
|
||||
loc_file = parser.get('GPS_DATA', 'LOCATION_FILE')
|
||||
emergency_sos_file = parser.get('GPS_DATA', 'EMERGENCY_SOS_FILE')
|
||||
the_mailbox_file = parser.get('GPS_DATA', 'MAILBOX_FILE')
|
||||
user_settings_file = parser.get('GPS_DATA', 'USER_SETTINGS_FILE')
|
||||
########################
|
||||
|
||||
app.run(debug = True, port=dash_port, host=dash_host)
|
|
@ -1,63 +0,0 @@
|
|||
###############################################################################
|
||||
# HBLink - Copyright (C) 2020 Cortney T. Buffington, N0MJS <n0mjs@me.com>
|
||||
# GPS/Data - Copyright (C) 2020 Eric Craw, KF7EEL <kf7eel@qsl.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
###############################################################################
|
||||
|
||||
'''
|
||||
Settings for web dashboard.
|
||||
'''
|
||||
|
||||
# Title of the Dashboard
|
||||
dashboard_title = 'HBLink3 D-APRS Dashboard'
|
||||
# Logo used on dashboard page
|
||||
logo = 'https://raw.githubusercontent.com/kf7eel/hblink3/gps/HBlink.png'
|
||||
# Port to run server
|
||||
dash_port = 8092
|
||||
# IP to run server on
|
||||
dash_host = '127.0.0.1'
|
||||
#Description of dashboard to show on main page
|
||||
description = '''
|
||||
Welcome to the ''' + dashboard_title + '''.
|
||||
'''
|
||||
# The following will generate a help page for your users.
|
||||
|
||||
# Data call type
|
||||
data_call_type = 'Private Call'
|
||||
# DMR ID of GPS/Data application
|
||||
data_call_id = '9099'
|
||||
# Default APRS ssid
|
||||
aprs_ssid = '15'
|
||||
|
||||
# Gateway contact info displayed on about page.
|
||||
contact_name = 'your name'
|
||||
contact_call = 'N0CALL'
|
||||
contact_email = 'email@example.org'
|
||||
contact_website = 'https://hbl.ink'
|
||||
|
||||
# Time format for display
|
||||
time_format = '%H:%M:%S - %m/%d/%y'
|
||||
|
||||
# Center dashboard map over these coordinates
|
||||
map_center = (47.00, -120.00)
|
||||
zoom_level = 7
|
||||
# List and preview of some map themes at http://leaflet-extras.github.io/leaflet-providers/preview/
|
||||
# The following are options for map themes and just work, you should use one of these: “OpenStreetMap”, “Stamen” (Terrain, Toner, and Watercolor),
|
||||
map_theme = 'Stamen Toner'
|
||||
|
||||
# RSS feed link, shows in the link section of each RSS item.
|
||||
rss_link = 'http://localhost:8092'
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
{% include 'page.html' %}
|
||||
{% include 'header.html' %}
|
||||
{{description}}
|
||||
<p> </p>
|
||||
<p>Contact information for this gateway.</p>
|
||||
<table style="margin-left: auto; margin-right: auto;" border="black">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong>Name</strong></td>
|
||||
<td>{{contact_name}} </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Callsign</strong></td>
|
||||
<td> {{contact_call}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>E-Mail</strong></td>
|
||||
<td> {{contact_email}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Website</strong></td>
|
||||
<td> {{contact_website}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p> </p>
|
||||
{% include 'footer.html' %}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<div>
|
||||
<hr />
|
||||
<div style="text-align: center;">Dashboard created by KF7EEL - <a href="https://kf7eel.github.io/hblink3/">https://github.com/kf7eel/hblink3</a><br />HBLink created by N0MJS.<br /><a href="https://github.com/HBLink-org">HBLink GitHub page</a><br />This is branch: <strong>gps<strong></div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,5 +0,0 @@
|
|||
{% include 'page.html' %}
|
||||
{% include 'header.html' %}
|
||||
{{content}}
|
||||
{% include 'footer.html' %}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="{{logo}}" alt="Logo" width="300" height="144" /></p>
|
||||
<h1 style="text-align: center;">{{title}}</h1>
|
||||
<hr />
|
||||
<table style="width: 500px; margin-left: auto; margin-right: auto;" border="black" cellspacing="3" cellpadding="3">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="text-align: center;"><button onclick="window.location.href='/';"> Dashboard Home </button></td>
|
||||
<td style="text-align: center;"><button onclick="window.location.href='/map';"> Station Map </button></td>
|
||||
<td style="text-align: center;"><button onclick="window.location.href='/mailbox';"> The Mailbox </button></td>
|
||||
<td style="text-align: center;"><button onclick="window.location.href='/user';"> User Settings </button></td>
|
||||
<td style="text-align: center;"><button onclick="window.location.href='/help';"> Dashboard Help </button></td>
|
||||
<td style="text-align: center;"><button onclick="window.location.href='/about';"> Gateway Contact </button></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<hr />
|
||||
|
|
@ -1,117 +0,0 @@
|
|||
{% include 'page.html' %}
|
||||
{% include 'header.html' %}
|
||||
<h2 style="text-align: center;">Attention:</h2>
|
||||
<p><span style="color: #ff0000;"><strong>Please be aware that many (if not all) DMR radios DO NOT transmit your callsign when sending a GPS position. It is your responsibility to identify your station per the regulations of your country.</strong></span></p>
|
||||
<p> </p>
|
||||
<p>{{description}}</p>
|
||||
<p>Configure your radio to send GPS positions with the following settings:</p>
|
||||
<table style="margin-left: auto; margin-right: auto;" border="black">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="text-align: center;"><strong>Data Call Type</strong></td>
|
||||
<td style="text-align: center;"><strong>DMR ID</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"> {{data_call_type}}</td>
|
||||
<td style="text-align: center;"> {{data_call_id}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p> </p>
|
||||
<p>When a position is received by this gateway, it will extract the coordinates and create an APRS position packet. This gateway will find your callsign based your radio's DMR ID. It is essential to have your information up to date with <a href="https://radioid.net/">RadioID.net</a>. A predefined APRS SSID of <strong>{{aprs_ssid}}</strong> is appended your callsign. The APRS location packet is then uploaded to APRS-IS. No setup or account creation is required beforehand. This is pretty much "plug and play."</p>
|
||||
<p>For example, N0CALL has a DMR ID of 1234567. N0CALL's radio sends a position to this gateway with the call type settings above. This gateway will query the <a href="https://radioid.net/">RadioID.net</a> database for DMR ID 1234567. The result will be an APRS location packet with APRS SSID {{aprs_ssid}}. </p>
|
||||
<p>You can change the default APRS settings for your radio via SMS.</p>
|
||||
<h2 style="text-align: center;">Commands</h2>
|
||||
<table style="margin-left: auto; margin-right: auto;" border="black">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="text-align: center;">
|
||||
<h4><strong>Command</strong></h4>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<h4><strong>Description</strong></h4>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<h4><strong>Example</strong></h4>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>@COM</strong></td>
|
||||
<td>Change the comment of the APRS.</td>
|
||||
<td><em><code>@COM This is a test comment.</code></em></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>@ICON</strong></td>
|
||||
<td>Change the icon of the APRS position. *See <a href="http://aprs.net/vm/DOS/SYMBOLS.HTM" rel="nofollow">http://aprs.net/vm/DOS/SYMBOLS.HTM</a> for icon list.</td>
|
||||
<td><em><code>@ICON /p</code></em></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>@SSID</strong></td>
|
||||
<td>Change SSID of your callsign.</td>
|
||||
<td><em><code>@SSID 7</code></em></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>@PIN</strong></td>
|
||||
<td>Set a PIN. This is used for changing your APRS settings ia the dashboard. You must set this for each DMR ID you wish to change via the dashboard.</td>
|
||||
<td><em><code>@PIN 1234</code></em></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>@MH</strong></td>
|
||||
<td>Set you location by maidenhead grid square. Designed for radios with no GPS or that are not compatable yet.</td>
|
||||
<td><em><code>@MH DN97uk</code></em></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>@BB</strong></td>
|
||||
<td>Post a bulliten to the web dashboard.</td>
|
||||
<td><em><code>@BB This is a test bulletin.</code></em></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>@[CALLSIGN W/ SSID] A-[MESSAGE]</strong></td>
|
||||
<td>Send a message to another station via APRS.</td>
|
||||
<td><em><code>@N0CALL-15 A-This is a test.</code></em></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>[EMAIL ADDRESS] E-[MESSAGE]</strong></td>
|
||||
<td>Send an email to an email address.</td>
|
||||
<td><em><code>test@example.org E-This is a test.</code></em></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>@[RECIPIENT CALLSIGN] M-[MESSAGE]</strong></td>
|
||||
<td>Post a message to the Mailbox.</td>
|
||||
<td><em>@N0CALL M-This is a test.</em></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>@REM MAIL</strong></td>
|
||||
<td>Remove all mail addressed to you.</td>
|
||||
<td><em>@REM MAIL</em></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>@SOS</strong></td>
|
||||
<td>EMERGENCY activation displays a banner on the main dashboard page.</td>
|
||||
<td><em>THIS IS AN EMERGENCY. @SOS</em></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>@NOTICE</strong></td>
|
||||
<td>Used to prominantly display a notice, similar to EMERGENCY activation.</td>
|
||||
<td><em>@NOTICE Server going down at 1800</em></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>@REM SOS</strong></td>
|
||||
<td>Removes an EMERGENCY or notice.</td>
|
||||
<td><em>@REM SOS</em></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p> </p>
|
||||
<p><strong>Commands should be in upper case.</strong> Send an SMS to <strong>{{data_call_id}}</strong> as a <strong>{{data_call_type}}</strong> with the desired command followed by the value. For example, to change your icon to a dog, the command would be <code>@ICON /p</code> (see the icon table for values). Changing your SSID is as simple as <code>@SSID 7</code>, and <code>@COM Testing 123</code> will change the comment.</p>
|
||||
<p>Sending <code>@BB Test</code> will result in a post to the bulletin board with the messaage of "Test".</p>
|
||||
<p><strong>To remove any of the stored values, just send the appropriate command without any input.</strong> <code>@COM</code> will remove the stored comment, <code>@ICON</code> will remove the stored icon, and <code>@ICON</code> will remove the strored icon. Any position reports sent will have the default settings.</p>
|
||||
|
||||
<h3 style="text-align: center;">EMERGENCY Activation</h3>
|
||||
<p>The EMERGENCY Activation function will display a prominant banner accross the main dashboard page. The banner contains a message, time, callsign of station, and a link to the last known location of the station. This feature is intended to be used in situations where a user is in distress. To trigger an EMERGENCY activation, simply send an SMS to <strong>{{data_call_id}}</strong> with <strong>@SOS</strong> in the message. The <strong>@SOS</strong> command can be anywhere in the message. A less intimidating banner can be displayed for testing, or other purposes, by using <strong>@NOTICE</strong>. To remove the EMERGENCY activation, simply send the <strong>@REM SOS</strong> command.</p>
|
||||
<h3 style="text-align: center;">The Map</h3>
|
||||
<p>This dashboard now has a built in map. The map will display the last know location of stations and some previous plots from them. You can track a station by clicking on the red pin, and selecting the <strong>Track Station</strong> link. When tracking a station, you have a few options for a refresh rate, located in a drop down menu.</p>
|
||||
<h3 style="text-align: center;">The Mailbox</h3>
|
||||
<p>The Mailbox is a place where users can leave messages via DMR SMS. A user can leave a message for someone else by sending a formatted SMS to <strong>{{data_call_id}}</strong>. See the table above for a syntax example of posting a message to the Mailbox. The message recipient can then use the mailbox to check for messages. Message recipients can delete all of their messages by sending the command <strong>@REM MAIL</strong>. There is no way to remove a single message, it's all or none.</p>
|
||||
|
||||
{% include 'footer.html' %}
|
|
@ -1,49 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="refresh" content="120" >
|
||||
<title>{{title}}</title>
|
||||
<style>
|
||||
body {background-color: D3D3D3;}
|
||||
h1 {color: green;}
|
||||
p {
|
||||
padding: 10px;
|
||||
margin: 20px;
|
||||
|
||||
}
|
||||
.content {
|
||||
max-width: 1200px;
|
||||
min-width: 1200px;
|
||||
margin: auto;
|
||||
}
|
||||
.emergency_button {
|
||||
display: block;
|
||||
width: 100%;
|
||||
border: none;
|
||||
background-color: ##ff0000;
|
||||
padding: 14px 28px;
|
||||
font-size: 16px;
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<div class="content">
|
||||
<body>
|
||||
{% include 'header.html' %}
|
||||
{{emergency}}
|
||||
<p style="text-align: center;"><em>Page automatically reloads every 2 minutes.</em></p>
|
||||
<h4 style="text-align: center;"><a href="bulletin_rss.xml"><em>Bulletin Board RSS Feed</em></a><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH5QIcFBAOXAevLAAAAZZJREFUSMftlbtKA0EUhj8jWhi8gaIEC29oxEoRFESLgIXYiWVSKoj6CCrBBwj6CBHNE1hEWy21ETQqiIW1wXhPo81ZOBw2apbdVPvDsDPnP8M/5zKzECJEQKivYO8DFoAYEAGKtTpQEvhW4w3IA+tAVy2F9fgEskA8COHUL8LOKAMZoMmLQF0FewcwImmNAzPANBB18b0BFoGroNLfBiyLgI2+BMwF3XgNwCrwYsQ//BBPSRPdAoeybjE+A8ClS+Sjfnf1E5A2dW4FzoxfwWvD/XWd7oAxI24jz3gVnpS7eiEpt+KvQEL5D5qal/245zFgU+pnXzMd+Zrh9/3q5l7g3CXtTs0bgWvFffn5vDa7iKcVv2K4DS8i3cAOsAuMm8h12ovqqrVL/R3upFrRKPBgHgctvm0iSynuWNnf5bf6byy5dPKe4nukhg6XU9yW2TfsJlDpNCUX27OaP8pD4WBCzQtmX381EUeAI3Xqe6m5xoHpYAezJuJkNb9Fh0tI4+SlXhpTwJBaZ+XbCcwr+6kcPESI2uAHmAijFaMnEmYAAAAASUVORK5CYII=" /></h4>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><div><p align="center"><iframe style="border: none;" title="Bulletin Board" src="bulletin_board" width="480" height="950"></iframe></p></div></td>
|
||||
<td><div>
|
||||
<p align="center"><iframe style="border: none;" title="Positions Received" src="positions" width="620" height="950"></iframe></p>
|
||||
</div></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{% include 'footer.html' %}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
{% include 'page.html' %}
|
||||
{% include 'header.html' %}
|
||||
<p style="text-align: center;"><span style="color: #ff0000;"><strong>Red</strong></span>: Last location received. <span style="color: #0000ff;"><strong>Blue</strong></span>: Location history.</p>
|
||||
<p style="text-align: center;"> </p>
|
||||
<div><p align="center"><iframe style="border: none;" title="Map" src="/view_map?track=" width="1100" height="700"></iframe></p></div>
|
||||
<p> </p>
|
||||
{% include 'footer.html' %}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{{title}}</title>
|
||||
<style>
|
||||
body {background-color: D3D3D3;}
|
||||
h1 {color: green;}
|
||||
p {
|
||||
padding: 10px;
|
||||
margin: 20px;
|
||||
|
||||
}
|
||||
.content {
|
||||
max-width: 1200px;
|
||||
min-width: 1200px;
|
||||
margin: auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<div class="content">
|
||||
<body>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,91 @@
|
|||
|
||||
'''
|
||||
Settings for HBNet Web Server.
|
||||
'''
|
||||
# Database options
|
||||
# Using SQLite is simple and easiest. Comment out this line and uncomment the MySQL
|
||||
# line to use a MySQL/MariaDB server.
|
||||
db_location = 'sqlite:///hbnet.sqlite'
|
||||
|
||||
# Uncomment and change this line to use a MySQL DB. It is best to start with a fresh
|
||||
# DB without data in it.
|
||||
|
||||
#db_location = 'mysql+pymysql://DB_USERNAME:DB_PASSWORD@DB_HOST:MySQL_PORT/DB_NAME'
|
||||
|
||||
|
||||
# Title of the HBNet Web Service/DMR network
|
||||
title = 'HBNet Web Service'
|
||||
# Port to run server
|
||||
hws_port = 8080
|
||||
# IP to run server on
|
||||
hws_host = '127.0.0.1'
|
||||
# Publicly accessible URL of the web server. THIS IS REQUIRED AND MUST BE CORRECT.
|
||||
url = 'http://localhost:8080'
|
||||
# Replace below with some random string such as an SHA256
|
||||
secret_key = 'SUPER SECRET LONG KEY'
|
||||
|
||||
# Default state for newly created user accounts. Setting to False will require
|
||||
# the approval of an admin user before the user can login.
|
||||
default_account_state = True
|
||||
|
||||
# Legacy passphrase used in hblink.cfg
|
||||
legacy_passphrase = 'passw0rd'
|
||||
|
||||
# Coordinates to center map over
|
||||
center_map = [45.372, -121.6972]
|
||||
# Default map zoom level
|
||||
map_zoom = 5
|
||||
|
||||
# Passphrase calculation config. If REMOTE_CONFIG is not used in your DMR server config
|
||||
# (hblink.cfg), then the values in section [USER_MANAGER] MUST match the values below.
|
||||
# If REMOTE_CONFIG is enabled, the DMR server (hblink) will automatically use the values below.
|
||||
# These config options affect the generation of user passphrases.
|
||||
|
||||
# Set to a value between 1 - 99. This value is used in the normal calculation.
|
||||
append_int = 1
|
||||
|
||||
# Set to a value between 1 - 99. This value is used for compromised passphrases.
|
||||
burn_int = 5
|
||||
|
||||
# Set to a value between 1 - 99 This value is used in the normal calculation.
|
||||
extra_int_1 = 5
|
||||
|
||||
# Set to a value between 1 - 99 This value is used in the normal calculation.
|
||||
extra_int_2 = 8
|
||||
|
||||
# Set to a length of about 10 characters.
|
||||
extra_1 = 'TeSt'
|
||||
extra_2 = 'DmR4'
|
||||
|
||||
# Shorten generated passphrases
|
||||
use_short_passphrase = True
|
||||
|
||||
# Character length of shortened passphrase
|
||||
shorten_length = 6
|
||||
# How often to pick character from long passphrase when shortening.
|
||||
shorten_sample = 4
|
||||
|
||||
# Email settings
|
||||
MAIL_SERVER = 'smtp.gmail.com'
|
||||
MAIL_PORT = 465
|
||||
MAIL_USE_SSL = True
|
||||
MAIL_USE_TLS = False
|
||||
MAIL_USERNAME = 'app@gmail.com'
|
||||
MAIL_PASSWORD = 'password'
|
||||
MAIL_DEFAULT_SENDER = '"' + title + '" <app@gmail.com>'
|
||||
|
||||
# User settings settings
|
||||
USER_ENABLE_EMAIL = True
|
||||
USER_ENABLE_USERNAME = True
|
||||
USER_REQUIRE_RETYPE_PASSWORD = True
|
||||
USER_ENABLE_CHANGE_USERNAME = False
|
||||
USER_ENABLE_MULTIPLE_EMAILS = True
|
||||
USER_ENABLE_CONFIRM_EMAIL = True
|
||||
USER_ENABLE_REGISTER = True
|
||||
USER_AUTO_LOGIN_AFTER_CONFIRM = False
|
||||
USER_SHOW_USERNAME_DOES_NOT_EXIST = True
|
||||
|
||||
|
||||
# Time format for display on some pages
|
||||
time_format = '%H:%M:%S - %m/%d/%y'
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
def gen_script(dmr_id, passphrase):
|
||||
script = '''
|
||||
DMR ID: ''' + str(dmr_id) + ''' \n Passphrase: ''' + str(passphrase) + '''
|
||||
'''
|
||||
return script
|
|
@ -0,0 +1,43 @@
|
|||
# Function to generate a script for Pi-Star that adds MASTER instances and generated passphrases to DMR_Hosts.txt.
|
||||
|
||||
def gen_script(dmr_id, svr_lst):
|
||||
auth_contents = ''
|
||||
header = '''
|
||||
## DMR_hosts.txt, generated by HBNet.
|
||||
|
||||
########################################################################################################
|
||||
### Name DMR-ID IP/Hostname Password Port #
|
||||
########################################################################################################
|
||||
\n'''
|
||||
for i in svr_lst:
|
||||
## print(i[1])
|
||||
auth_contents = auth_contents + str(i[0]) + '''\t\t\t\t''' + str(dmr_id) + '''\t''' + i[1] + '''\t\t\t\t''' + i[2] + '''\t\t''' + str(i[3]) + '\n'
|
||||
## print(header)
|
||||
## print(auth_contents)
|
||||
|
||||
|
||||
## return header + auth_contents
|
||||
|
||||
output = '''
|
||||
#!/usr/bin/python3
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
os.chdir('/root')
|
||||
if Path('/root/DMR_Hosts.txt').is_file():
|
||||
print('DMR_Hosts.txt exists, adding entries...')
|
||||
with open('/root/DMR_Hosts.txt', 'a') as dmr_hosts:
|
||||
dmr_hosts.write("""''' + auth_contents + '''""")
|
||||
dmr_hosts.close()
|
||||
|
||||
else:
|
||||
Path('/root/DMR_Hosts.txt').touch()
|
||||
print('DMR_Hosts.txt does not exist, creating...')
|
||||
with open('/root/DMR_Hosts.txt', 'w') as dmr_hosts:
|
||||
dmr_hosts.write("""''' + header + auth_contents + '""")' + '''
|
||||
dmr_hosts.close()
|
||||
print('DMR Host file updates.')'''
|
||||
print(output)
|
||||
return output
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
configparser>=3.0.0
|
||||
flask
|
||||
flask_user
|
||||
flask_sqlalchemy
|
||||
email_validator
|
||||
flask_babelex
|
||||
pymysql
|
||||
folium
|
||||
requests
|
||||
libscrc
|
||||
dmr_utils3
|
||||
cryptography
|
||||
uwsgi
|
Binary file not shown.
After Width: | Height: | Size: 63 KiB |
|
@ -0,0 +1,70 @@
|
|||
{% extends 'flask_user/_public_base.html' %}
|
||||
{% block content %}
|
||||
|
||||
<h1 style="text-align: center;">Manage Mail</h1>
|
||||
|
||||
Use <strong>*all</strong> to send an internal message to all users. To send a message to multiple users, use a comma (<strong>,</strong>) to separate usernames.
|
||||
|
||||
|
||||
|
||||
<div id="compose" class="collapse">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">Send internal message to another user</div>
|
||||
<div class="card-body">
|
||||
|
||||
<form action="{{ current_user.username or current_user.email }}?send_mail=true" method="post">
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text" id="basic-addon1">Username</span>
|
||||
<input type="text" id="username" name="username" class="form-control" aria-label="Username" aria-describedby="basic-addon1">
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<span class="input-group-text">Message</span>
|
||||
<textarea id="message" name="message" class="form-control" aria-label="Message"></textarea>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
<p style="text-align: center;"><input class="btn btn-primary" type="submit" value="Send" /></form></p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{% if show_mail %}
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<p style="text-align: right;"><button data-bs-toggle="collapse" data-bs-target="#compose" class="btn btn-primary">Compose</button></p>
|
||||
|
||||
<table data-toggle="table" data-pagination="true" data-search="true" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th>From</th>
|
||||
<th>Message</th>
|
||||
<th>Time</th>
|
||||
<th>Options</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{{markup_content}}
|
||||
|
||||
</tbody></table>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if not show_mail %}
|
||||
{{markup_content}}
|
||||
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
|
||||
<p> </p>
|
||||
{% endblock %}
|
|
@ -0,0 +1,25 @@
|
|||
{% extends 'flask_user/_public_base.html' %}
|
||||
{% block content %}
|
||||
|
||||
<p> </p>
|
||||
<h1 style="text-align: center;">Last Known Location</h1>
|
||||
|
||||
<div class="row container-fluid" >
|
||||
<div class="col-sm-12">
|
||||
<table data-toggle="table" data-pagination="true" data-search="true" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Callsign</th>
|
||||
<th>Latitude</th>
|
||||
<th>Longitude</th>
|
||||
<th>Time</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{markup_content}}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p> </p>
|
||||
{% endblock %}
|
|
@ -0,0 +1,31 @@
|
|||
{% extends 'flask_user/_public_base.html' %}
|
||||
{% block content %}
|
||||
|
||||
<h1 style="text-align: center;">Bulletin Board</h1>
|
||||
<p style="text-align: center;"><a href="bulletin_rss.xml"><em>RSS Feed</em></a><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH5QIcFBAOXAevLAAAAZZJREFUSMftlbtKA0EUhj8jWhi8gaIEC29oxEoRFESLgIXYiWVSKoj6CCrBBwj6CBHNE1hEWy21ETQqiIW1wXhPo81ZOBw2apbdVPvDsDPnP8M/5zKzECJEQKivYO8DFoAYEAGKtTpQEvhW4w3IA+tAVy2F9fgEskA8COHUL8LOKAMZoMmLQF0FewcwImmNAzPANBB18b0BFoGroNLfBiyLgI2+BMwF3XgNwCrwYsQ//BBPSRPdAoeybjE+A8ClS+Sjfnf1E5A2dW4FzoxfwWvD/XWd7oAxI24jz3gVnpS7eiEpt+KvQEL5D5qal/245zFgU+pnXzMd+Zrh9/3q5l7g3CXtTs0bgWvFffn5vDa7iKcVv2K4DS8i3cAOsAuMm8h12ovqqrVL/R3upFrRKPBgHgctvm0iSynuWNnf5bf6byy5dPKe4nukhg6XU9yW2TfsJlDpNCUX27OaP8pD4WBCzQtmX381EUeAI3Xqe6m5xoHpYAezJuJkNb9Fh0tI4+SlXhpTwJBaZ+XbCcwr+6kcPESI2uAHmAijFaMnEmYAAAAASUVORK5CYII=" /></p>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<table data-toggle="table" data-pagination="true" data-search="true" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Callsign</th>
|
||||
<th>Bulltein</th>
|
||||
<th>Time</th>
|
||||
<th>Server</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{{markup_content}}
|
||||
|
||||
</tbody></table>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p> </p>
|
||||
{% endblock %}
|
|
@ -0,0 +1,31 @@
|
|||
{% extends 'flask_user/_authorized_base.html' %}
|
||||
|
||||
{% block content %}
|
||||
{% from "flask_user/_macros.html" import render_field, render_checkbox_field, render_submit_field %}
|
||||
<h1>{%trans%}User profile{%endtrans%}</h1>
|
||||
|
||||
<form action="" method="POST" class="form" role="form">
|
||||
{{ form.hidden_tag() }}
|
||||
{% for field in form %}
|
||||
{% if not field.flags.hidden %}
|
||||
{% if field.type=='SubmitField' %}
|
||||
{{ render_submit_field(field, tabindex=loop.index*10) }}
|
||||
{% else %}
|
||||
{{ render_field(field, tabindex=loop.index*10) }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</form>
|
||||
<br/>
|
||||
{% if not user_manager.USER_ENABLE_AUTH0 %}
|
||||
{% if user_manager.USER_ENABLE_CHANGE_USERNAME %}
|
||||
<p><a href="{{ url_for('user.change_username') }}">{%trans%}Change username{%endtrans%}</a></p>
|
||||
{% endif %}
|
||||
{% if user_manager.USER_ENABLE_CHANGE_PASSWORD %}
|
||||
<p><a href="{{ url_for('user.change_password') }}">{%trans%}<button type="button" class="btn btn-warning">Change Portal Passord</button>{%endtrans%}</a></p>
|
||||
{% endif %}
|
||||
<p><a href="../update_ids"><strong><button type="button" class="btn btn-danger">Update your information from RadioID.net</button></strong></a></p>
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1,8 @@
|
|||
<p>Dear {{ user.email }} - {{ user.username }},</p>
|
||||
|
||||
{% block message %}
|
||||
{% endblock %}
|
||||
|
||||
<p>Sincerely,<br/>
|
||||
{{ app_name }}
|
||||
</p>
|
|
@ -0,0 +1,74 @@
|
|||
{% extends 'flask_user/_public_base.html' %}
|
||||
|
||||
{% block content %}
|
||||
{% from "flask_user/_macros.html" import render_field, render_checkbox_field, render_submit_field %}
|
||||
<h1>{%trans%}Sign in{%endtrans%}</h1>
|
||||
<p> </p>
|
||||
|
||||
<strong>Your username MUST be your callsign or email address.</strong>
|
||||
<p> </p>
|
||||
|
||||
<form action="" method="POST" class="form" role="form">
|
||||
{{ form.hidden_tag() }}
|
||||
|
||||
{# Username or Email field #}
|
||||
{% set field = form.username if user_manager.USER_ENABLE_USERNAME else form.email %}
|
||||
<div class="form-group {% if field.errors %}has-error{% endif %}">
|
||||
{# Label on left, "New here? Register." on right #}
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<label for="{{ field.id }}" class="control-label"><strong>{{ field.label.text }}</strong></label>
|
||||
</div>
|
||||
<div class="col-xs-6 text-right">
|
||||
{% if user_manager.USER_ENABLE_REGISTER and not user_manager.USER_REQUIRE_INVITATION %}
|
||||
<a href="{{ url_for('user.register') }}" tabindex='190'>
|
||||
{%trans%}New here? Register.{%endtrans%}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{{ field(class_='form-control', tabindex=110) }}
|
||||
{% if field.errors %}
|
||||
{% for e in field.errors %}
|
||||
|
||||
|
||||
<p class="help-block"><strong>{{ e }}</strong></p>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
||||
{# Password field #}
|
||||
{% set field = form.password %}
|
||||
<div class="form-group {% if field.errors %}has-error{% endif %}">
|
||||
{# Label on left, "Forgot your Password?" on right #}
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<label for="{{ field.id }}" class="control-label"><strong>{{ field.label.text }}</strong></label>
|
||||
</div>
|
||||
<div class="col-xs-6 text-right">
|
||||
{% if user_manager.USER_ENABLE_FORGOT_PASSWORD %}
|
||||
<a href="{{ url_for('user.forgot_password') }}" tabindex='195'>
|
||||
{%trans%}Forgot your Password?{%endtrans%}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{{ field(class_='form-control', tabindex=120) }}
|
||||
{% if field.errors %}
|
||||
{% for e in field.errors %}
|
||||
|
||||
|
||||
<p class="help-block"><strong>{{ e }}</strong></p>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{# Remember me #}
|
||||
{% if user_manager.USER_ENABLE_REMEMBER_ME %}
|
||||
{{ render_checkbox_field(login_form.remember_me, tabindex=130) }}
|
||||
{% endif %}
|
||||
|
||||
{# Submit button #}
|
||||
{{ render_submit_field(form.submit, tabindex=180) }}
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1,66 @@
|
|||
{% extends 'flask_user/_public_base.html' %}
|
||||
|
||||
{% block content %}
|
||||
{% from "flask_user/_macros.html" import render_field, render_submit_field %}
|
||||
<h1>{%trans%}Register{%endtrans%}</h1>
|
||||
<p> </p>
|
||||
|
||||
<strong>Your username MUST be your callsign.</strong> After filling out the fields, a confirmation link may be emailed to you.
|
||||
<hr />
|
||||
<p> </p>
|
||||
By registering, you acknowledge that you agree to the Terms of Use.
|
||||
<p> </p>
|
||||
|
||||
<p style="text-align: center;"><a href="/tos"><button type="button" class="btn btn-primary">Terms of Use</button></a></p>
|
||||
<p> </p>
|
||||
<hr />
|
||||
<p> </p>
|
||||
|
||||
<form action="" method="POST" novalidate formnovalidate class="form" role="form">
|
||||
{{ form.hidden_tag() }}
|
||||
|
||||
{# Username or Email #}
|
||||
{% set field = form.username if user_manager.USER_ENABLE_USERNAME else form.email %}
|
||||
<div class="form-group {% if field.errors %}has-error{% endif %}">
|
||||
{# Label on left, "Already registered? Sign in." on right #}
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<label for="{{ field.id }}" class="control-label"><strong>{{ field.label.text }}</strong></label>
|
||||
</div>
|
||||
<div class="col-xs-6 text-right">
|
||||
{% if user_manager.USER_ENABLE_REGISTER %}
|
||||
<a href="{{ url_for('user.login') }}" tabindex='290'>
|
||||
{%trans%}Already registered? Sign in.{%endtrans%}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{ field(class_='form-control', tabindex=210) }}
|
||||
{% if field.errors %}
|
||||
{% for e in field.errors %}
|
||||
|
||||
|
||||
<p class="help-block"><strong>{{ e }}</strong></p>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
||||
{% if user_manager.USER_ENABLE_EMAIL and user_manager.USER_ENABLE_USERNAME %}
|
||||
{{ render_field(form.email, tabindex=220) }}
|
||||
|
||||
{% endif %}
|
||||
|
||||
{{ render_field(form.password, tabindex=230) }}
|
||||
|
||||
{% if user_manager.USER_REQUIRE_RETYPE_PASSWORD %}
|
||||
{{ render_field(form.retype_password, tabindex=240) }}
|
||||
{% endif %}
|
||||
|
||||
{{ render_submit_field(form.submit, tabindex=280) }}
|
||||
</form>
|
||||
|
||||
<p> </p>
|
||||
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1,182 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{{ user_manager.USER_APP_NAME }}</title>
|
||||
|
||||
<!-- Bootstrap -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://unpkg.com/bootstrap-table@1.15.5/dist/bootstrap-table.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css">
|
||||
|
||||
|
||||
<!-- In-lining styles to avoid needing a separate .css file -->
|
||||
<style>
|
||||
hr { border-color: #cccccc; margin: 0; }
|
||||
.no-margins { margin: 0px; }
|
||||
.with-margins { margin: 10px; }
|
||||
.col-centered { float: none; margin: 0 auto; }
|
||||
</style>
|
||||
|
||||
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
|
||||
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7/html5shiv.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
{# *** Allow sub-templates to insert extra html to the head section *** #}
|
||||
{% block extra_css %}{% endblock %}
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
|
||||
<p><img class="img-responsive" style="display: block; margin-left: auto; margin-right: auto;" src="{{ url_for('static', filename='HBnet.png') }}" alt="Logo" width="300" height="144" /></p>
|
||||
<h2 class="card-body" style="text-align: center;">{{ user_manager.USER_APP_NAME }}</h2>
|
||||
<hr />
|
||||
|
||||
<!-- A grey horizontal navbar that becomes vertical on small screens -->
|
||||
<nav class="navbar navbar-expand-sm bg-light">
|
||||
|
||||
<div class="container-fluid">
|
||||
|
||||
<!-- Links -->
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{url}}/"><i class="bi bi-house-fill"></i> Home </a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{url}}/talkgroups"><i class="bi bi-card-list"></i> Talkgroups </a>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{url}}/map"><i class="bi bi-map"></i> Map </a>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="aprs_menu" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="bi bi-hash"></i> Data
|
||||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="aprs_menu">
|
||||
<li><a class="dropdown-item" href="{{url}}/aprs"><i class="bi bi-geo"></i> APRS Dashboard </a></li>
|
||||
<li><a class="dropdown-item" href="{{url}}/sms"><i class="bi bi-chat-right-text"></i> SMS Log </a></li>
|
||||
<li><a class="dropdown-item" href="{{url}}/bb"><i class="bi bi-clipboard"></i> Bulletin Board </a></li>
|
||||
<li><a class="dropdown-item" href="{{url}}/ss"><i class="bi bi-people"></i> Social Status </a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{url}}/news"><i class="bi bi-newspaper"></i> News </a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{url}}/help"><i class="bi bi-question-square"></i> Help </a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<ul class="navbar-nav">
|
||||
{% if not call_or_get(current_user.is_authenticated) %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url_for('user.login') }}"><i class="bi bi-door-open"></i> Sign In </a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url_for('user.register') }}"><i class="bi bi-person-plus"></i> Register </a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if call_or_get(current_user.is_authenticated) %}
|
||||
<!--Admin Menu -->
|
||||
{% if call_or_get(current_user.has_roles('Admin')) %}
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="aprs_menu" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="bi bi-tools"></i> Admin
|
||||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="mmdvm_admin">
|
||||
<li><a class="dropdown-item" href="{{url}}/manage_servers">Manage Servers</a></li>
|
||||
<li><a class="dropdown-item" href="{{url}}/manage_peers">Manage Peers</a></li>
|
||||
<li><a class="dropdown-item" href="{{url}}/manage_masters">Manage Masters</a></li>
|
||||
<li><a class="dropdown-item" href="{{url}}/manage_rules">Manage Rules</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="{{url}}/add_user">Add User</a></li>
|
||||
<li><a class="dropdown-item" href="{{url}}/list_users">Manage Users</a></li>
|
||||
<li><a class="dropdown-item" href="{{url}}/approve_users">Waiting Approval</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="{{url}}/manage_news">Manage News</a></li>
|
||||
<li><a class="dropdown-item" href="{{url}}/misc_settings">Misc Options</a></li>
|
||||
<li><a class="dropdown-item" href="{{url}}/auth_log">Authorization Log</a></li>
|
||||
<a class="dropdown-item" href="{{url}}/all_mail/{{ current_user.username or current_user.email }}">Manage Mail</a>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{url}}/mail/{{ current_user.username or current_user.email }}"><i class="bi bi-mailbox"></i> Mailbox </a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{url}}/generate_passphrase"><i class="bi bi-info-square"></i> Passphrase(s) </a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url_for('user.edit_user_profile') }}"><i class="bi bi-file-person"></i> Change {{ current_user.username or current_user.email }} </a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url_for('user.logout') }}"><i class="bi bi-door-closed"></i> Sign Out </a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
{% block body %}
|
||||
|
||||
<hr class="no-margins"/>
|
||||
|
||||
<div id="main-div" class="with-margins">
|
||||
{# One-time system messages called Flash messages #}
|
||||
{% block flash_messages %}
|
||||
{%- with messages = get_flashed_messages(with_categories=true) -%}
|
||||
{% if messages %}
|
||||
{% for category, message in messages %}
|
||||
{% if category=='error' %}
|
||||
{% set category='danger' %}
|
||||
{% endif %}
|
||||
<div class="alert alert-{{category}}">{{ message|safe }}</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{%- endwith %}
|
||||
{% endblock %}
|
||||
{% block main %}
|
||||
{% block content %}
|
||||
|
||||
{{markup_content}}
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
<hr class="no-margins"/>
|
||||
<div id="footer-div" class="clearfix with-margins">
|
||||
<p style="text-align: center;"><strong>{{ user_manager.USER_APP_NAME }}<br /></strong><a href="https://hbnet.xyz">HBNet Project</a><br />V. <strong>Dev</strong> </p>
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
|
||||
<!-- Bootstrap -->
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW" crossorigin="anonymous"></script>
|
||||
<script src="https://unpkg.com/bootstrap-table@1.18.3/dist/bootstrap-table.min.js"></script>
|
||||
|
||||
|
||||
{# *** Allow sub-templates to insert extra html to the bottom of the body *** #}
|
||||
{% block extra_js %}{% endblock %}
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,37 @@
|
|||
{% extends 'flask_user/_public_base.html' %}
|
||||
{% block content %}
|
||||
|
||||
<h3 style="text-align: center;">Registration</h3>
|
||||
<p>To register for access , click the <a href="/user/register">Register</a> link. <strong>Your username MUST be your callsign. </strong>Information for you account is pulled from <a href="https://www.radioid.net/">RadioID.net</a>, including all associated DMR IDs with your callsign. After filling out the fields, a confirmation link may be emailed to you. After confirming your email address, your account may be reviewed and approved by an administrator. You may receive an email when your account is approved.</p>
|
||||
<p> </p>
|
||||
<h3 style="text-align: center;">Hotspot/Repeater Login</h3>
|
||||
<p>To find your passphrase(s) for use with the MMDVM server(s), click on the <a href="/generate_passphrase">Passphrase(s)</a> link. This page will display a unique passphrase for each of your DMR IDs. Use the desired DMR ID and passphrase in your hotspot/repeater configuration. Each passphrase is also spelled phonetically for ease of manual entry. A special script to automatically add our MMDVM servers to Pi-Star is available by clicking on link provided on the View Passphrase(s) page (also available <a href="/generate_passphrase/pi-star">here</a>).</p>
|
||||
<p> </p>
|
||||
<h3 style="text-align: center;">Updating DMR ID Information</h3>
|
||||
<p>If you recently added a DMR ID to <a href="https://www.radioid.net/">RadioID.net</a>, or made any change, you can update your account by clicking on the <a href="/update_ids">update link</a> on the <a href="/user/edit_user_profile">user profile settings</a> page.</p>
|
||||
<p> </p>
|
||||
<h3 style="text-align: center;">Talkgroups</h3>
|
||||
<p>You may view a list of all talkgroups by going to the <a href="talkgroups">Talkgroups</a> page. Click on the talkgroup name for more information. A CSV file is available for download and may be used in the CPS of some radios. Talkgroups listed there may not be available on all servers if there are multiple. You may find a list of talkgroups available on each server by going to the <a href="/generate_passphrase">Passphrase(s)</a> page.</p>
|
||||
<p> </p>
|
||||
<h3 style="text-align: center;">MMDVM Options</h3>
|
||||
<p>Options are like a type of command that your hotspot/repeater sends to the server for various functions. The following options are supported:</p>
|
||||
<div class="container-fluid">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Option</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>NO_MAP</td>
|
||||
<td>This option will prevent your hotspot/repeater from plotting on the map. <strong>This option may also be entered into the Location field of your hotspot, if your hotspot doesn't have an options field.</strong></td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<p>You can add multiple options by separating them using a semicolon (<strong>;</strong>). <br />
|
||||
Example: <pre>OPTION_1;OPTION_2</pre>
|
||||
{% endblock %}
|
|
@ -0,0 +1,29 @@
|
|||
{% extends 'flask_user/_public_base.html' %}
|
||||
{% block content %}
|
||||
<p> </p>
|
||||
|
||||
<div class="row">
|
||||
|
||||
|
||||
{{content_block}}
|
||||
|
||||
|
||||
<div class="col-lg-6">
|
||||
|
||||
<p> </p>
|
||||
<table style="margin-left: auto; margin-right: auto;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="text-align: center;">
|
||||
<h4>Latest News:</h4>
|
||||
{{news}}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p> </p>
|
||||
{% endblock %}
|
|
@ -0,0 +1,68 @@
|
|||
{% extends 'flask_user/_public_base.html' %}
|
||||
{% block content %}
|
||||
|
||||
<h1 style="text-align: center;">Mail</h1>
|
||||
|
||||
|
||||
|
||||
<div id="compose" class="collapse">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">Send internal message to another user</div>
|
||||
<div class="card-body">
|
||||
|
||||
<form action="{{ current_user.username or current_user.email }}?send_mail=true" method="post">
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text" id="basic-addon1">Username</span>
|
||||
<input type="text" id="username" name="username" class="form-control" aria-label="Username" aria-describedby="basic-addon1">
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<span class="input-group-text">Message</span>
|
||||
<textarea id="message" name="message" class="form-control" aria-label="Message"></textarea>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
<p style="text-align: center;"><input class="btn btn-primary" type="submit" value="Send" /></form></p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{% if show_mail %}
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<p style="text-align: right;"><button data-bs-toggle="collapse" data-bs-target="#compose" class="btn btn-primary">Compose</button></p>
|
||||
|
||||
<table data-toggle="table" data-pagination="true" data-search="true" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th>From</th>
|
||||
<th>Message</th>
|
||||
<th>Time</th>
|
||||
<th>Options</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{{markup_content}}
|
||||
|
||||
</tbody></table>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if not show_mail %}
|
||||
{{markup_content}}
|
||||
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
|
||||
<p> </p>
|
||||
{% endblock %}
|
|
@ -0,0 +1,28 @@
|
|||
{% extends 'flask_user/_public_base.html' %}
|
||||
{% block content %}
|
||||
|
||||
<p> </p>
|
||||
<div class="well">Map of connected peers and GPS locations. <br />
|
||||
To diasble map plotting for your hotspot or repeater, see the <strong>MMDVM Options</strong> section in <a href="/help"><strong>Help</strong></a>.
|
||||
<p> </p>
|
||||
|
||||
<table border="1">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><span style="color: #ff0000;"><strong>Red</strong></span> = Peer location (no APRS)</td>
|
||||
<td><span style="color: #0000ff;"><strong>Blue</strong></span> = GPS location (APRS)</td>
|
||||
<td><strong><span style="color: #00ff00;">Green</span></strong> = Peer location (APRS)</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="row container-fluid" >
|
||||
<div class="col-xs-12">
|
||||
{{markup_content}}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p> </p>
|
||||
{% endblock %}
|
|
@ -0,0 +1,9 @@
|
|||
{% extends 'flask_user/_public_base.html' %}
|
||||
{% block content %}
|
||||
<p style="text-align: center;"><a href="/news?all_news=true"><strong><button type="button" class="btn btn-primary">View All News</button></strong></a></p>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">{{markup_content}}</div>
|
||||
</div>
|
||||
|
||||
<p> </p>
|
||||
{% endblock %}
|
|
@ -0,0 +1,34 @@
|
|||
{% extends 'flask_user/_public_base.html' %}
|
||||
{% block content %}
|
||||
|
||||
|
||||
<div class="card" >
|
||||
<div class="panel-heading" style="text-align: center;"><h4>Pi-Star Instructions</h4></div>
|
||||
<div class="panel-body">
|
||||
<p> </p>
|
||||
A script to enable the use of this network on a Pi-Star device is available. This script will automatically add information, including your generated passphrase and each Master/Proxy instance
|
||||
on this network, to your device's DMR_Hosts.txt. This will allow you to connect to this network in the Pi-Star configuration page.
|
||||
<p> </p>
|
||||
|
||||
A script(s) is generated for each of your DMR IDs when you load this page. Each link/command is valid for only one use. If you need execute a command again,
|
||||
simply reload the page to get a fresh link.
|
||||
<p> </p>
|
||||
<hr />
|
||||
<p> </p>
|
||||
|
||||
<p><strong>1</strong>: Log into your Pi-Star device via SSH. <br />
|
||||
<strong>2</strong>: Become <strong>root</strong> user. DMR_Hosts.txt is stored in /root, thus you need to be root to modify it.
|
||||
<pre>sudo su</pre><br />
|
||||
<strong>3</strong>: Decide which DMR ID you want Pi-Star to login with. Copy and past one of the commands below to update DMR_Hosts.txt. Each command is specific to a DMR ID.<br />
|
||||
|
||||
<p> </p>
|
||||
|
||||
{{markup_content}}
|
||||
<p> </p>
|
||||
|
||||
If you were sucessful, you can now go into the Pi-Star configuration and select this network from the dropdown list.
|
||||
</div>
|
||||
</div>
|
||||
<p> </p>
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1,14 @@
|
|||
{% extends 'flask_user/_public_base.html' %}
|
||||
{% block content %}
|
||||
|
||||
<p> </p>
|
||||
|
||||
<div class="row container-fluid" >
|
||||
<div class="col-xs-12">
|
||||
{{markup_content}}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p> </p>
|
||||
{% endblock %}
|
|
@ -0,0 +1,31 @@
|
|||
{% extends 'flask_user/_public_base.html' %}
|
||||
{% block content %}
|
||||
|
||||
<h1 style="text-align: center;">SMS Log</h1>
|
||||
<p style="text-align: center;"><a href="/sms.xml"><em>RSS Feed</em></a><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH5QIcFBAOXAevLAAAAZZJREFUSMftlbtKA0EUhj8jWhi8gaIEC29oxEoRFESLgIXYiWVSKoj6CCrBBwj6CBHNE1hEWy21ETQqiIW1wXhPo81ZOBw2apbdVPvDsDPnP8M/5zKzECJEQKivYO8DFoAYEAGKtTpQEvhW4w3IA+tAVy2F9fgEskA8COHUL8LOKAMZoMmLQF0FewcwImmNAzPANBB18b0BFoGroNLfBiyLgI2+BMwF3XgNwCrwYsQ//BBPSRPdAoeybjE+A8ClS+Sjfnf1E5A2dW4FzoxfwWvD/XWd7oAxI24jz3gVnpS7eiEpt+KvQEL5D5qal/245zFgU+pnXzMd+Zrh9/3q5l7g3CXtTs0bgWvFffn5vDa7iKcVv2K4DS8i3cAOsAuMm8h12ovqqrVL/R3upFrRKPBgHgctvm0iSynuWNnf5bf6byy5dPKe4nukhg6XU9yW2TfsJlDpNCUX27OaP8pD4WBCzQtmX381EUeAI3Xqe6m5xoHpYAezJuJkNb9Fh0tI4+SlXhpTwJBaZ+XbCcwr+6kcPESI2uAHmAijFaMnEmYAAAAASUVORK5CYII=" /></p>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<table data-toggle="table" data-pagination="true" data-search="true" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Sender</th>
|
||||
<th>Receiver</th>
|
||||
<th>Message</th>
|
||||
<th>Server</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{{markup_content}}
|
||||
|
||||
</tbody></table>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p> </p>
|
||||
{% endblock %}
|
|
@ -0,0 +1,34 @@
|
|||
{% extends 'flask_user/_public_base.html' %}
|
||||
{% block content %}
|
||||
|
||||
<h1 style="text-align: center;">Social Status</h1>
|
||||
<p style="text-align: center;"><a href="/ss/{{user_id}}.xml"><em>RSS Feed</em></a><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH5QIcFBAOXAevLAAAAZZJREFUSMftlbtKA0EUhj8jWhi8gaIEC29oxEoRFESLgIXYiWVSKoj6CCrBBwj6CBHNE1hEWy21ETQqiIW1wXhPo81ZOBw2apbdVPvDsDPnP8M/5zKzECJEQKivYO8DFoAYEAGKtTpQEvhW4w3IA+tAVy2F9fgEskA8COHUL8LOKAMZoMmLQF0FewcwImmNAzPANBB18b0BFoGroNLfBiyLgI2+BMwF3XgNwCrwYsQ//BBPSRPdAoeybjE+A8ClS+Sjfnf1E5A2dW4FzoxfwWvD/XWd7oAxI24jz3gVnpS7eiEpt+KvQEL5D5qal/245zFgU+pnXzMd+Zrh9/3q5l7g3CXtTs0bgWvFffn5vDa7iKcVv2K4DS8i3cAOsAuMm8h12ovqqrVL/R3upFrRKPBgHgctvm0iSynuWNnf5bf6byy5dPKe4nukhg6XU9yW2TfsJlDpNCUX27OaP8pD4WBCzQtmX381EUeAI3Xqe6m5xoHpYAezJuJkNb9Fh0tI4+SlXhpTwJBaZ+XbCcwr+6kcPESI2uAHmAijFaMnEmYAAAAASUVORK5CYII=" /></p>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
{{markup_content}}
|
||||
|
||||
<p style="text-align: center;">Post History</p>
|
||||
|
||||
<table data-toggle="table" data-pagination="true" data-search="true" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Post</th>
|
||||
<th>Time</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{{all_post}}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1,33 @@
|
|||
{% extends 'flask_user/_public_base.html' %}
|
||||
{% block content %}
|
||||
|
||||
<h1 style="text-align: center;">Social Status List</h1>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-header">Last Known Status</div>
|
||||
<div class="card-body">
|
||||
|
||||
<table data-toggle="table" data-pagination="true" data-search="true" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th>User</th>
|
||||
<th>Post</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{{markup_content}}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="card-footer">Footer</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1,9 @@
|
|||
{% extends 'flask_user/_public_base.html' %}
|
||||
{% block content %}
|
||||
<p style="text-align: center;"><a href="/talkgroups"><strong><button type="button" class="btn btn-primary">All Talkgroups</button></strong></a></p>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">{{markup_content}}</div>
|
||||
</div>
|
||||
|
||||
<p> </p>
|
||||
{% endblock %}
|
|
@ -0,0 +1,36 @@
|
|||
{% extends 'flask_user/_public_base.html' %}
|
||||
{% block content %}
|
||||
<style>
|
||||
|
||||
</style>
|
||||
<p> </p>
|
||||
<p style="text-align: center;"><strong>Note:</strong> Talkgroups listed here may not be available on all servers. See <a href="/generate_passphrase">Passphrase(s)</a> for complete list of talkgroup availability per server.</p>
|
||||
<p style="text-align: center;"><a href="hbnet_tg.csv"><strong>Download talkgroup CSV</strong></a> | <a href="hbnet_tg_anytone.csv"><strong>Download talkgroup CSV (Anytone format)</strong></a></p>
|
||||
<div class="container-fluid">
|
||||
|
||||
<!-- <table class="table table-striped table-bordered" style="width:100%" id="all_tg"> -->
|
||||
|
||||
<table data-toggle="table" data-pagination="true" data-search="true">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 146.1px; text-align: center;">Name</th>
|
||||
<th style="width: 89.9px; text-align: center;">TG</th>
|
||||
<th style="width: 339px; text-align: center;">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{{markup_content}}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="row container-fluid" >
|
||||
<div class="col-xs-12">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p> </p>
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1,30 @@
|
|||
{% extends 'flask_user/_public_base.html' %}
|
||||
{% block content %}
|
||||
|
||||
<h1 style="text-align: center;">Tiny Pages</h1>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
|
||||
<form action="?add_page=true" method="post">
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text" id="basic-addon1"><strong>?</strong></span>
|
||||
<input type="text" id="username" placeholder="Query" name="query" class="form-control" aria-label="Query" aria-describedby="basic-addon1">
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<span class="input-group-text">Content</span>
|
||||
<textarea id="message" name="content" class="form-control" aria-label="Content"></textarea>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
<p style="text-align: center;"><input class="btn btn-primary" type="submit" value="Add" /></form></p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p> </p>
|
||||
{% endblock %}
|
|
@ -0,0 +1,32 @@
|
|||
{% extends 'flask_user/_public_base.html' %}
|
||||
{% block content %}
|
||||
|
||||
<h1 style="text-align: center;">Tiny Pages</h1>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
{% if call_or_get(current_user.is_authenticated) %}
|
||||
<button type="button" class="btn btn-primary">Add Tiny Page</button>
|
||||
{% endif %}
|
||||
<table data-toggle="table" data-pagination="true" data-search="true" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Query</th>
|
||||
<th>Content</th>
|
||||
<th>Author</th>
|
||||
<th>Options</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{{markup_content}}
|
||||
|
||||
</tbody></table>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p> </p>
|
||||
{% endblock %}
|
|
@ -0,0 +1,64 @@
|
|||
{% extends 'flask_user/_public_base.html' %}
|
||||
{% block content %}
|
||||
<p> </p>
|
||||
<div class="card bg-light card-body mb-3">
|
||||
<h4 style="text-align: center;"><a href="/generate_passphrase/pi-star"><button type="button" class="btn btn-warning">Automatic Pi-Star Setup Script</button></a> </h4>
|
||||
<br>
|
||||
|
||||
<h4 style="text-align: center;"><button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#options_modal">
|
||||
MMDVM Options
|
||||
</button></h4>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-6">{{server_content}}</div>
|
||||
<div class="col-sm-6">{{passphrase_content}}</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Options Modal -->
|
||||
<div class="modal fade" id="options_modal">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
|
||||
<!-- Modal Header -->
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Modal Heading</h4>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
|
||||
<!-- Modal body -->
|
||||
<div class="modal-body">
|
||||
|
||||
|
||||
<div class="container-fluid">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Option</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>NO_MAP</td>
|
||||
<td>This option will prevent your hotspot/repeater from plotting on the map. <strong>This option may also be entered into the Location field of your hotspot, if your hotspot doesn't have an options field.</strong></td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Modal footer -->
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-danger" data-bs-dismiss="modal">Close</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p> </p>
|
||||
{% endblock %}
|
|
@ -0,0 +1,11 @@
|
|||
[uwsgi]
|
||||
module = wsgi:app
|
||||
|
||||
master = true
|
||||
processes = 2
|
||||
|
||||
socket = /tmp/hbnet_web_service.sock
|
||||
chmod-socket = 666
|
||||
vacuum = true
|
||||
|
||||
die-on-term = true
|
|
@ -0,0 +1,11 @@
|
|||
from app import hbnet_web_service
|
||||
|
||||
app = hbnet_web_service()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# app = create_app()
|
||||
|
||||
app.run()
|
||||
|
||||
|
Loading…
Reference in New Issue