New Wavelog Contesting and Basics for Wavelog Worker (#3063)
* initial commit for new contesting in Wavelog
* implemented cache buster to match logic from upstream dev branch
* refactore data-store to idb since this will be much faster with a lot of QSOs (scale for the future)
* implementation of other exchange types (wip)
* updated migration version
* renamed mig
* renamed mig
* updated mig
* ESC Handler to reset form
* Add Websocket
* stretch maxDuration warning
We can stretch the maxDuration warning to 2 seconds to allow for more network latency and processing time. The heartbeat is protected against multiple parallel requests, so we can afford to be more lenient with the duration before showing a warning. This should help reduce false positives in environments with higher latency or slower processing.
* worked before warning in qso form
While input the logic checks in the qso list if the callisgn already exists on the same band and mode.
* translations
* fix band buttons
* updated migration after release 2.4.2
* Fixing create new contest, add clubstation permission check, add time check to contests
* Adding attach QSO to Contest
* Remove redundant clubstation checks
* Fix function tip
* Remove time check when launch contest
* Fixing contest attach main logbook, adding detach contest qso
* Enable clubstation contest QSO detach attach
* add space handler for callsign input
* set rst default to 599 for cw, 59 for others
* add grid and refactor some ui to make a better fitting here and there
* adjust tabindex
* add "copy exchange to" feature
* fix css for all themes
* adif and cbr export
* fix bug with wrong operator callsign
* add exchange type "exchange+grid"
* introduce new logic for exchangetypes and more flexible order selection
* fix broken qso list scroll
* legacy import feature
* more precise wording
* feat: inline editing of QSOs by double click in the QSO list
* redirect cabrillo to contesting manager
* Fix QSO permission check
* remove unused cabrillo stuff
* remove duplicate function
* fix check if worked before on band change
tnx to @int2001
* fix flash message for legacy importer
* make dropdown searchable and place "other" at the top
* add hint about "Other" contest
* avoid "flash" of winkeyer settings in qso logging, it shows up if cw is set as mode
* winkeyer for the new contesting
need proper testing by @AndreasK79 and @phl0 since I don't have a winkeyer myself. I tested with a python simulator...
* english comments
* proper singular/plural
* fix dropdown
* preselect active station location
* allow editing time aswell
* fix fontsize in radio buttons
* remove redundant qso count query
* cache last updated value for contest qsos to reduce db load
* index on user id
* cache also qso count
* you can now resize windows also on the edges
requested by @xyz667 in https://github.com/wavelog/wavelog/pull/3063#issuecomment-4557850867
* fix oversized clock
* click to prepare logging for contesting
Logic:
- if qso windows is open, call is sent to qso form
- if contest log is open, call is sent to contest log
- if both are open, call is sent to contest log
- if none is open, click opens qso form and call is sent to qso form
* handle exchange s prefill with data from the last qso and make exchange always uppercase
* add dropdown to qso list with option to delete qsos
* language fixes
* english comments
* center text
* fix missing dropdown on new qsos
* add date presets for contest session creator/editor
* basic worker implementation
* support multiple workers for clustering
* remove unnecessary node column
* simple availability check
* websocket for contesting
* bonus: add vip for visibilty in debug view
* use vip if available
* worker disabled in debug view if disabled in config
* racecondition for winkeyer breaks edit/delete dropdown
* racecondition for winkeyer breaks edit/delete dropdown
* qso handling for worker in contesting, no high interval heartbeat anymore
* clear heartbeat intervall
* fix some timing bugs
* remove dedicated worker controller as it's not needed
* handle whitespace
* trigger sync engine after processing QSO sync response and adjust last sync time to avoid spurious resyncs
* fix set and setLocal
* fix change detection and sync logic
* fix the lost of seconds due to edit
* fix table rendering
* watermark handling for true delta
* remove caching as it brings more problems here as benefits
* make serial as default exchangetype
* Add clarification on cluster setup requirements for worker URLs
* add operator to qso list if this is a clubstation
* fix bug for editing qsos in clubmode
* remove redundant code
* integers must be null in database
* fix bug in tabindex if 3 exchangefields are configured (serial, exchange, grid)
* nice contesting map (draft)
* map autofit
* add grid overlay
* calculate distanz and azimuth
* include rotor control via waveloggate (ws only)
* implement simple dedicated callbook lookup
* simpler and faster lookup
* option in contest session to disabled callbook lookup and only calculate dxcc
* syntax issue
* fix bug in CBR export
* catch empty result on contest
* remove some leftovers
* removed some comments
* remove unused stuff
* removed old todos/comments
* add 4s timeout for ajax transport
* you need to be admin for this
* translations
* add option to delete qso's aswell when deleting a session (opt in)
* add quickstart button in manager
* removed old todo
* fix "grows to bottom"
* disable "copy exchange to" if no exchange is set
* clear map on qso clear aswell
* same for scp
* updated documentation link
* calculate distanze and azimut also on grid only
* better space usage in qso input
* callbook db first approach, online lookup can be disabled while being cached for all users when enabled
* some input validation
* use only one sot for qrgtoband
* basic stats component
* fix html encoding
* render all aswell
* ascii
* store locally which time frame the user wants
* sync settings and warn user if something happend on the backend
* dev leftover
* show errors if callbook fails or callsign is invalid
* easier syntax
* Revert "easier syntax" - that was a mistake
This reverts commit 80c75dbf1e6c832f8d0616ea56b8b55d96c36418.
* fix for callbook lookup
* make pathline more visible
* better visibility of qsos
* add classic coordinates bar to the map
* fix bug in stats
* stretch max duration to 4s.. just in case
* simple sanity check in js to prevent unnecessary callbook lookups
* simulate tab after filling the call from scp
* fix poll radios with enabled worker
* reset po/mo files back to upstream/dev
* split contest exports, add back reg1test edi format
* keep the menu item but redirect to contesting
* better syntax and bugfix
* break it down further and fix typo ("constraint")
* use monospace font for input fields
* fix: in worker driven mode we need to do the heartbeat also on not focused windows otherwise we loose this contact
* fix: error handling on invalid times
* wavelog Ø
* more styling
* band lowercase fix
* Other is not a very descriptive title for a contest logger window, so we rename it to "Contest"
* custom contest name
* compare the whole array instead just a few settings
---------
Co-authored-by: int2001 <joerg@dj7nt.de>
Co-authored-by: HadleySo <71105018+HadleySo@users.noreply.github.com>
Co-authored-by: DB4SCW <dev@db4scw.de>
2026-06-14 14:23:00 +02:00
|
|
|
<?php
|
|
|
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Worker
|
|
|
|
|
*
|
|
|
|
|
* Manages communication with the wavelog_worker Go service.
|
|
|
|
|
*
|
|
|
|
|
* Usage:
|
|
|
|
|
* $this->load->library('Worker');
|
|
|
|
|
* $this->worker->register_topic('contest_session.abc123');
|
|
|
|
|
* $this->worker->publish('contest_session.abc123', ['event' => 'qso_updated', ...]);
|
|
|
|
|
* $this->worker->unregister_topic('contest_session.abc123');
|
|
|
|
|
*
|
|
|
|
|
* If not configured or disabled, all methods are no-ops. Errors are intentionally
|
|
|
|
|
* swallowed — the worker is optional and must never cause a QSO save to appear failed.
|
|
|
|
|
*/
|
|
|
|
|
class Worker {
|
|
|
|
|
|
|
|
|
|
private string $url;
|
|
|
|
|
private string $secret;
|
|
|
|
|
private int $timeout_ms;
|
|
|
|
|
private bool $enabled;
|
2026-07-10 19:50:39 +02:00
|
|
|
private int $token_expiration;
|
New Wavelog Contesting and Basics for Wavelog Worker (#3063)
* initial commit for new contesting in Wavelog
* implemented cache buster to match logic from upstream dev branch
* refactore data-store to idb since this will be much faster with a lot of QSOs (scale for the future)
* implementation of other exchange types (wip)
* updated migration version
* renamed mig
* renamed mig
* updated mig
* ESC Handler to reset form
* Add Websocket
* stretch maxDuration warning
We can stretch the maxDuration warning to 2 seconds to allow for more network latency and processing time. The heartbeat is protected against multiple parallel requests, so we can afford to be more lenient with the duration before showing a warning. This should help reduce false positives in environments with higher latency or slower processing.
* worked before warning in qso form
While input the logic checks in the qso list if the callisgn already exists on the same band and mode.
* translations
* fix band buttons
* updated migration after release 2.4.2
* Fixing create new contest, add clubstation permission check, add time check to contests
* Adding attach QSO to Contest
* Remove redundant clubstation checks
* Fix function tip
* Remove time check when launch contest
* Fixing contest attach main logbook, adding detach contest qso
* Enable clubstation contest QSO detach attach
* add space handler for callsign input
* set rst default to 599 for cw, 59 for others
* add grid and refactor some ui to make a better fitting here and there
* adjust tabindex
* add "copy exchange to" feature
* fix css for all themes
* adif and cbr export
* fix bug with wrong operator callsign
* add exchange type "exchange+grid"
* introduce new logic for exchangetypes and more flexible order selection
* fix broken qso list scroll
* legacy import feature
* more precise wording
* feat: inline editing of QSOs by double click in the QSO list
* redirect cabrillo to contesting manager
* Fix QSO permission check
* remove unused cabrillo stuff
* remove duplicate function
* fix check if worked before on band change
tnx to @int2001
* fix flash message for legacy importer
* make dropdown searchable and place "other" at the top
* add hint about "Other" contest
* avoid "flash" of winkeyer settings in qso logging, it shows up if cw is set as mode
* winkeyer for the new contesting
need proper testing by @AndreasK79 and @phl0 since I don't have a winkeyer myself. I tested with a python simulator...
* english comments
* proper singular/plural
* fix dropdown
* preselect active station location
* allow editing time aswell
* fix fontsize in radio buttons
* remove redundant qso count query
* cache last updated value for contest qsos to reduce db load
* index on user id
* cache also qso count
* you can now resize windows also on the edges
requested by @xyz667 in https://github.com/wavelog/wavelog/pull/3063#issuecomment-4557850867
* fix oversized clock
* click to prepare logging for contesting
Logic:
- if qso windows is open, call is sent to qso form
- if contest log is open, call is sent to contest log
- if both are open, call is sent to contest log
- if none is open, click opens qso form and call is sent to qso form
* handle exchange s prefill with data from the last qso and make exchange always uppercase
* add dropdown to qso list with option to delete qsos
* language fixes
* english comments
* center text
* fix missing dropdown on new qsos
* add date presets for contest session creator/editor
* basic worker implementation
* support multiple workers for clustering
* remove unnecessary node column
* simple availability check
* websocket for contesting
* bonus: add vip for visibilty in debug view
* use vip if available
* worker disabled in debug view if disabled in config
* racecondition for winkeyer breaks edit/delete dropdown
* racecondition for winkeyer breaks edit/delete dropdown
* qso handling for worker in contesting, no high interval heartbeat anymore
* clear heartbeat intervall
* fix some timing bugs
* remove dedicated worker controller as it's not needed
* handle whitespace
* trigger sync engine after processing QSO sync response and adjust last sync time to avoid spurious resyncs
* fix set and setLocal
* fix change detection and sync logic
* fix the lost of seconds due to edit
* fix table rendering
* watermark handling for true delta
* remove caching as it brings more problems here as benefits
* make serial as default exchangetype
* Add clarification on cluster setup requirements for worker URLs
* add operator to qso list if this is a clubstation
* fix bug for editing qsos in clubmode
* remove redundant code
* integers must be null in database
* fix bug in tabindex if 3 exchangefields are configured (serial, exchange, grid)
* nice contesting map (draft)
* map autofit
* add grid overlay
* calculate distanz and azimuth
* include rotor control via waveloggate (ws only)
* implement simple dedicated callbook lookup
* simpler and faster lookup
* option in contest session to disabled callbook lookup and only calculate dxcc
* syntax issue
* fix bug in CBR export
* catch empty result on contest
* remove some leftovers
* removed some comments
* remove unused stuff
* removed old todos/comments
* add 4s timeout for ajax transport
* you need to be admin for this
* translations
* add option to delete qso's aswell when deleting a session (opt in)
* add quickstart button in manager
* removed old todo
* fix "grows to bottom"
* disable "copy exchange to" if no exchange is set
* clear map on qso clear aswell
* same for scp
* updated documentation link
* calculate distanze and azimut also on grid only
* better space usage in qso input
* callbook db first approach, online lookup can be disabled while being cached for all users when enabled
* some input validation
* use only one sot for qrgtoband
* basic stats component
* fix html encoding
* render all aswell
* ascii
* store locally which time frame the user wants
* sync settings and warn user if something happend on the backend
* dev leftover
* show errors if callbook fails or callsign is invalid
* easier syntax
* Revert "easier syntax" - that was a mistake
This reverts commit 80c75dbf1e6c832f8d0616ea56b8b55d96c36418.
* fix for callbook lookup
* make pathline more visible
* better visibility of qsos
* add classic coordinates bar to the map
* fix bug in stats
* stretch max duration to 4s.. just in case
* simple sanity check in js to prevent unnecessary callbook lookups
* simulate tab after filling the call from scp
* fix poll radios with enabled worker
* reset po/mo files back to upstream/dev
* split contest exports, add back reg1test edi format
* keep the menu item but redirect to contesting
* better syntax and bugfix
* break it down further and fix typo ("constraint")
* use monospace font for input fields
* fix: in worker driven mode we need to do the heartbeat also on not focused windows otherwise we loose this contact
* fix: error handling on invalid times
* wavelog Ø
* more styling
* band lowercase fix
* Other is not a very descriptive title for a contest logger window, so we rename it to "Contest"
* custom contest name
* compare the whole array instead just a few settings
---------
Co-authored-by: int2001 <joerg@dj7nt.de>
Co-authored-by: HadleySo <71105018+HadleySo@users.noreply.github.com>
Co-authored-by: DB4SCW <dev@db4scw.de>
2026-06-14 14:23:00 +02:00
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
|
$CI =& get_instance();
|
|
|
|
|
$CI->config->load('worker', TRUE, TRUE);
|
|
|
|
|
|
|
|
|
|
$this->secret = (string) $CI->config->item('worker_secret', 'worker');
|
|
|
|
|
$timeout_seconds = (float) $CI->config->item('worker_timeout', 'worker');
|
|
|
|
|
$this->timeout_ms = (int) max(100, $timeout_seconds * 1000);
|
|
|
|
|
|
|
|
|
|
$vip_cfg = (string) $CI->config->item('worker_vip', 'worker');
|
|
|
|
|
$urls_cfg = $CI->config->item('worker_urls', 'worker');
|
|
|
|
|
if ($vip_cfg !== '') {
|
|
|
|
|
$this->url = rtrim($vip_cfg, '/');
|
|
|
|
|
} elseif (is_array($urls_cfg) && !empty($urls_cfg)) {
|
|
|
|
|
$this->url = rtrim($urls_cfg[0], '/');
|
|
|
|
|
} else {
|
|
|
|
|
$this->url = '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->enabled = (bool) $CI->config->item('worker_enabled', 'worker')
|
|
|
|
|
&& $this->url !== ''
|
|
|
|
|
&& $this->secret !== '';
|
2026-07-10 20:09:37 +02:00
|
|
|
$this->token_expiration = (int) ($CI->config->item('worker_token_expiration', 'worker') ?? 86400); // Default 24h
|
|
|
|
|
// if token_expiration is set to 0 or negative, we throw an exception to prevent misconfiguration
|
|
|
|
|
if ($this->token_expiration <= 0) {
|
|
|
|
|
throw new InvalidArgumentException('worker_token_expiration must be positive');
|
|
|
|
|
}
|
New Wavelog Contesting and Basics for Wavelog Worker (#3063)
* initial commit for new contesting in Wavelog
* implemented cache buster to match logic from upstream dev branch
* refactore data-store to idb since this will be much faster with a lot of QSOs (scale for the future)
* implementation of other exchange types (wip)
* updated migration version
* renamed mig
* renamed mig
* updated mig
* ESC Handler to reset form
* Add Websocket
* stretch maxDuration warning
We can stretch the maxDuration warning to 2 seconds to allow for more network latency and processing time. The heartbeat is protected against multiple parallel requests, so we can afford to be more lenient with the duration before showing a warning. This should help reduce false positives in environments with higher latency or slower processing.
* worked before warning in qso form
While input the logic checks in the qso list if the callisgn already exists on the same band and mode.
* translations
* fix band buttons
* updated migration after release 2.4.2
* Fixing create new contest, add clubstation permission check, add time check to contests
* Adding attach QSO to Contest
* Remove redundant clubstation checks
* Fix function tip
* Remove time check when launch contest
* Fixing contest attach main logbook, adding detach contest qso
* Enable clubstation contest QSO detach attach
* add space handler for callsign input
* set rst default to 599 for cw, 59 for others
* add grid and refactor some ui to make a better fitting here and there
* adjust tabindex
* add "copy exchange to" feature
* fix css for all themes
* adif and cbr export
* fix bug with wrong operator callsign
* add exchange type "exchange+grid"
* introduce new logic for exchangetypes and more flexible order selection
* fix broken qso list scroll
* legacy import feature
* more precise wording
* feat: inline editing of QSOs by double click in the QSO list
* redirect cabrillo to contesting manager
* Fix QSO permission check
* remove unused cabrillo stuff
* remove duplicate function
* fix check if worked before on band change
tnx to @int2001
* fix flash message for legacy importer
* make dropdown searchable and place "other" at the top
* add hint about "Other" contest
* avoid "flash" of winkeyer settings in qso logging, it shows up if cw is set as mode
* winkeyer for the new contesting
need proper testing by @AndreasK79 and @phl0 since I don't have a winkeyer myself. I tested with a python simulator...
* english comments
* proper singular/plural
* fix dropdown
* preselect active station location
* allow editing time aswell
* fix fontsize in radio buttons
* remove redundant qso count query
* cache last updated value for contest qsos to reduce db load
* index on user id
* cache also qso count
* you can now resize windows also on the edges
requested by @xyz667 in https://github.com/wavelog/wavelog/pull/3063#issuecomment-4557850867
* fix oversized clock
* click to prepare logging for contesting
Logic:
- if qso windows is open, call is sent to qso form
- if contest log is open, call is sent to contest log
- if both are open, call is sent to contest log
- if none is open, click opens qso form and call is sent to qso form
* handle exchange s prefill with data from the last qso and make exchange always uppercase
* add dropdown to qso list with option to delete qsos
* language fixes
* english comments
* center text
* fix missing dropdown on new qsos
* add date presets for contest session creator/editor
* basic worker implementation
* support multiple workers for clustering
* remove unnecessary node column
* simple availability check
* websocket for contesting
* bonus: add vip for visibilty in debug view
* use vip if available
* worker disabled in debug view if disabled in config
* racecondition for winkeyer breaks edit/delete dropdown
* racecondition for winkeyer breaks edit/delete dropdown
* qso handling for worker in contesting, no high interval heartbeat anymore
* clear heartbeat intervall
* fix some timing bugs
* remove dedicated worker controller as it's not needed
* handle whitespace
* trigger sync engine after processing QSO sync response and adjust last sync time to avoid spurious resyncs
* fix set and setLocal
* fix change detection and sync logic
* fix the lost of seconds due to edit
* fix table rendering
* watermark handling for true delta
* remove caching as it brings more problems here as benefits
* make serial as default exchangetype
* Add clarification on cluster setup requirements for worker URLs
* add operator to qso list if this is a clubstation
* fix bug for editing qsos in clubmode
* remove redundant code
* integers must be null in database
* fix bug in tabindex if 3 exchangefields are configured (serial, exchange, grid)
* nice contesting map (draft)
* map autofit
* add grid overlay
* calculate distanz and azimuth
* include rotor control via waveloggate (ws only)
* implement simple dedicated callbook lookup
* simpler and faster lookup
* option in contest session to disabled callbook lookup and only calculate dxcc
* syntax issue
* fix bug in CBR export
* catch empty result on contest
* remove some leftovers
* removed some comments
* remove unused stuff
* removed old todos/comments
* add 4s timeout for ajax transport
* you need to be admin for this
* translations
* add option to delete qso's aswell when deleting a session (opt in)
* add quickstart button in manager
* removed old todo
* fix "grows to bottom"
* disable "copy exchange to" if no exchange is set
* clear map on qso clear aswell
* same for scp
* updated documentation link
* calculate distanze and azimut also on grid only
* better space usage in qso input
* callbook db first approach, online lookup can be disabled while being cached for all users when enabled
* some input validation
* use only one sot for qrgtoband
* basic stats component
* fix html encoding
* render all aswell
* ascii
* store locally which time frame the user wants
* sync settings and warn user if something happend on the backend
* dev leftover
* show errors if callbook fails or callsign is invalid
* easier syntax
* Revert "easier syntax" - that was a mistake
This reverts commit 80c75dbf1e6c832f8d0616ea56b8b55d96c36418.
* fix for callbook lookup
* make pathline more visible
* better visibility of qsos
* add classic coordinates bar to the map
* fix bug in stats
* stretch max duration to 4s.. just in case
* simple sanity check in js to prevent unnecessary callbook lookups
* simulate tab after filling the call from scp
* fix poll radios with enabled worker
* reset po/mo files back to upstream/dev
* split contest exports, add back reg1test edi format
* keep the menu item but redirect to contesting
* better syntax and bugfix
* break it down further and fix typo ("constraint")
* use monospace font for input fields
* fix: in worker driven mode we need to do the heartbeat also on not focused windows otherwise we loose this contact
* fix: error handling on invalid times
* wavelog Ø
* more styling
* band lowercase fix
* Other is not a very descriptive title for a contest logger window, so we rename it to "Contest"
* custom contest name
* compare the whole array instead just a few settings
---------
Co-authored-by: int2001 <joerg@dj7nt.de>
Co-authored-by: HadleySo <71105018+HadleySo@users.noreply.github.com>
Co-authored-by: DB4SCW <dev@db4scw.de>
2026-06-14 14:23:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns true if the Worker is configured and enabled.
|
|
|
|
|
*/
|
|
|
|
|
public function is_enabled(): bool {
|
|
|
|
|
return $this->enabled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Registers a topic with the Worker so browsers can connect to it.
|
|
|
|
|
* Idempotent — safe to call on every page load.
|
|
|
|
|
*
|
|
|
|
|
* @param string $topic e.g. "contest_session.abc123"
|
|
|
|
|
* @param bool $require_token Whether browsers must present a valid HMAC token.
|
|
|
|
|
*/
|
|
|
|
|
public function register_topic(string $topic, bool $require_token = true): void {
|
|
|
|
|
$this->_internal_post('/internal/register', [
|
|
|
|
|
'topic' => $topic,
|
|
|
|
|
'meta' => ['require_token' => $require_token],
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Unregisters a topic. Call when the session is deleted.
|
|
|
|
|
* Idempotent — safe even if the Worker does not know the topic.
|
|
|
|
|
*/
|
|
|
|
|
public function unregister_topic(string $topic): void {
|
|
|
|
|
$this->_internal_post('/internal/unregister', ['topic' => $topic]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Broadcasts a payload to all clients subscribed to topic.
|
|
|
|
|
* If the Worker returns 404 (unknown topic after a restart), re-registers and retries once.
|
|
|
|
|
*
|
|
|
|
|
* @param string $topic
|
|
|
|
|
* @param array $payload Forwarded as-is as the push envelope payload.
|
|
|
|
|
*/
|
|
|
|
|
public function publish(string $topic, array $payload): void {
|
|
|
|
|
if (!$this->enabled) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$body = json_encode(['topic' => $topic, 'payload' => $payload]);
|
|
|
|
|
if ($body === false) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$ch = curl_init($this->url . '/internal/publish');
|
|
|
|
|
curl_setopt_array($ch, [
|
|
|
|
|
CURLOPT_POST => true,
|
|
|
|
|
CURLOPT_POSTFIELDS => $body,
|
|
|
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
|
|
|
CURLOPT_CONNECTTIMEOUT_MS => 500,
|
|
|
|
|
CURLOPT_TIMEOUT_MS => $this->timeout_ms,
|
|
|
|
|
CURLOPT_HTTPHEADER => [
|
|
|
|
|
'Content-Type: application/json',
|
|
|
|
|
'X-Worker-Secret: ' . $this->secret,
|
|
|
|
|
],
|
|
|
|
|
]);
|
|
|
|
|
curl_exec($ch);
|
|
|
|
|
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
|
|
|
$curl_err = curl_error($ch);
|
|
|
|
|
|
|
|
|
|
if ($curl_err !== '') {
|
|
|
|
|
log_message('error', 'Worker: publish(' . $topic . ') failed: ' . $curl_err);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 404 means the Worker restarted and lost the registry. Re-register and retry once.
|
|
|
|
|
if ($http_code === 404) {
|
|
|
|
|
$this->register_topic($topic);
|
|
|
|
|
$this->_internal_post('/internal/publish', ['topic' => $topic, 'payload' => $payload]);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($http_code !== 200) {
|
|
|
|
|
log_message('error', 'Worker: publish(' . $topic . ') returned HTTP ' . $http_code);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the public WebSocket URL for the browser (worker_client_url from config).
|
|
|
|
|
* Empty string if not configured.
|
|
|
|
|
*/
|
|
|
|
|
public function client_url(): string {
|
|
|
|
|
$CI =& get_instance();
|
|
|
|
|
return (string) $CI->config->item('worker_client_url', 'worker');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Generates a signed HMAC token for browser WebSocket authentication.
|
|
|
|
|
* The Go worker verifies this locally — no PHP callback needed.
|
|
|
|
|
* Returns empty string if the worker secret is not configured.
|
|
|
|
|
*
|
2026-06-16 12:20:49 +02:00
|
|
|
* The token is bound to a single topic. The worker compares the topic claim
|
|
|
|
|
* against the topic the browser tries to subscribe to, so a token for one
|
|
|
|
|
* topic cannot be used to join another.
|
|
|
|
|
*
|
|
|
|
|
* @param string $topic e.g. "contest_session.42" or "radio.5"
|
|
|
|
|
* @param int $ttl_seconds Default 24h
|
New Wavelog Contesting and Basics for Wavelog Worker (#3063)
* initial commit for new contesting in Wavelog
* implemented cache buster to match logic from upstream dev branch
* refactore data-store to idb since this will be much faster with a lot of QSOs (scale for the future)
* implementation of other exchange types (wip)
* updated migration version
* renamed mig
* renamed mig
* updated mig
* ESC Handler to reset form
* Add Websocket
* stretch maxDuration warning
We can stretch the maxDuration warning to 2 seconds to allow for more network latency and processing time. The heartbeat is protected against multiple parallel requests, so we can afford to be more lenient with the duration before showing a warning. This should help reduce false positives in environments with higher latency or slower processing.
* worked before warning in qso form
While input the logic checks in the qso list if the callisgn already exists on the same band and mode.
* translations
* fix band buttons
* updated migration after release 2.4.2
* Fixing create new contest, add clubstation permission check, add time check to contests
* Adding attach QSO to Contest
* Remove redundant clubstation checks
* Fix function tip
* Remove time check when launch contest
* Fixing contest attach main logbook, adding detach contest qso
* Enable clubstation contest QSO detach attach
* add space handler for callsign input
* set rst default to 599 for cw, 59 for others
* add grid and refactor some ui to make a better fitting here and there
* adjust tabindex
* add "copy exchange to" feature
* fix css for all themes
* adif and cbr export
* fix bug with wrong operator callsign
* add exchange type "exchange+grid"
* introduce new logic for exchangetypes and more flexible order selection
* fix broken qso list scroll
* legacy import feature
* more precise wording
* feat: inline editing of QSOs by double click in the QSO list
* redirect cabrillo to contesting manager
* Fix QSO permission check
* remove unused cabrillo stuff
* remove duplicate function
* fix check if worked before on band change
tnx to @int2001
* fix flash message for legacy importer
* make dropdown searchable and place "other" at the top
* add hint about "Other" contest
* avoid "flash" of winkeyer settings in qso logging, it shows up if cw is set as mode
* winkeyer for the new contesting
need proper testing by @AndreasK79 and @phl0 since I don't have a winkeyer myself. I tested with a python simulator...
* english comments
* proper singular/plural
* fix dropdown
* preselect active station location
* allow editing time aswell
* fix fontsize in radio buttons
* remove redundant qso count query
* cache last updated value for contest qsos to reduce db load
* index on user id
* cache also qso count
* you can now resize windows also on the edges
requested by @xyz667 in https://github.com/wavelog/wavelog/pull/3063#issuecomment-4557850867
* fix oversized clock
* click to prepare logging for contesting
Logic:
- if qso windows is open, call is sent to qso form
- if contest log is open, call is sent to contest log
- if both are open, call is sent to contest log
- if none is open, click opens qso form and call is sent to qso form
* handle exchange s prefill with data from the last qso and make exchange always uppercase
* add dropdown to qso list with option to delete qsos
* language fixes
* english comments
* center text
* fix missing dropdown on new qsos
* add date presets for contest session creator/editor
* basic worker implementation
* support multiple workers for clustering
* remove unnecessary node column
* simple availability check
* websocket for contesting
* bonus: add vip for visibilty in debug view
* use vip if available
* worker disabled in debug view if disabled in config
* racecondition for winkeyer breaks edit/delete dropdown
* racecondition for winkeyer breaks edit/delete dropdown
* qso handling for worker in contesting, no high interval heartbeat anymore
* clear heartbeat intervall
* fix some timing bugs
* remove dedicated worker controller as it's not needed
* handle whitespace
* trigger sync engine after processing QSO sync response and adjust last sync time to avoid spurious resyncs
* fix set and setLocal
* fix change detection and sync logic
* fix the lost of seconds due to edit
* fix table rendering
* watermark handling for true delta
* remove caching as it brings more problems here as benefits
* make serial as default exchangetype
* Add clarification on cluster setup requirements for worker URLs
* add operator to qso list if this is a clubstation
* fix bug for editing qsos in clubmode
* remove redundant code
* integers must be null in database
* fix bug in tabindex if 3 exchangefields are configured (serial, exchange, grid)
* nice contesting map (draft)
* map autofit
* add grid overlay
* calculate distanz and azimuth
* include rotor control via waveloggate (ws only)
* implement simple dedicated callbook lookup
* simpler and faster lookup
* option in contest session to disabled callbook lookup and only calculate dxcc
* syntax issue
* fix bug in CBR export
* catch empty result on contest
* remove some leftovers
* removed some comments
* remove unused stuff
* removed old todos/comments
* add 4s timeout for ajax transport
* you need to be admin for this
* translations
* add option to delete qso's aswell when deleting a session (opt in)
* add quickstart button in manager
* removed old todo
* fix "grows to bottom"
* disable "copy exchange to" if no exchange is set
* clear map on qso clear aswell
* same for scp
* updated documentation link
* calculate distanze and azimut also on grid only
* better space usage in qso input
* callbook db first approach, online lookup can be disabled while being cached for all users when enabled
* some input validation
* use only one sot for qrgtoband
* basic stats component
* fix html encoding
* render all aswell
* ascii
* store locally which time frame the user wants
* sync settings and warn user if something happend on the backend
* dev leftover
* show errors if callbook fails or callsign is invalid
* easier syntax
* Revert "easier syntax" - that was a mistake
This reverts commit 80c75dbf1e6c832f8d0616ea56b8b55d96c36418.
* fix for callbook lookup
* make pathline more visible
* better visibility of qsos
* add classic coordinates bar to the map
* fix bug in stats
* stretch max duration to 4s.. just in case
* simple sanity check in js to prevent unnecessary callbook lookups
* simulate tab after filling the call from scp
* fix poll radios with enabled worker
* reset po/mo files back to upstream/dev
* split contest exports, add back reg1test edi format
* keep the menu item but redirect to contesting
* better syntax and bugfix
* break it down further and fix typo ("constraint")
* use monospace font for input fields
* fix: in worker driven mode we need to do the heartbeat also on not focused windows otherwise we loose this contact
* fix: error handling on invalid times
* wavelog Ø
* more styling
* band lowercase fix
* Other is not a very descriptive title for a contest logger window, so we rename it to "Contest"
* custom contest name
* compare the whole array instead just a few settings
---------
Co-authored-by: int2001 <joerg@dj7nt.de>
Co-authored-by: HadleySo <71105018+HadleySo@users.noreply.github.com>
Co-authored-by: DB4SCW <dev@db4scw.de>
2026-06-14 14:23:00 +02:00
|
|
|
*/
|
2026-07-10 19:50:39 +02:00
|
|
|
public function create_token(string $topic, $ttl_seconds = null): string {
|
New Wavelog Contesting and Basics for Wavelog Worker (#3063)
* initial commit for new contesting in Wavelog
* implemented cache buster to match logic from upstream dev branch
* refactore data-store to idb since this will be much faster with a lot of QSOs (scale for the future)
* implementation of other exchange types (wip)
* updated migration version
* renamed mig
* renamed mig
* updated mig
* ESC Handler to reset form
* Add Websocket
* stretch maxDuration warning
We can stretch the maxDuration warning to 2 seconds to allow for more network latency and processing time. The heartbeat is protected against multiple parallel requests, so we can afford to be more lenient with the duration before showing a warning. This should help reduce false positives in environments with higher latency or slower processing.
* worked before warning in qso form
While input the logic checks in the qso list if the callisgn already exists on the same band and mode.
* translations
* fix band buttons
* updated migration after release 2.4.2
* Fixing create new contest, add clubstation permission check, add time check to contests
* Adding attach QSO to Contest
* Remove redundant clubstation checks
* Fix function tip
* Remove time check when launch contest
* Fixing contest attach main logbook, adding detach contest qso
* Enable clubstation contest QSO detach attach
* add space handler for callsign input
* set rst default to 599 for cw, 59 for others
* add grid and refactor some ui to make a better fitting here and there
* adjust tabindex
* add "copy exchange to" feature
* fix css for all themes
* adif and cbr export
* fix bug with wrong operator callsign
* add exchange type "exchange+grid"
* introduce new logic for exchangetypes and more flexible order selection
* fix broken qso list scroll
* legacy import feature
* more precise wording
* feat: inline editing of QSOs by double click in the QSO list
* redirect cabrillo to contesting manager
* Fix QSO permission check
* remove unused cabrillo stuff
* remove duplicate function
* fix check if worked before on band change
tnx to @int2001
* fix flash message for legacy importer
* make dropdown searchable and place "other" at the top
* add hint about "Other" contest
* avoid "flash" of winkeyer settings in qso logging, it shows up if cw is set as mode
* winkeyer for the new contesting
need proper testing by @AndreasK79 and @phl0 since I don't have a winkeyer myself. I tested with a python simulator...
* english comments
* proper singular/plural
* fix dropdown
* preselect active station location
* allow editing time aswell
* fix fontsize in radio buttons
* remove redundant qso count query
* cache last updated value for contest qsos to reduce db load
* index on user id
* cache also qso count
* you can now resize windows also on the edges
requested by @xyz667 in https://github.com/wavelog/wavelog/pull/3063#issuecomment-4557850867
* fix oversized clock
* click to prepare logging for contesting
Logic:
- if qso windows is open, call is sent to qso form
- if contest log is open, call is sent to contest log
- if both are open, call is sent to contest log
- if none is open, click opens qso form and call is sent to qso form
* handle exchange s prefill with data from the last qso and make exchange always uppercase
* add dropdown to qso list with option to delete qsos
* language fixes
* english comments
* center text
* fix missing dropdown on new qsos
* add date presets for contest session creator/editor
* basic worker implementation
* support multiple workers for clustering
* remove unnecessary node column
* simple availability check
* websocket for contesting
* bonus: add vip for visibilty in debug view
* use vip if available
* worker disabled in debug view if disabled in config
* racecondition for winkeyer breaks edit/delete dropdown
* racecondition for winkeyer breaks edit/delete dropdown
* qso handling for worker in contesting, no high interval heartbeat anymore
* clear heartbeat intervall
* fix some timing bugs
* remove dedicated worker controller as it's not needed
* handle whitespace
* trigger sync engine after processing QSO sync response and adjust last sync time to avoid spurious resyncs
* fix set and setLocal
* fix change detection and sync logic
* fix the lost of seconds due to edit
* fix table rendering
* watermark handling for true delta
* remove caching as it brings more problems here as benefits
* make serial as default exchangetype
* Add clarification on cluster setup requirements for worker URLs
* add operator to qso list if this is a clubstation
* fix bug for editing qsos in clubmode
* remove redundant code
* integers must be null in database
* fix bug in tabindex if 3 exchangefields are configured (serial, exchange, grid)
* nice contesting map (draft)
* map autofit
* add grid overlay
* calculate distanz and azimuth
* include rotor control via waveloggate (ws only)
* implement simple dedicated callbook lookup
* simpler and faster lookup
* option in contest session to disabled callbook lookup and only calculate dxcc
* syntax issue
* fix bug in CBR export
* catch empty result on contest
* remove some leftovers
* removed some comments
* remove unused stuff
* removed old todos/comments
* add 4s timeout for ajax transport
* you need to be admin for this
* translations
* add option to delete qso's aswell when deleting a session (opt in)
* add quickstart button in manager
* removed old todo
* fix "grows to bottom"
* disable "copy exchange to" if no exchange is set
* clear map on qso clear aswell
* same for scp
* updated documentation link
* calculate distanze and azimut also on grid only
* better space usage in qso input
* callbook db first approach, online lookup can be disabled while being cached for all users when enabled
* some input validation
* use only one sot for qrgtoband
* basic stats component
* fix html encoding
* render all aswell
* ascii
* store locally which time frame the user wants
* sync settings and warn user if something happend on the backend
* dev leftover
* show errors if callbook fails or callsign is invalid
* easier syntax
* Revert "easier syntax" - that was a mistake
This reverts commit 80c75dbf1e6c832f8d0616ea56b8b55d96c36418.
* fix for callbook lookup
* make pathline more visible
* better visibility of qsos
* add classic coordinates bar to the map
* fix bug in stats
* stretch max duration to 4s.. just in case
* simple sanity check in js to prevent unnecessary callbook lookups
* simulate tab after filling the call from scp
* fix poll radios with enabled worker
* reset po/mo files back to upstream/dev
* split contest exports, add back reg1test edi format
* keep the menu item but redirect to contesting
* better syntax and bugfix
* break it down further and fix typo ("constraint")
* use monospace font for input fields
* fix: in worker driven mode we need to do the heartbeat also on not focused windows otherwise we loose this contact
* fix: error handling on invalid times
* wavelog Ø
* more styling
* band lowercase fix
* Other is not a very descriptive title for a contest logger window, so we rename it to "Contest"
* custom contest name
* compare the whole array instead just a few settings
---------
Co-authored-by: int2001 <joerg@dj7nt.de>
Co-authored-by: HadleySo <71105018+HadleySo@users.noreply.github.com>
Co-authored-by: DB4SCW <dev@db4scw.de>
2026-06-14 14:23:00 +02:00
|
|
|
if ($this->secret === '') {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-10 19:50:39 +02:00
|
|
|
if ($ttl_seconds === null) {
|
|
|
|
|
$ttl_seconds = $this->token_expiration;
|
|
|
|
|
}
|
|
|
|
|
|
New Wavelog Contesting and Basics for Wavelog Worker (#3063)
* initial commit for new contesting in Wavelog
* implemented cache buster to match logic from upstream dev branch
* refactore data-store to idb since this will be much faster with a lot of QSOs (scale for the future)
* implementation of other exchange types (wip)
* updated migration version
* renamed mig
* renamed mig
* updated mig
* ESC Handler to reset form
* Add Websocket
* stretch maxDuration warning
We can stretch the maxDuration warning to 2 seconds to allow for more network latency and processing time. The heartbeat is protected against multiple parallel requests, so we can afford to be more lenient with the duration before showing a warning. This should help reduce false positives in environments with higher latency or slower processing.
* worked before warning in qso form
While input the logic checks in the qso list if the callisgn already exists on the same band and mode.
* translations
* fix band buttons
* updated migration after release 2.4.2
* Fixing create new contest, add clubstation permission check, add time check to contests
* Adding attach QSO to Contest
* Remove redundant clubstation checks
* Fix function tip
* Remove time check when launch contest
* Fixing contest attach main logbook, adding detach contest qso
* Enable clubstation contest QSO detach attach
* add space handler for callsign input
* set rst default to 599 for cw, 59 for others
* add grid and refactor some ui to make a better fitting here and there
* adjust tabindex
* add "copy exchange to" feature
* fix css for all themes
* adif and cbr export
* fix bug with wrong operator callsign
* add exchange type "exchange+grid"
* introduce new logic for exchangetypes and more flexible order selection
* fix broken qso list scroll
* legacy import feature
* more precise wording
* feat: inline editing of QSOs by double click in the QSO list
* redirect cabrillo to contesting manager
* Fix QSO permission check
* remove unused cabrillo stuff
* remove duplicate function
* fix check if worked before on band change
tnx to @int2001
* fix flash message for legacy importer
* make dropdown searchable and place "other" at the top
* add hint about "Other" contest
* avoid "flash" of winkeyer settings in qso logging, it shows up if cw is set as mode
* winkeyer for the new contesting
need proper testing by @AndreasK79 and @phl0 since I don't have a winkeyer myself. I tested with a python simulator...
* english comments
* proper singular/plural
* fix dropdown
* preselect active station location
* allow editing time aswell
* fix fontsize in radio buttons
* remove redundant qso count query
* cache last updated value for contest qsos to reduce db load
* index on user id
* cache also qso count
* you can now resize windows also on the edges
requested by @xyz667 in https://github.com/wavelog/wavelog/pull/3063#issuecomment-4557850867
* fix oversized clock
* click to prepare logging for contesting
Logic:
- if qso windows is open, call is sent to qso form
- if contest log is open, call is sent to contest log
- if both are open, call is sent to contest log
- if none is open, click opens qso form and call is sent to qso form
* handle exchange s prefill with data from the last qso and make exchange always uppercase
* add dropdown to qso list with option to delete qsos
* language fixes
* english comments
* center text
* fix missing dropdown on new qsos
* add date presets for contest session creator/editor
* basic worker implementation
* support multiple workers for clustering
* remove unnecessary node column
* simple availability check
* websocket for contesting
* bonus: add vip for visibilty in debug view
* use vip if available
* worker disabled in debug view if disabled in config
* racecondition for winkeyer breaks edit/delete dropdown
* racecondition for winkeyer breaks edit/delete dropdown
* qso handling for worker in contesting, no high interval heartbeat anymore
* clear heartbeat intervall
* fix some timing bugs
* remove dedicated worker controller as it's not needed
* handle whitespace
* trigger sync engine after processing QSO sync response and adjust last sync time to avoid spurious resyncs
* fix set and setLocal
* fix change detection and sync logic
* fix the lost of seconds due to edit
* fix table rendering
* watermark handling for true delta
* remove caching as it brings more problems here as benefits
* make serial as default exchangetype
* Add clarification on cluster setup requirements for worker URLs
* add operator to qso list if this is a clubstation
* fix bug for editing qsos in clubmode
* remove redundant code
* integers must be null in database
* fix bug in tabindex if 3 exchangefields are configured (serial, exchange, grid)
* nice contesting map (draft)
* map autofit
* add grid overlay
* calculate distanz and azimuth
* include rotor control via waveloggate (ws only)
* implement simple dedicated callbook lookup
* simpler and faster lookup
* option in contest session to disabled callbook lookup and only calculate dxcc
* syntax issue
* fix bug in CBR export
* catch empty result on contest
* remove some leftovers
* removed some comments
* remove unused stuff
* removed old todos/comments
* add 4s timeout for ajax transport
* you need to be admin for this
* translations
* add option to delete qso's aswell when deleting a session (opt in)
* add quickstart button in manager
* removed old todo
* fix "grows to bottom"
* disable "copy exchange to" if no exchange is set
* clear map on qso clear aswell
* same for scp
* updated documentation link
* calculate distanze and azimut also on grid only
* better space usage in qso input
* callbook db first approach, online lookup can be disabled while being cached for all users when enabled
* some input validation
* use only one sot for qrgtoband
* basic stats component
* fix html encoding
* render all aswell
* ascii
* store locally which time frame the user wants
* sync settings and warn user if something happend on the backend
* dev leftover
* show errors if callbook fails or callsign is invalid
* easier syntax
* Revert "easier syntax" - that was a mistake
This reverts commit 80c75dbf1e6c832f8d0616ea56b8b55d96c36418.
* fix for callbook lookup
* make pathline more visible
* better visibility of qsos
* add classic coordinates bar to the map
* fix bug in stats
* stretch max duration to 4s.. just in case
* simple sanity check in js to prevent unnecessary callbook lookups
* simulate tab after filling the call from scp
* fix poll radios with enabled worker
* reset po/mo files back to upstream/dev
* split contest exports, add back reg1test edi format
* keep the menu item but redirect to contesting
* better syntax and bugfix
* break it down further and fix typo ("constraint")
* use monospace font for input fields
* fix: in worker driven mode we need to do the heartbeat also on not focused windows otherwise we loose this contact
* fix: error handling on invalid times
* wavelog Ø
* more styling
* band lowercase fix
* Other is not a very descriptive title for a contest logger window, so we rename it to "Contest"
* custom contest name
* compare the whole array instead just a few settings
---------
Co-authored-by: int2001 <joerg@dj7nt.de>
Co-authored-by: HadleySo <71105018+HadleySo@users.noreply.github.com>
Co-authored-by: DB4SCW <dev@db4scw.de>
2026-06-14 14:23:00 +02:00
|
|
|
$CI =& get_instance();
|
|
|
|
|
$user_id = intval($CI->session->userdata('source_uid') ?: $CI->session->userdata('user_id'));
|
|
|
|
|
|
|
|
|
|
$claims = [
|
2026-06-16 12:20:49 +02:00
|
|
|
'user_id' => $user_id,
|
|
|
|
|
'topic' => $topic,
|
|
|
|
|
'expires' => time() + $ttl_seconds,
|
New Wavelog Contesting and Basics for Wavelog Worker (#3063)
* initial commit for new contesting in Wavelog
* implemented cache buster to match logic from upstream dev branch
* refactore data-store to idb since this will be much faster with a lot of QSOs (scale for the future)
* implementation of other exchange types (wip)
* updated migration version
* renamed mig
* renamed mig
* updated mig
* ESC Handler to reset form
* Add Websocket
* stretch maxDuration warning
We can stretch the maxDuration warning to 2 seconds to allow for more network latency and processing time. The heartbeat is protected against multiple parallel requests, so we can afford to be more lenient with the duration before showing a warning. This should help reduce false positives in environments with higher latency or slower processing.
* worked before warning in qso form
While input the logic checks in the qso list if the callisgn already exists on the same band and mode.
* translations
* fix band buttons
* updated migration after release 2.4.2
* Fixing create new contest, add clubstation permission check, add time check to contests
* Adding attach QSO to Contest
* Remove redundant clubstation checks
* Fix function tip
* Remove time check when launch contest
* Fixing contest attach main logbook, adding detach contest qso
* Enable clubstation contest QSO detach attach
* add space handler for callsign input
* set rst default to 599 for cw, 59 for others
* add grid and refactor some ui to make a better fitting here and there
* adjust tabindex
* add "copy exchange to" feature
* fix css for all themes
* adif and cbr export
* fix bug with wrong operator callsign
* add exchange type "exchange+grid"
* introduce new logic for exchangetypes and more flexible order selection
* fix broken qso list scroll
* legacy import feature
* more precise wording
* feat: inline editing of QSOs by double click in the QSO list
* redirect cabrillo to contesting manager
* Fix QSO permission check
* remove unused cabrillo stuff
* remove duplicate function
* fix check if worked before on band change
tnx to @int2001
* fix flash message for legacy importer
* make dropdown searchable and place "other" at the top
* add hint about "Other" contest
* avoid "flash" of winkeyer settings in qso logging, it shows up if cw is set as mode
* winkeyer for the new contesting
need proper testing by @AndreasK79 and @phl0 since I don't have a winkeyer myself. I tested with a python simulator...
* english comments
* proper singular/plural
* fix dropdown
* preselect active station location
* allow editing time aswell
* fix fontsize in radio buttons
* remove redundant qso count query
* cache last updated value for contest qsos to reduce db load
* index on user id
* cache also qso count
* you can now resize windows also on the edges
requested by @xyz667 in https://github.com/wavelog/wavelog/pull/3063#issuecomment-4557850867
* fix oversized clock
* click to prepare logging for contesting
Logic:
- if qso windows is open, call is sent to qso form
- if contest log is open, call is sent to contest log
- if both are open, call is sent to contest log
- if none is open, click opens qso form and call is sent to qso form
* handle exchange s prefill with data from the last qso and make exchange always uppercase
* add dropdown to qso list with option to delete qsos
* language fixes
* english comments
* center text
* fix missing dropdown on new qsos
* add date presets for contest session creator/editor
* basic worker implementation
* support multiple workers for clustering
* remove unnecessary node column
* simple availability check
* websocket for contesting
* bonus: add vip for visibilty in debug view
* use vip if available
* worker disabled in debug view if disabled in config
* racecondition for winkeyer breaks edit/delete dropdown
* racecondition for winkeyer breaks edit/delete dropdown
* qso handling for worker in contesting, no high interval heartbeat anymore
* clear heartbeat intervall
* fix some timing bugs
* remove dedicated worker controller as it's not needed
* handle whitespace
* trigger sync engine after processing QSO sync response and adjust last sync time to avoid spurious resyncs
* fix set and setLocal
* fix change detection and sync logic
* fix the lost of seconds due to edit
* fix table rendering
* watermark handling for true delta
* remove caching as it brings more problems here as benefits
* make serial as default exchangetype
* Add clarification on cluster setup requirements for worker URLs
* add operator to qso list if this is a clubstation
* fix bug for editing qsos in clubmode
* remove redundant code
* integers must be null in database
* fix bug in tabindex if 3 exchangefields are configured (serial, exchange, grid)
* nice contesting map (draft)
* map autofit
* add grid overlay
* calculate distanz and azimuth
* include rotor control via waveloggate (ws only)
* implement simple dedicated callbook lookup
* simpler and faster lookup
* option in contest session to disabled callbook lookup and only calculate dxcc
* syntax issue
* fix bug in CBR export
* catch empty result on contest
* remove some leftovers
* removed some comments
* remove unused stuff
* removed old todos/comments
* add 4s timeout for ajax transport
* you need to be admin for this
* translations
* add option to delete qso's aswell when deleting a session (opt in)
* add quickstart button in manager
* removed old todo
* fix "grows to bottom"
* disable "copy exchange to" if no exchange is set
* clear map on qso clear aswell
* same for scp
* updated documentation link
* calculate distanze and azimut also on grid only
* better space usage in qso input
* callbook db first approach, online lookup can be disabled while being cached for all users when enabled
* some input validation
* use only one sot for qrgtoband
* basic stats component
* fix html encoding
* render all aswell
* ascii
* store locally which time frame the user wants
* sync settings and warn user if something happend on the backend
* dev leftover
* show errors if callbook fails or callsign is invalid
* easier syntax
* Revert "easier syntax" - that was a mistake
This reverts commit 80c75dbf1e6c832f8d0616ea56b8b55d96c36418.
* fix for callbook lookup
* make pathline more visible
* better visibility of qsos
* add classic coordinates bar to the map
* fix bug in stats
* stretch max duration to 4s.. just in case
* simple sanity check in js to prevent unnecessary callbook lookups
* simulate tab after filling the call from scp
* fix poll radios with enabled worker
* reset po/mo files back to upstream/dev
* split contest exports, add back reg1test edi format
* keep the menu item but redirect to contesting
* better syntax and bugfix
* break it down further and fix typo ("constraint")
* use monospace font for input fields
* fix: in worker driven mode we need to do the heartbeat also on not focused windows otherwise we loose this contact
* fix: error handling on invalid times
* wavelog Ø
* more styling
* band lowercase fix
* Other is not a very descriptive title for a contest logger window, so we rename it to "Contest"
* custom contest name
* compare the whole array instead just a few settings
---------
Co-authored-by: int2001 <joerg@dj7nt.de>
Co-authored-by: HadleySo <71105018+HadleySo@users.noreply.github.com>
Co-authored-by: DB4SCW <dev@db4scw.de>
2026-06-14 14:23:00 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$encoded = bin2hex(json_encode($claims));
|
|
|
|
|
$sig = hash_hmac('sha256', $encoded, $this->secret);
|
|
|
|
|
return $encoded . '.' . $sig;
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-17 11:50:11 +02:00
|
|
|
/**
|
|
|
|
|
* Live status of the worker cluster, fanned out to every configured node's
|
|
|
|
|
* /internal/status endpoint. Reused by the debug page and the statistics
|
|
|
|
|
* API so the fan-out lives in one place.
|
|
|
|
|
*
|
|
|
|
|
* @return array {
|
|
|
|
|
* enabled: bool,
|
|
|
|
|
* vip: string|null,
|
|
|
|
|
* nodes_total: int,
|
|
|
|
|
* nodes_alive: int,
|
|
|
|
|
* active_topics: int|null, // cluster sum, null when no node answered
|
|
|
|
|
* connected_clients: int|null, // cluster sum, null when no node answered
|
|
|
|
|
* nodes: array<int, array{url,alive,version,active_topics,connected_clients,uptime}>
|
|
|
|
|
* }
|
|
|
|
|
*/
|
|
|
|
|
public function status(): array {
|
|
|
|
|
$CI =& get_instance();
|
|
|
|
|
$vip_url = rtrim((string) $CI->config->item('worker_vip', 'worker'), '/');
|
|
|
|
|
|
|
|
|
|
$result = [
|
|
|
|
|
'enabled' => $this->enabled,
|
|
|
|
|
'vip' => $vip_url !== '' ? $vip_url : null,
|
|
|
|
|
'nodes_total' => 0,
|
|
|
|
|
'nodes_alive' => 0,
|
|
|
|
|
'active_topics' => null,
|
|
|
|
|
'connected_clients' => null,
|
|
|
|
|
'nodes' => [],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
if (!$this->enabled) {
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$urls_cfg = $CI->config->item('worker_urls', 'worker');
|
|
|
|
|
$urls = is_array($urls_cfg) ? array_map(fn($u) => rtrim($u, '/'), $urls_cfg) : [];
|
|
|
|
|
if (empty($urls) && $this->url !== '') {
|
|
|
|
|
$urls = [$this->url];
|
|
|
|
|
}
|
|
|
|
|
$result['nodes_total'] = count($urls);
|
|
|
|
|
|
|
|
|
|
$topics = 0;
|
|
|
|
|
$clients = 0;
|
|
|
|
|
$have_metrics = false;
|
|
|
|
|
foreach ($urls as $url) {
|
|
|
|
|
$node = $this->fetch_node_status($url);
|
|
|
|
|
if ($node['alive']) {
|
|
|
|
|
$result['nodes_alive']++;
|
|
|
|
|
}
|
|
|
|
|
if ($node['active_topics'] !== null) {
|
|
|
|
|
$topics += (int) $node['active_topics'];
|
|
|
|
|
$have_metrics = true;
|
|
|
|
|
}
|
|
|
|
|
if ($node['connected_clients'] !== null) {
|
|
|
|
|
$clients += (int) $node['connected_clients'];
|
|
|
|
|
$have_metrics = true;
|
|
|
|
|
}
|
|
|
|
|
$result['nodes'][] = $node;
|
|
|
|
|
}
|
|
|
|
|
if ($have_metrics) {
|
|
|
|
|
$result['active_topics'] = $topics;
|
|
|
|
|
$result['connected_clients'] = $clients;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Query a single worker node's /internal/status. Never throws: an
|
|
|
|
|
* unreachable node is reported as alive=false with null metrics.
|
|
|
|
|
*/
|
|
|
|
|
private function fetch_node_status(string $url): array {
|
|
|
|
|
$ch = curl_init($url . '/internal/status');
|
|
|
|
|
curl_setopt_array($ch, [
|
|
|
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
|
|
|
CURLOPT_CONNECTTIMEOUT_MS => 300,
|
|
|
|
|
CURLOPT_TIMEOUT_MS => 800,
|
|
|
|
|
CURLOPT_HTTPHEADER => ['X-Worker-Secret: ' . $this->secret],
|
|
|
|
|
]);
|
|
|
|
|
$raw = curl_exec($ch);
|
|
|
|
|
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
|
|
|
|
|
|
|
|
$stats = ($http_code === 200 && $raw) ? json_decode($raw, true) : null;
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
'url' => $url,
|
|
|
|
|
'alive' => $http_code === 200,
|
|
|
|
|
'version' => $stats['version'] ?? null,
|
|
|
|
|
'active_topics' => $stats['active_topics'] ?? null,
|
|
|
|
|
'connected_clients' => $stats['connected_clients'] ?? null,
|
|
|
|
|
'uptime' => $stats['uptime'] ?? null,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
New Wavelog Contesting and Basics for Wavelog Worker (#3063)
* initial commit for new contesting in Wavelog
* implemented cache buster to match logic from upstream dev branch
* refactore data-store to idb since this will be much faster with a lot of QSOs (scale for the future)
* implementation of other exchange types (wip)
* updated migration version
* renamed mig
* renamed mig
* updated mig
* ESC Handler to reset form
* Add Websocket
* stretch maxDuration warning
We can stretch the maxDuration warning to 2 seconds to allow for more network latency and processing time. The heartbeat is protected against multiple parallel requests, so we can afford to be more lenient with the duration before showing a warning. This should help reduce false positives in environments with higher latency or slower processing.
* worked before warning in qso form
While input the logic checks in the qso list if the callisgn already exists on the same band and mode.
* translations
* fix band buttons
* updated migration after release 2.4.2
* Fixing create new contest, add clubstation permission check, add time check to contests
* Adding attach QSO to Contest
* Remove redundant clubstation checks
* Fix function tip
* Remove time check when launch contest
* Fixing contest attach main logbook, adding detach contest qso
* Enable clubstation contest QSO detach attach
* add space handler for callsign input
* set rst default to 599 for cw, 59 for others
* add grid and refactor some ui to make a better fitting here and there
* adjust tabindex
* add "copy exchange to" feature
* fix css for all themes
* adif and cbr export
* fix bug with wrong operator callsign
* add exchange type "exchange+grid"
* introduce new logic for exchangetypes and more flexible order selection
* fix broken qso list scroll
* legacy import feature
* more precise wording
* feat: inline editing of QSOs by double click in the QSO list
* redirect cabrillo to contesting manager
* Fix QSO permission check
* remove unused cabrillo stuff
* remove duplicate function
* fix check if worked before on band change
tnx to @int2001
* fix flash message for legacy importer
* make dropdown searchable and place "other" at the top
* add hint about "Other" contest
* avoid "flash" of winkeyer settings in qso logging, it shows up if cw is set as mode
* winkeyer for the new contesting
need proper testing by @AndreasK79 and @phl0 since I don't have a winkeyer myself. I tested with a python simulator...
* english comments
* proper singular/plural
* fix dropdown
* preselect active station location
* allow editing time aswell
* fix fontsize in radio buttons
* remove redundant qso count query
* cache last updated value for contest qsos to reduce db load
* index on user id
* cache also qso count
* you can now resize windows also on the edges
requested by @xyz667 in https://github.com/wavelog/wavelog/pull/3063#issuecomment-4557850867
* fix oversized clock
* click to prepare logging for contesting
Logic:
- if qso windows is open, call is sent to qso form
- if contest log is open, call is sent to contest log
- if both are open, call is sent to contest log
- if none is open, click opens qso form and call is sent to qso form
* handle exchange s prefill with data from the last qso and make exchange always uppercase
* add dropdown to qso list with option to delete qsos
* language fixes
* english comments
* center text
* fix missing dropdown on new qsos
* add date presets for contest session creator/editor
* basic worker implementation
* support multiple workers for clustering
* remove unnecessary node column
* simple availability check
* websocket for contesting
* bonus: add vip for visibilty in debug view
* use vip if available
* worker disabled in debug view if disabled in config
* racecondition for winkeyer breaks edit/delete dropdown
* racecondition for winkeyer breaks edit/delete dropdown
* qso handling for worker in contesting, no high interval heartbeat anymore
* clear heartbeat intervall
* fix some timing bugs
* remove dedicated worker controller as it's not needed
* handle whitespace
* trigger sync engine after processing QSO sync response and adjust last sync time to avoid spurious resyncs
* fix set and setLocal
* fix change detection and sync logic
* fix the lost of seconds due to edit
* fix table rendering
* watermark handling for true delta
* remove caching as it brings more problems here as benefits
* make serial as default exchangetype
* Add clarification on cluster setup requirements for worker URLs
* add operator to qso list if this is a clubstation
* fix bug for editing qsos in clubmode
* remove redundant code
* integers must be null in database
* fix bug in tabindex if 3 exchangefields are configured (serial, exchange, grid)
* nice contesting map (draft)
* map autofit
* add grid overlay
* calculate distanz and azimuth
* include rotor control via waveloggate (ws only)
* implement simple dedicated callbook lookup
* simpler and faster lookup
* option in contest session to disabled callbook lookup and only calculate dxcc
* syntax issue
* fix bug in CBR export
* catch empty result on contest
* remove some leftovers
* removed some comments
* remove unused stuff
* removed old todos/comments
* add 4s timeout for ajax transport
* you need to be admin for this
* translations
* add option to delete qso's aswell when deleting a session (opt in)
* add quickstart button in manager
* removed old todo
* fix "grows to bottom"
* disable "copy exchange to" if no exchange is set
* clear map on qso clear aswell
* same for scp
* updated documentation link
* calculate distanze and azimut also on grid only
* better space usage in qso input
* callbook db first approach, online lookup can be disabled while being cached for all users when enabled
* some input validation
* use only one sot for qrgtoband
* basic stats component
* fix html encoding
* render all aswell
* ascii
* store locally which time frame the user wants
* sync settings and warn user if something happend on the backend
* dev leftover
* show errors if callbook fails or callsign is invalid
* easier syntax
* Revert "easier syntax" - that was a mistake
This reverts commit 80c75dbf1e6c832f8d0616ea56b8b55d96c36418.
* fix for callbook lookup
* make pathline more visible
* better visibility of qsos
* add classic coordinates bar to the map
* fix bug in stats
* stretch max duration to 4s.. just in case
* simple sanity check in js to prevent unnecessary callbook lookups
* simulate tab after filling the call from scp
* fix poll radios with enabled worker
* reset po/mo files back to upstream/dev
* split contest exports, add back reg1test edi format
* keep the menu item but redirect to contesting
* better syntax and bugfix
* break it down further and fix typo ("constraint")
* use monospace font for input fields
* fix: in worker driven mode we need to do the heartbeat also on not focused windows otherwise we loose this contact
* fix: error handling on invalid times
* wavelog Ø
* more styling
* band lowercase fix
* Other is not a very descriptive title for a contest logger window, so we rename it to "Contest"
* custom contest name
* compare the whole array instead just a few settings
---------
Co-authored-by: int2001 <joerg@dj7nt.de>
Co-authored-by: HadleySo <71105018+HadleySo@users.noreply.github.com>
Co-authored-by: DB4SCW <dev@db4scw.de>
2026-06-14 14:23:00 +02:00
|
|
|
/**
|
|
|
|
|
* Shared fire-and-forget POST to a Worker internal API endpoint.
|
|
|
|
|
*/
|
|
|
|
|
private function _internal_post(string $path, array $body): void {
|
|
|
|
|
if (!$this->enabled) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$encoded = json_encode($body);
|
|
|
|
|
if ($encoded === false) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$ch = curl_init($this->url . $path);
|
|
|
|
|
curl_setopt_array($ch, [
|
|
|
|
|
CURLOPT_POST => true,
|
|
|
|
|
CURLOPT_POSTFIELDS => $encoded,
|
|
|
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
|
|
|
CURLOPT_CONNECTTIMEOUT_MS => 500,
|
|
|
|
|
CURLOPT_TIMEOUT_MS => $this->timeout_ms,
|
|
|
|
|
CURLOPT_HTTPHEADER => [
|
|
|
|
|
'Content-Type: application/json',
|
|
|
|
|
'X-Worker-Secret: ' . $this->secret,
|
|
|
|
|
],
|
|
|
|
|
]);
|
|
|
|
|
curl_exec($ch);
|
|
|
|
|
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
|
|
|
$curl_err = curl_error($ch);
|
|
|
|
|
|
|
|
|
|
if ($curl_err !== '') {
|
|
|
|
|
log_message('error', 'Worker: POST ' . $path . ' failed: ' . $curl_err);
|
|
|
|
|
} elseif ($http_code !== 200) {
|
|
|
|
|
log_message('error', 'Worker: POST ' . $path . ' returned HTTP ' . $http_code);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|