Compare commits

...

6 Commits

@ -2,15 +2,13 @@
self="$(basename "$0")"
files_daily=$((24*60/45))
# TODO: Increase these for compression ratio
# Values are low for test run
recent_file_limit=$((files_daily * 2))
recent_file_archive_size=$((files_daily))
recent_file_limit=$((files_daily * 56))
recent_file_archive_size=$((files_daily * 28))
archives_dir="cache-lt/archive/servers"
base_file_name="$archives_dir/recent/servers.json"
num_recent_files=$(/bin/ls -1 $base_file_name* 2>/dev/null | wc -l)
if [ "$num_recent_files" -ge "$recent_file_limit" ]; then
if [ "$num_recent_files" -ge "$recent_file_limit" ] || [ "$1" = "-f" ]; then
>&2 echo "$self: recent file limit reached, compressing"
/bin/ls -1tr $base_file_name* |
head -n "$recent_file_archive_size" |

@ -11,7 +11,7 @@
endscript
}
"cache-lt/archive/servers/servers.tar*" {
"cache-lt/archive/servers/servers.tar" {
rotate -1
missingok
compress

@ -1640,7 +1640,7 @@
$pubkey_old = $this->get_pubkey();
$pubkey_new = url_get_pubkey($link);
log_error(
"Key collision for $base_url:" .
"Key mismatch for $base_url:" .
"Have $pubkey_old, fetched $pubkey_new from $preview_url"
);
return false;

@ -49,7 +49,8 @@
private static function sdir_validate_entry(
array $room_entry,
bool &$missing_url,
bool &$missing_tags
bool &$missing_tags,
bool &$invalid_url
): bool {
if (!isset($room_entry['url']) || !is_string($room_entry['url'])) {
log_value($room_entry);
@ -63,10 +64,16 @@
return false;
}
if (!filter_var($room_entry['url'], FILTER_VALIDATE_URL)) {
log_value($room_entry);
$invalid_url = true;
return false;
}
return true;
}
private static function sdir_report_errors(bool $entry_missing_url, bool $entry_missing_tags) {
private static function sdir_report_errors(bool $entry_missing_url, bool $entry_missing_tags, bool $entry_invalid_url) {
if ($entry_missing_url) {
log_error("One or more room entries from session.directory is missing the 'url' parameter.");
}
@ -74,6 +81,10 @@
if ($entry_missing_tags) {
log_error("One or more room entries from session.directory is missing the 'tags' parameter.");
}
if ($entry_invalid_url) {
log_warning("One or more room entries from session.directory contain an invalid 'url' parameter.");
}
}
private function get_sdir_entries(): array|bool {
@ -87,6 +98,7 @@
private function sdir_process_tags(): bool {
$entry_missing_url = false;
$entry_missing_tags = false;
$entry_invalid_url = false;
$rooms = SDIRCommunitySource::get_sdir_entries();
@ -97,7 +109,7 @@
foreach ($rooms as $room_entry) {
if (!SDIRCommunitySource::sdir_validate_entry(
$room_entry, $entry_missing_url, $entry_missing_tags
$room_entry, $entry_missing_url, $entry_missing_tags, $entry_invalid_url
)) {
continue;
}
@ -116,7 +128,7 @@
}
}
SDIRCommunitySource::sdir_report_errors($entry_missing_url, $entry_missing_tags);
SDIRCommunitySource::sdir_report_errors($entry_missing_url, $entry_missing_tags, $entry_invalid_url);
return true;
}

@ -130,11 +130,16 @@
/**
* Extracts the server public key from a join URL.
* @param string $join_url Join URL for Session Community.
* @return string SOGS public key
* @return string|null SOGS public key
*/
function url_get_pubkey(string $join_url) {
$url_components = parse_url($join_url);
parse_str($url_components['query'], $query_components);
$query = $url_components['query'] ?? "";
if ($query === "") {
log_value($join_url);
throw new DomainException("Join URL does not contain public key");
}
parse_str($query, $query_components);
return $query_components['public_key'];
}

@ -17,12 +17,11 @@
return $id != "qr_code" && $id != "preview" && $id != "join_url";
}
function sort_onclick($colno) {
global $TABLE_COLUMNS;
$column = $TABLE_COLUMNS[$colno];
function sort_onclick($column) {
$name = isset($column['name_long']) ? $column['name_long'] : $column['name'];
if (!column_sortable($column['id'])) return " title='$name'";
return " title='Click to sort by $name.'";
if (!column_sortable($column['id'])) return "title='$name'";
$name = mb_strtolower($name);
return "title='Click to sort by $name.'";
}
// Note: Changing the names or columns displayed requires updating
@ -33,7 +32,7 @@
['id' => "name", 'name' => "Name"],
['id' => "description", 'name' => "About", 'name_long' => "Description"],
['id' => "users", 'name' => "#", 'name_long' => "Active Users"],
['id' => "preview", 'name' => "Preview"],
['id' => "preview", 'name' => "Preview", 'name_long' => "Preview (external link)"],
['id' => "qr_code", 'name' => "QR", 'name_long' => "QR Code (for use in-app)"],
['id' => "server_icon", 'name' => "Host", 'name_long' => "Server host"],
['id' => "join_url", 'name' => "URL", 'name_long' => "Join URL (for use in-app)"],
@ -42,8 +41,8 @@
<table id="tbl_communities">
<tr>
<?php foreach ($TABLE_COLUMNS as $colno => $column): ?>
<th<?=sort_onclick($colno)?> id="th_<?=$column['id']?>" class="tbl_communities__th">
<?php foreach ($TABLE_COLUMNS as $column): ?>
<th <?=sort_onclick($column)?> id="th_<?=$column['id']?>" class="tbl_communities__th">
<?=$column['name']?>
</th>

Loading…
Cancel
Save