Software /
code /
prosody
File
util/session.lua @ 13633:6b84d11aa09b
mod_storage_sql: Detect SQLite3 without UPSERT (or SQLCipher 3.x)
SQLCipher v3.4.1 (the version in Debian 12) is based on SQLite3 v3.15.2,
while UPSERT support was introduced in SQLite3 v3.24.0
This check was not needed before because we v3.24.0 has not been in a
version of Debian we support for a long, long time.
Note however that SQLCipher databases are not compatible across major
versions, upgrading from v3.x to v4.x requires executing a migration.
Attempts at making `prosodyctl mod_storage_sql upgrade` perform such a
migration has not been successful.
Executing the following in the `sqlcipher` tool should do the migration:
PRAGMA key = '<key material>';
PRAGMA cipher_migrate;
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 23 Jan 2025 19:33:05 +0100 |
parent | 13165:9c13c11b199d |
line wrap: on
line source
local initialize_filters = require "prosody.util.filters".initialize; local time = require "prosody.util.time"; local logger = require "prosody.util.logger"; local function new_session(typ) local session = { type = typ .. "_unauthed"; base_type = typ; since = time.now(); }; return session; end local function set_id(session) local id = session.base_type .. tostring(session):match("%x+$"):lower(); session.id = id; return session; end local function set_logger(session) local log = logger.init(session.id); session.log = log; return session; end local function set_conn(session, conn) session.conn = conn; session.ip = conn:ip(); return session; end local function set_send(session) local conn = session.conn; if not conn then function session.send(data) session.log("debug", "Discarding data sent to unconnected session: %s", data); return false; end return session; end local filter = initialize_filters(session); local w = conn.write; session.send = function (t) if t.name then t = filter("stanzas/out", t); end if t then t = filter("bytes/out", tostring(t)); if t then local ret, err = w(conn, t); if not ret then session.log("debug", "Error writing to connection: %s", err); return false, err; end end end return true; end return session; end local function set_role(session, role) session.role = role; end return { new = new_session; set_id = set_id; set_logger = set_logger; set_conn = set_conn; set_send = set_send; set_role = set_role; }