mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-02-04 09:14:30 +00:00
Make allowing RBN spots via cluster a configurable option.
This commit is contained in:
@@ -64,6 +64,11 @@ spot-providers:
|
|||||||
# Callsign Spothole will use to log into this cluster. Ensure the SSID (e.g. -99) is different to any personal
|
# Callsign Spothole will use to log into this cluster. Ensure the SSID (e.g. -99) is different to any personal
|
||||||
# connection you might make to this cluster node.
|
# connection you might make to this cluster node.
|
||||||
login_callsign: "N0CALL-99"
|
login_callsign: "N0CALL-99"
|
||||||
|
# Whether to allow RBN spots that come via this cluster. If you don't want RBN spots or you are making a separate
|
||||||
|
# connection to RBN directly, leave this as False. If you want RBN spots from this cluster, set this to True. (Make
|
||||||
|
# sure you aren't also separately connecting to RBN directly, otherwise you may get duplicate spots.) Note that not
|
||||||
|
# all clusters sent RBN spots anyway.
|
||||||
|
allow_rbn_spots: false
|
||||||
-
|
-
|
||||||
class: "DXCluster"
|
class: "DXCluster"
|
||||||
name: "W3LPL Cluster"
|
name: "W3LPL Cluster"
|
||||||
@@ -75,6 +80,11 @@ spot-providers:
|
|||||||
# Callsign Spothole will use to log into this cluster. Ensure the SSID (e.g. -99) is different to any personal
|
# Callsign Spothole will use to log into this cluster. Ensure the SSID (e.g. -99) is different to any personal
|
||||||
# connection you might make to this cluster node.
|
# connection you might make to this cluster node.
|
||||||
login_callsign: "N0CALL-99"
|
login_callsign: "N0CALL-99"
|
||||||
|
# Whether to allow RBN spots that come via this cluster. If you don't want RBN spots or you are making a separate
|
||||||
|
# connection to RBN directly, leave this as False. If you want RBN spots from this cluster, set this to True. (Make
|
||||||
|
# sure you aren't also separately connecting to RBN directly, otherwise you may get duplicate spots.) Note that not
|
||||||
|
# all clusters sent RBN spots anyway.
|
||||||
|
allow_rbn_spots: false
|
||||||
-
|
-
|
||||||
class: "RBN"
|
class: "RBN"
|
||||||
name: "RBN CW/RTTY"
|
name: "RBN CW/RTTY"
|
||||||
|
|||||||
@@ -12,15 +12,17 @@ from data.spot import Spot
|
|||||||
from spotproviders.spot_provider import SpotProvider
|
from spotproviders.spot_provider import SpotProvider
|
||||||
|
|
||||||
|
|
||||||
# Spot provider for a DX Cluster. Hostname, port, login_prompt and login_callsign are provided in config.
|
# Spot provider for a DX Cluster. Hostname, port, login_prompt, login_callsign and allow_rbn_spots are provided in config.
|
||||||
|
# See config-example.yml for examples.
|
||||||
class DXCluster(SpotProvider):
|
class DXCluster(SpotProvider):
|
||||||
# Note the callsign pattern deliberately excludes calls ending in "-#", which are from RBN and can be enabled by
|
|
||||||
# default on some clusters. If you want RBN spots, there is a separate provider for that.
|
|
||||||
CALLSIGN_PATTERN = "([a-z|0-9|/]+)"
|
CALLSIGN_PATTERN = "([a-z|0-9|/]+)"
|
||||||
FREQUENCY_PATTERN = "([0-9|.]+)"
|
FREQUENCY_PATTERN = "([0-9|.]+)"
|
||||||
LINE_PATTERN = re.compile(
|
LINE_PATTERN_EXCLUDE_RBN = re.compile(
|
||||||
"^DX de " + CALLSIGN_PATTERN + ":\\s+" + FREQUENCY_PATTERN + "\\s+" + CALLSIGN_PATTERN + "\\s+(.*)\\s+(\\d{4}Z)",
|
"^DX de " + CALLSIGN_PATTERN + ":\\s+" + FREQUENCY_PATTERN + "\\s+" + CALLSIGN_PATTERN + "\\s+(.*)\\s+(\\d{4}Z)",
|
||||||
re.IGNORECASE)
|
re.IGNORECASE)
|
||||||
|
LINE_PATTERN_ALLOW_RBN = re.compile(
|
||||||
|
"^DX de " + CALLSIGN_PATTERN + "-?#?:\\s+" + FREQUENCY_PATTERN + "\\s+" + CALLSIGN_PATTERN + "\\s+(.*)\\s+(\\d{4}Z)",
|
||||||
|
re.IGNORECASE)
|
||||||
|
|
||||||
# Constructor requires hostname and port
|
# Constructor requires hostname and port
|
||||||
def __init__(self, provider_config):
|
def __init__(self, provider_config):
|
||||||
@@ -29,6 +31,8 @@ class DXCluster(SpotProvider):
|
|||||||
self.port = provider_config["port"]
|
self.port = provider_config["port"]
|
||||||
self.login_prompt = provider_config["login_prompt"] if "login_prompt" in provider_config else "login:"
|
self.login_prompt = provider_config["login_prompt"] if "login_prompt" in provider_config else "login:"
|
||||||
self.login_callsign = provider_config["login_callsign"] if "login_callsign" in provider_config else SERVER_OWNER_CALLSIGN
|
self.login_callsign = provider_config["login_callsign"] if "login_callsign" in provider_config else SERVER_OWNER_CALLSIGN
|
||||||
|
self.allow_rbn_spots = provider_config["allow_rbn_spots"] if "allow_rbn_spots" in provider_config else False
|
||||||
|
self.spot_line_pattern = self.LINE_PATTERN_ALLOW_RBN if self.allow_rbn_spots else self.LINE_PATTERN_EXCLUDE_RBN
|
||||||
self.telnet = None
|
self.telnet = None
|
||||||
self.thread = Thread(target=self.handle)
|
self.thread = Thread(target=self.handle)
|
||||||
self.thread.daemon = True
|
self.thread.daemon = True
|
||||||
@@ -64,7 +68,7 @@ class DXCluster(SpotProvider):
|
|||||||
try:
|
try:
|
||||||
# Check new telnet info against regular expression
|
# Check new telnet info against regular expression
|
||||||
telnet_output = self.telnet.read_until("\n".encode("latin-1"))
|
telnet_output = self.telnet.read_until("\n".encode("latin-1"))
|
||||||
match = self.LINE_PATTERN.match(telnet_output.decode("latin-1"))
|
match = self.spot_line_pattern.match(telnet_output.decode("latin-1"))
|
||||||
if match:
|
if match:
|
||||||
spot_time = datetime.strptime(match.group(5), "%H%MZ")
|
spot_time = datetime.strptime(match.group(5), "%H%MZ")
|
||||||
spot_datetime = datetime.combine(datetime.today(), spot_time.time()).replace(tzinfo=pytz.UTC)
|
spot_datetime = datetime.combine(datetime.today(), spot_time.time()).replace(tzinfo=pytz.UTC)
|
||||||
|
|||||||
Reference in New Issue
Block a user