support public listing on rx.kiwisdr.com
This commit is contained in:
parent
81465d69cc
commit
a57b112417
@ -59,6 +59,18 @@ Antenna: Receiver Antenna<br />
|
|||||||
Website: <a href="http://localhost" target="_blank">http://localhost</a>
|
Website: <a href="http://localhost" target="_blank">http://localhost</a>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# ==== rx.kiwisdr.com listing ====
|
||||||
|
# If you want your receiver to be listed publicly on rx.kiwisdr.com, then take the following steps:
|
||||||
|
# 1a. If you have a previous listing key from sdr.hu email it to support@kiwisdr.com and wait for a reply.
|
||||||
|
# -or-
|
||||||
|
# 1b. Send an email to support@kiwisdr.com and request a new listing key.
|
||||||
|
# Enter the listing key from step 1a or 1b here:
|
||||||
|
listing_key = ""
|
||||||
|
# 2. Use a public domain name or public ip address as the server hostname:
|
||||||
|
server_hostname = "localhost"
|
||||||
|
# 3. Set this setting to True to enable listing:
|
||||||
|
public_listing = False
|
||||||
|
|
||||||
# ==== DSP/RX settings ====
|
# ==== DSP/RX settings ====
|
||||||
fft_fps = 9
|
fft_fps = 9
|
||||||
fft_size = 4096 # Should be power of 2
|
fft_size = 4096 # Should be power of 2
|
||||||
|
40
listing.py
Executable file
40
listing.py
Executable file
@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
"""
|
||||||
|
|
||||||
|
This file is part of OpenWebRX,
|
||||||
|
an open-source SDR receiver software with a web UI.
|
||||||
|
Copyright (c) 2013-2015 by Andras Retzler <randras@sdr.hu>
|
||||||
|
Copyright (c) 2019-2020 by Jakob Ketterl <dd5jfk@darc.de>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
from owrx.listing import ListingUpdater
|
||||||
|
from owrx.config import Config
|
||||||
|
|
||||||
|
import logging
|
||||||
|
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
pm = Config.get()
|
||||||
|
|
||||||
|
if "public_listing" not in pm or not pm["public_listing"]:
|
||||||
|
logger.error('Public listing on is not activated. Please check "public_listing" in your config.')
|
||||||
|
exit(1)
|
||||||
|
if "listing_key" not in pm or pm["listing_key"] is None or pm["listing_key"] == "":
|
||||||
|
logger.error('Missing "listing_key" in your config. Aborting')
|
||||||
|
exit(1)
|
||||||
|
ListingUpdater().update()
|
@ -9,6 +9,7 @@ from owrx.config import Config
|
|||||||
from owrx.feature import FeatureDetector
|
from owrx.feature import FeatureDetector
|
||||||
from owrx.sdr import SdrService
|
from owrx.sdr import SdrService
|
||||||
from socketserver import ThreadingMixIn
|
from socketserver import ThreadingMixIn
|
||||||
|
from owrx.listing import ListingUpdater
|
||||||
from owrx.service import Services
|
from owrx.service import Services
|
||||||
from owrx.websocket import WebSocketConnection
|
from owrx.websocket import WebSocketConnection
|
||||||
from owrx.pskreporter import PskReporter
|
from owrx.pskreporter import PskReporter
|
||||||
@ -58,6 +59,10 @@ Support and info: https://groups.io/g/openwebrx
|
|||||||
# Get error messages about unknown / unavailable features as soon as possible
|
# Get error messages about unknown / unavailable features as soon as possible
|
||||||
SdrService.loadProps()
|
SdrService.loadProps()
|
||||||
|
|
||||||
|
if "listing_key" in pm and pm["public_listing"]:
|
||||||
|
updater = ListingUpdater()
|
||||||
|
updater.start()
|
||||||
|
|
||||||
Services.start()
|
Services.start()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -244,6 +244,18 @@ class GeneralSettingsController(AdminController):
|
|||||||
infotext="This callsign will be used to send spots to pskreporter.info",
|
infotext="This callsign will be used to send spots to pskreporter.info",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Section(
|
||||||
|
"rx.kiwisdr.com",
|
||||||
|
TextInput(
|
||||||
|
"listing_key",
|
||||||
|
"rx.kiwisdr.com key",
|
||||||
|
infotext='Please obtain your listing key via email from support@kiwisdr.com',
|
||||||
|
),
|
||||||
|
CheckboxInput(
|
||||||
|
"public_listing", "List on rx.kiwisdr.com", "List my receiver publicly on rx.kiwisdr.com"
|
||||||
|
),
|
||||||
|
TextInput("server_hostname", "Hostname"),
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
def render_sections(self):
|
def render_sections(self):
|
||||||
|
@ -27,7 +27,7 @@ class StatusController(Controller):
|
|||||||
|
|
||||||
def indexAction(self):
|
def indexAction(self):
|
||||||
pm = Config.get()
|
pm = Config.get()
|
||||||
|
avatar_path = pkg_resources.resource_filename("htdocs", "gfx/openwebrx-avatar.png")
|
||||||
status = {
|
status = {
|
||||||
"receiver": {
|
"receiver": {
|
||||||
"name": pm["receiver_name"],
|
"name": pm["receiver_name"],
|
||||||
@ -36,8 +36,10 @@ class StatusController(Controller):
|
|||||||
"asl": pm["receiver_asl"],
|
"asl": pm["receiver_asl"],
|
||||||
"location": pm["receiver_location"],
|
"location": pm["receiver_location"],
|
||||||
},
|
},
|
||||||
|
"clients": ClientRegistry.getSharedInstance().clientCount(),
|
||||||
"max_clients": pm["max_clients"],
|
"max_clients": pm["max_clients"],
|
||||||
"version": openwebrx_version,
|
"sw_version": openwebrx_version,
|
||||||
|
"avatar_mtime": os.path.getmtime(avatar_path),
|
||||||
"sdrs": [self.getReceiverStats(r) for r in SdrService.getSources().values()]
|
"sdrs": [self.getReceiverStats(r) for r in SdrService.getSources().values()]
|
||||||
}
|
}
|
||||||
self.send_response(json.dumps(status), content_type="application/json")
|
self.send_response(json.dumps(status), content_type="application/json")
|
||||||
|
43
owrx/listing.py
Normal file
43
owrx/listing.py
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import threading
|
||||||
|
import time
|
||||||
|
from owrx.config import Config
|
||||||
|
from urllib import request, parse
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class ListingUpdater(threading.Thread):
|
||||||
|
def __init__(self):
|
||||||
|
self.doRun = True
|
||||||
|
super().__init__(daemon=True)
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
pm = Config.get().filter("server_hostname", "web_port", "listing_key")
|
||||||
|
data = parse.urlencode({
|
||||||
|
"url": "http://{server_hostname}:{web_port}".format(**pm.__dict__()),
|
||||||
|
"key": pm["listing_key"]
|
||||||
|
}).encode()
|
||||||
|
|
||||||
|
res = request.urlopen("http://kiwisdr.com/php/update.php", data=data)
|
||||||
|
if res.getcode() < 200 or res.getcode() >= 300:
|
||||||
|
logger.warning('rx.kiwisdr.com update failed with error code %i', res.getcode())
|
||||||
|
return 2
|
||||||
|
|
||||||
|
returned = res.read().decode("utf-8")
|
||||||
|
if "UPDATE:" not in returned:
|
||||||
|
logger.warning("Update failed, your receiver cannot be listed on rx.kiwisdr.com!")
|
||||||
|
return 2
|
||||||
|
|
||||||
|
value = returned.split("UPDATE:")[1].split("\n", 1)[0]
|
||||||
|
if value.startswith("SUCCESS"):
|
||||||
|
logger.info("Update succeeded!")
|
||||||
|
else:
|
||||||
|
logger.warning("Update failed, your receiver cannot be listed on rx.kiwisdr.com! Reason: %s", value)
|
||||||
|
return 20
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
while self.doRun:
|
||||||
|
retrytime_mins = self.update()
|
||||||
|
time.sleep(60 * retrytime_mins)
|
Loading…
x
Reference in New Issue
Block a user