mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-20 06:17:41 +00:00
Telnet fixes and banner
This commit is contained in:
@@ -4,6 +4,7 @@ import threading
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
import pytz
|
import pytz
|
||||||
|
from pyhamtools import callinfo
|
||||||
|
|
||||||
from core.config import SERVER_OWNER_CALLSIGN
|
from core.config import SERVER_OWNER_CALLSIGN
|
||||||
from core.constants import SOFTWARE_VERSION
|
from core.constants import SOFTWARE_VERSION
|
||||||
@@ -12,6 +13,33 @@ from data.spot import Spot
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
BANNER = (
|
||||||
|
"""
|
||||||
|
==
|
||||||
|
==== ##### ##### ####
|
||||||
|
== == ..### ..### ..###
|
||||||
|
== ###==######## ###### ####### .####### ###### .### ######
|
||||||
|
==###.. ..###..### ###..###...###. .###..### ###..### .### ###..###
|
||||||
|
==###.### .### .###.### .### .### .### .### .### .### .### .#######
|
||||||
|
== .###.###.### .###.### .### .### ### .### .### .### .### .### .###...
|
||||||
|
== ...### .####### ..###### ..##### #### #####..###### #####..######
|
||||||
|
== .###. .###=.. ...... ..... .... ..... ...... ..... ......
|
||||||
|
== %% ... %%%%###==
|
||||||
|
== %%%%%%%%%%%#####== \r\n"""
|
||||||
|
+ "== ..... =="
|
||||||
|
+ f"Welcome to Spothole v{SOFTWARE_VERSION}".rjust(56)
|
||||||
|
+ "\r\n"
|
||||||
|
+ "========================"
|
||||||
|
+ f"This server is run by {SERVER_OWNER_CALLSIGN}".rjust(56)
|
||||||
|
)
|
||||||
|
|
||||||
|
MOTD = (
|
||||||
|
"Spothole's telnet server is a new feature and may not work properly in all\r\n"
|
||||||
|
+ "loggers. Please give it a try in your logger of choice and let me know if it\r\n"
|
||||||
|
+ "(or doesn't!) Please note that DXSpider-like commands are not yet supported\r\n"
|
||||||
|
+ "so you are not yet able to filter spots server-side or log in at all."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TelnetServer:
|
class TelnetServer:
|
||||||
"""A telnet server designed to provide spots in the same format as DXSpider, for compatibility with desktop loggers."""
|
"""A telnet server designed to provide spots in the same format as DXSpider, for compatibility with desktop loggers."""
|
||||||
@@ -56,15 +84,22 @@ class TelnetServer:
|
|||||||
logger.debug("Telnet client connected")
|
logger.debug("Telnet client connected")
|
||||||
self._clients.add(writer)
|
self._clients.add(writer)
|
||||||
|
|
||||||
# Print MOTD
|
# Print banner and MOTD
|
||||||
try:
|
try:
|
||||||
motd = (
|
text = (
|
||||||
f"Welcome to Spothole v{SOFTWARE_VERSION}.\r\nThis server is run by {SERVER_OWNER_CALLSIGN}.\r\n===\r\n"
|
BANNER
|
||||||
|
+ "\r\n\r\n"
|
||||||
|
+ "================================================================================"
|
||||||
|
+ "\r\n"
|
||||||
|
+ MOTD
|
||||||
|
+ "\r\n"
|
||||||
|
+ "================================================================================"
|
||||||
|
+ "\r\n\r\n"
|
||||||
)
|
)
|
||||||
writer.write(motd.encode("ascii"))
|
writer.write(text.encode("ascii"))
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
logger.exception("Exception printing telnet motd")
|
||||||
|
|
||||||
# Set up buffer for user input
|
# Set up buffer for user input
|
||||||
input_buffer = ""
|
input_buffer = ""
|
||||||
@@ -163,12 +198,14 @@ class TelnetServer:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def _format_dxspider_spot(spot: Spot) -> str:
|
def _format_dxspider_spot(spot: Spot) -> str:
|
||||||
"""Formats a spot into the format DXspider uses:
|
"""Formats a spot into the format DXspider uses:
|
||||||
DX de CALLSIGN: FREQUENCY DX_CALLSIGN COMMENTS TIME_UTC"""
|
DX de CALLSIGN: FREQUENCY DX_CALLSIGN COMMENTS TIME_UTC.
|
||||||
|
Always use the base call for the spotter to save space. Everything must align properly to parse in clients,
|
||||||
|
and everything must be renderable in ASCII."""
|
||||||
|
|
||||||
de_call = f"{spot.de_call + ':' if spot.de_call else '???:'!s:<9}"
|
de_call = f"{callinfo.Callinfo.get_homecall(spot.de_call)[:6] + ':' if spot.de_call else '???:'!s:<7}"
|
||||||
frequency = f"{(spot.freq / 1000.0):8.1f}"
|
frequency = f"{(spot.freq / 1000.0):10.1f}"
|
||||||
dx_call = f"{spot.dx_call!s:<12}"
|
dx_call = f"{spot.dx_call!s:<12}"
|
||||||
comment = f"{spot.comment[:29]:<30}"
|
comment = f"{spot.comment.encode('ascii', errors='ignore').decode()[:29]:<30}"
|
||||||
if spot.time:
|
if spot.time:
|
||||||
timestamp = datetime.fromtimestamp(spot.time, tz=pytz.utc).strftime("%H%M") + "Z"
|
timestamp = datetime.fromtimestamp(spot.time, tz=pytz.utc).strftime("%H%M") + "Z"
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -77,7 +77,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/js/add-spot.js?v=1789162324"></script>
|
<script src="/static/js/add-spot.js?v=1789198850"></script>
|
||||||
<script>$(document).ready(function () {
|
<script>$(document).ready(function () {
|
||||||
$("#nav-link-add-spot").addClass("active");
|
$("#nav-link-add-spot").addClass("active");
|
||||||
}); <!-- highlight active page in nav --></script>
|
}); <!-- highlight active page in nav --></script>
|
||||||
|
|||||||
@@ -83,7 +83,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/js/alerts.js?v=1789162324"></script>
|
<script src="/static/js/alerts.js?v=1789198850"></script>
|
||||||
<script>$(document).ready(function () {
|
<script>$(document).ready(function () {
|
||||||
$("#nav-link-alerts").addClass("active");
|
$("#nav-link-alerts").addClass("active");
|
||||||
}); <!-- highlight active page in nav --></script>
|
}); <!-- highlight active page in nav --></script>
|
||||||
|
|||||||
@@ -76,8 +76,8 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/js/spotsbandsandmap.js?v=1789162324"></script>
|
<script src="/static/js/spotsbandsandmap.js?v=1789198850"></script>
|
||||||
<script src="/static/js/bands.js?v=1789162324"></script>
|
<script src="/static/js/bands.js?v=1789198850"></script>
|
||||||
<script>$(document).ready(function () {
|
<script>$(document).ready(function () {
|
||||||
$("#nav-link-bands").addClass("active");
|
$("#nav-link-bands").addClass("active");
|
||||||
}); <!-- highlight active page in nav --></script>
|
}); <!-- highlight active page in nav --></script>
|
||||||
|
|||||||
+5
-5
@@ -1,6 +1,6 @@
|
|||||||
{% extends "skeleton.html" %}
|
{% extends "skeleton.html" %}
|
||||||
{% block head_extra %}
|
{% block head_extra %}
|
||||||
<link rel="stylesheet" href="/static/css/style.css?v=1789162324" type="text/css">
|
<link rel="stylesheet" href="/static/css/style.css?v=1789198850" type="text/css">
|
||||||
<link href="/static/vendor/css/bootstrap-5.3.8.min.css" rel="stylesheet">
|
<link href="/static/vendor/css/bootstrap-5.3.8.min.css" rel="stylesheet">
|
||||||
<link href="/static/vendor/css/fontawesome-6.7.2.min.css" rel="stylesheet">
|
<link href="/static/vendor/css/fontawesome-6.7.2.min.css" rel="stylesheet">
|
||||||
<link href="/static/vendor/css/solid-6.7.2.min.css" rel="stylesheet">
|
<link href="/static/vendor/css/solid-6.7.2.min.css" rel="stylesheet">
|
||||||
@@ -16,10 +16,10 @@
|
|||||||
window.fetchEventSource = fetchEventSource;
|
window.fetchEventSource = fetchEventSource;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script src="/static/js/utils.js?v=1789162324"></script>
|
<script src="/static/js/utils.js?v=1789198850"></script>
|
||||||
<script src="/static/js/ui-ham.js?v=1789162324"></script>
|
<script src="/static/js/ui-ham.js?v=1789198850"></script>
|
||||||
<script src="/static/js/geo.js?v=1789162324"></script>
|
<script src="/static/js/geo.js?v=1789198850"></script>
|
||||||
<script src="/static/js/common.js?v=1789162324"></script>
|
<script src="/static/js/common.js?v=1789198850"></script>
|
||||||
{% end %}
|
{% end %}
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|||||||
@@ -284,7 +284,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/vendor/js/chart-4.4.9.umd.min.js"></script>
|
<script src="/static/vendor/js/chart-4.4.9.umd.min.js"></script>
|
||||||
<script src="/static/js/conditions.js?v=1789162324"></script>
|
<script src="/static/js/conditions.js?v=1789198850"></script>
|
||||||
<script>$(document).ready(function () {
|
<script>$(document).ready(function () {
|
||||||
$("#nav-link-conditions").addClass("active");
|
$("#nav-link-conditions").addClass("active");
|
||||||
}); <!-- highlight active page in nav --></script>
|
}); <!-- highlight active page in nav --></script>
|
||||||
|
|||||||
+2
-2
@@ -113,8 +113,8 @@
|
|||||||
const CARTODB_API_KEY = "{{ web_ui_options.get('cartodb_api_key', '') }}";
|
const CARTODB_API_KEY = "{{ web_ui_options.get('cartodb_api_key', '') }}";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script src="/static/js/spotsbandsandmap.js?v=1789162323"></script>
|
<script src="/static/js/spotsbandsandmap.js?v=1789198850"></script>
|
||||||
<script src="/static/js/map.js?v=1789162323"></script>
|
<script src="/static/js/map.js?v=1789198850"></script>
|
||||||
<script>$(document).ready(function () {
|
<script>$(document).ready(function () {
|
||||||
$("#nav-link-map").addClass("active");
|
$("#nav-link-map").addClass("active");
|
||||||
}); <!-- highlight active page in nav --></script>
|
}); <!-- highlight active page in nav --></script>
|
||||||
|
|||||||
@@ -125,8 +125,8 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/js/spotsbandsandmap.js?v=1789162323"></script>
|
<script src="/static/js/spotsbandsandmap.js?v=1789198850"></script>
|
||||||
<script src="/static/js/spots.js?v=1789162323"></script>
|
<script src="/static/js/spots.js?v=1789198850"></script>
|
||||||
<script>$(document).ready(function () {
|
<script>$(document).ready(function () {
|
||||||
$("#nav-link-spots").addClass("active");
|
$("#nav-link-spots").addClass("active");
|
||||||
}); <!-- highlight active page in nav --></script>
|
}); <!-- highlight active page in nav --></script>
|
||||||
|
|||||||
@@ -96,7 +96,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/js/status.js?v=1789162324"></script>
|
<script src="/static/js/status.js?v=1789198850"></script>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$("#nav-link-status").addClass("active");
|
$("#nav-link-status").addClass("active");
|
||||||
|
|||||||
Reference in New Issue
Block a user