From cf559ee43ff30a1996965f944103afefaec70102 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 1 Oct 2024 22:28:01 +0100 Subject: [PATCH 1/3] smp server: fix notifiers lost when compacting store log (#1347) --- src/Simplex/FileTransfer/Server/Store.hs | 1 + src/Simplex/FileTransfer/Server/StoreLog.hs | 1 + src/Simplex/Messaging/Notifications/Server/StoreLog.hs | 3 +++ src/Simplex/Messaging/Server/StoreLog.hs | 4 +++- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Simplex/FileTransfer/Server/Store.hs b/src/Simplex/FileTransfer/Server/Store.hs index 10c34819f..46513ea96 100644 --- a/src/Simplex/FileTransfer/Server/Store.hs +++ b/src/Simplex/FileTransfer/Server/Store.hs @@ -54,6 +54,7 @@ fileTimePrecision :: Int64 fileTimePrecision = 3600 -- truncate creation time to 1 hour data FileRecipient = FileRecipient RecipientId RcvPublicAuthKey + deriving (Show) instance StrEncoding FileRecipient where strEncode (FileRecipient rId rKey) = strEncode rId <> ":" <> strEncode rKey diff --git a/src/Simplex/FileTransfer/Server/StoreLog.hs b/src/Simplex/FileTransfer/Server/StoreLog.hs index 9d3919c2c..675e4efdb 100644 --- a/src/Simplex/FileTransfer/Server/StoreLog.hs +++ b/src/Simplex/FileTransfer/Server/StoreLog.hs @@ -44,6 +44,7 @@ data FileStoreLogRecord | AddRecipients SenderId (NonEmpty FileRecipient) | DeleteFile SenderId | AckFile RecipientId + deriving (Show) instance StrEncoding FileStoreLogRecord where strEncode = \case diff --git a/src/Simplex/Messaging/Notifications/Server/StoreLog.hs b/src/Simplex/Messaging/Notifications/Server/StoreLog.hs index d43700ad3..d11c01f76 100644 --- a/src/Simplex/Messaging/Notifications/Server/StoreLog.hs +++ b/src/Simplex/Messaging/Notifications/Server/StoreLog.hs @@ -50,6 +50,7 @@ data NtfStoreLogRecord | CreateSubscription NtfSubRec | SubscriptionStatus NtfSubscriptionId NtfSubStatus | DeleteSubscription NtfSubscriptionId + deriving (Show) data NtfTknRec = NtfTknRec { ntfTknId :: NtfTokenId, @@ -61,6 +62,7 @@ data NtfTknRec = NtfTknRec tknRegCode :: NtfRegCode, tknCronInterval :: Word16 } + deriving (Show) mkTknData :: NtfTknRec -> STM NtfTknData mkTknData NtfTknRec {ntfTknId, token, tknStatus = status, tknVerifyKey, tknDhKeys, tknDhSecret, tknRegCode, tknCronInterval = cronInt} = do @@ -81,6 +83,7 @@ data NtfSubRec = NtfSubRec tokenId :: NtfTokenId, subStatus :: NtfSubStatus } + deriving (Show) mkSubData :: NtfSubRec -> STM NtfSubData mkSubData NtfSubRec {ntfSubId, smpQueue, notifierKey, tokenId, subStatus = status} = do diff --git a/src/Simplex/Messaging/Server/StoreLog.hs b/src/Simplex/Messaging/Server/StoreLog.hs index c47b06eb5..cfe2cd82e 100644 --- a/src/Simplex/Messaging/Server/StoreLog.hs +++ b/src/Simplex/Messaging/Server/StoreLog.hs @@ -55,6 +55,7 @@ data StoreLogRecord | DeleteQueue QueueId | DeleteNotifier QueueId | UpdateTime QueueId RoundedSystemTime + deriving (Show) data SLRTag = CreateQueue_ @@ -74,10 +75,11 @@ instance StrEncoding QueueRec where "sid=" <> strEncode senderId, "sk=" <> strEncode senderKey ] - <> if sndSecure then " sndSecure=" <> strEncode sndSecure else "" + <> sndSecureStr <> maybe "" notifierStr notifier <> maybe "" updatedAtStr updatedAt where + sndSecureStr = if sndSecure then " sndSecure=" <> strEncode sndSecure else "" notifierStr ntfCreds = " notifier=" <> strEncode ntfCreds updatedAtStr t = " updated_at=" <> strEncode t From 7488923fc3fb67d3c448ff4700f0a28d787bd2b0 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin Date: Wed, 2 Oct 2024 09:24:29 +0100 Subject: [PATCH 2/3] 6.0.6.0 --- package.yaml | 2 +- simplexmq.cabal | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.yaml b/package.yaml index 39054ec77..467a3221e 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: simplexmq -version: 6.0.5.0 +version: 6.0.6.0 synopsis: SimpleXMQ message broker description: | This package includes <./docs/Simplex-Messaging-Server.html server>, diff --git a/simplexmq.cabal b/simplexmq.cabal index 33743c8a4..0af4831ac 100644 --- a/simplexmq.cabal +++ b/simplexmq.cabal @@ -5,7 +5,7 @@ cabal-version: 1.12 -- see: https://github.com/sol/hpack name: simplexmq -version: 6.0.5.0 +version: 6.0.6.0 synopsis: SimpleXMQ message broker description: This package includes <./docs/Simplex-Messaging-Server.html server>, <./docs/Simplex-Messaging-Client.html client> and From 0e921d3258a0f210cc86f643a1599aa7151dcd14 Mon Sep 17 00:00:00 2001 From: sh <37271604+shumvgolove@users.noreply.github.com> Date: Fri, 4 Oct 2024 08:57:07 +0000 Subject: [PATCH 3/3] scripts: preparations for new deployments (#1357) * scripts/install: allow specifying version * scripts/update: allow specifying version * scripts/services: allow 443 for smp, allow infinite startup --- README.md | 11 +++++++-- install.sh | 38 ++++++++++++++++++----------- scripts/main/simplex-servers-update | 20 ++++++++++++--- scripts/main/smp-server.service | 2 ++ scripts/main/xftp-server.service | 1 + 5 files changed, 52 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index b43fe6920..b5cbca928 100644 --- a/README.md +++ b/README.md @@ -149,8 +149,15 @@ On Linux, you can deploy smp and xftp server using Docker. This will download im You can install and setup servers automatically using our script: ```sh -curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/simplex-chat/simplexmq/stable/install.sh -o simplex-server-install.sh \ -&& if echo 'c90886104cd640b2ed64921dba80e90691db36788e8d6dcc13d8f33f92f0ea54 simplex-server-install.sh' | sha256sum -c; then chmod +x ./simplex-server-install.sh && ./simplex-server-install.sh; rm ./simplex-server-install.sh; else echo "SHA-256 checksum is incorrect!" && rm ./simplex-server-install.sh; fi +curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/simplex-chat/simplexmq/stable/install.sh -o simplex-server-install.sh &&\ +if echo '53fcdb4ceab324316e2c4cda7e84dbbb344f32550a65975a7895425e5a1be757 simplex-server-install.sh' | sha256sum -c; then + chmod +x ./simplex-server-install.sh + ./simplex-server-install.sh + rm ./simplex-server-install.sh +else + echo "SHA-256 checksum is incorrect!" + rm ./simplex-server-install.sh +fi ``` ### Build from source diff --git a/install.sh b/install.sh index 461215f71..4974c8a3c 100755 --- a/install.sh +++ b/install.sh @@ -2,9 +2,6 @@ set -eu # Links to scripts/configs -bin="https://github.com/simplex-chat/simplexmq/releases/latest/download" -remote_version="$(curl --proto '=https' --tlsv1.2 -sSf -L https://api.github.com/repos/simplex-chat/simplexmq/releases/latest | grep -i "tag_name" | awk -F \" '{print $4}')" - scripts="https://raw.githubusercontent.com/simplex-chat/simplexmq/stable/scripts/main" scripts_systemd_smp="$scripts/smp-server.service" scripts_systemd_xftp="$scripts/xftp-server.service" @@ -57,7 +54,7 @@ ${GRN}1.${NC} Install latest binaries from GitHub releases: ${GRN}2.${NC} Create server directories: - smp: ${YLW}${path_conf_smp}${NC} - xftp: ${YLW}${path_conf_xftp}${NC} -${GRN}3.${NC} Setup user for each server: +${GRN}3.${NC} Setup user for server: - xmp: ${YLW}${user_smp}${NC} - xftp: ${YLW}${user_xftp}${NC} ${GRN}4.${NC} Create systemd services: @@ -67,9 +64,8 @@ ${GRN}5.${NC} Install stopscript (systemd), update and uninstallation script: - all: ${YLW}${path_bin_update}${NC}, ${YLW}${path_bin_uninstall}${NC}, ${YLW}${path_bin_stopscript}${NC} Press: - - ${GRN}ENTER${NC} to continue installing both xftp and smp servers - - ${GRN}1${NC} to install only smp server - - ${GRN}2${NC} to install only xftp server + - ${GRN}1${NC} to install smp server + - ${GRN}2${NC} to install xftp server - ${RED}Ctrl+C${NC} to cancel installation Selection: " @@ -83,6 +79,21 @@ Please checkout our server guides: To uninstall with full clean-up, simply run: ${YLW}sudo /usr/local/bin/simplex-servers-uninstall${NC} " +set_version() { + ver="${VER:-latest}" + + case "$ver" in + latest) + bin="https://github.com/simplex-chat/simplexmq/releases/latest/download" + remote_version="$(curl --proto '=https' --tlsv1.2 -sSf -L https://api.github.com/repos/simplex-chat/simplexmq/releases/latest | grep -i "tag_name" | awk -F \" '{print $4}')" + ;; + *) + bin="https://github.com/simplex-chat/simplexmq/releases/download/${ver}" + remote_version="${ver}" + ;; + esac +} + os_test() { . /etc/os-release @@ -155,6 +166,7 @@ checks() { exit 1 fi + set_version os_test mkdir -p $path_conf_info @@ -166,13 +178,11 @@ main() { printf "%b\n%b" "${BLU}$logo${NC}" "$welcome" read ans - if [ "$ans" = '1' ]; then - setup='smp' - elif [ "$ans" = '2' ]; then - setup='xftp' - else - setup='smp xftp' - fi + case "$ans" in + 1) setup='smp' ;; + 2) setup='xftp' ;; + *) printf 'Installation aborted.\n' && exit 0 ;; + esac printf "Installing binaries..." diff --git a/scripts/main/simplex-servers-update b/scripts/main/simplex-servers-update index 7e85ff777..dad3c25b9 100755 --- a/scripts/main/simplex-servers-update +++ b/scripts/main/simplex-servers-update @@ -2,8 +2,6 @@ set -eu # Links to scripts/configs -bin="https://github.com/simplex-chat/simplexmq/releases/latest/download" - scripts="https://raw.githubusercontent.com/simplex-chat/simplexmq/stable/scripts/main" scripts_systemd_smp="$scripts/smp-server.service" scripts_systemd_xftp="$scripts/xftp-server.service" @@ -76,6 +74,21 @@ installed_test() { set -u } +set_version() { + ver="${VER:-latest}" + + case "$ver" in + latest) + bin="https://github.com/simplex-chat/simplexmq/releases/latest/download" + remote_version="$(curl --proto '=https' --tlsv1.2 -sSf -L https://api.github.com/repos/simplex-chat/simplexmq/releases/latest | grep -i "tag_name" | awk -F \" '{print $4}')" + ;; + *) + bin="https://github.com/simplex-chat/simplexmq/releases/download/${ver}" + remote_version="${ver}" + ;; + esac +} + update_scripts() { curl --proto '=https' --tlsv1.2 -sSf -L "$scripts_update" -o "$path_tmp_bin_update" && chmod +x "$path_tmp_bin_update" curl --proto '=https' --tlsv1.2 -sSf -L "$scripts_uninstall" -o "$path_tmp_bin_uninstall" && chmod +x "$path_tmp_bin_uninstall" @@ -137,8 +150,6 @@ update_bins() { eval "bin=\$bin_${1}" eval "path_bin=\$path_bin_${1}" - remote_version="$(curl --proto '=https' --tlsv1.2 -sSf -L https://api.github.com/repos/simplex-chat/simplexmq/releases/latest | grep -i "tag_name" | awk -F \" '{print $4}')" - set_ver() { local_version='unset' sed -i -- "s/local_version_${1}=.*/local_version_${1}='${remote_version}'/" "$path_conf_info/release" @@ -192,6 +203,7 @@ checks() { exit 1 fi + set_version os_test installed_test diff --git a/scripts/main/smp-server.service b/scripts/main/smp-server.service index 3a845f1c6..6d365041d 100644 --- a/scripts/main/smp-server.service +++ b/scripts/main/smp-server.service @@ -9,7 +9,9 @@ ExecStart=/usr/local/bin/smp-server start +RTS -N -RTS ExecStopPost=/usr/local/bin/simplex-servers-stopscript smp-server LimitNOFILE=65535 KillSignal=SIGINT +TimeoutStartSec=infinity TimeoutStopSec=infinity +AmbientCapabilities=CAP_NET_BIND_SERVICE [Install] WantedBy=multi-user.target diff --git a/scripts/main/xftp-server.service b/scripts/main/xftp-server.service index 51c8b1cd9..fcde29bf8 100644 --- a/scripts/main/xftp-server.service +++ b/scripts/main/xftp-server.service @@ -9,6 +9,7 @@ ExecStart=/usr/local/bin/xftp-server start +RTS -N -RTS ExecStopPost=/usr/local/bin/simplex-servers-stopscript xftp-server LimitNOFILE=65535 KillSignal=SIGINT +TimeoutStartSec=infinity TimeoutStopSec=infinity AmbientCapabilities=CAP_NET_BIND_SERVICE