void kr_zonecut_set(struct kr_zonecut *, const knot_dname_t *);
uint64_t kr_now();
const char *kr_strptime_diff(const char *, const char *, const char *, double *);
+time_t kr_file_mtime(const char *);
void lru_free_items_impl(struct lru *);
struct lru *lru_create_impl(unsigned int, unsigned int, knot_mm_t *, knot_mm_t *);
void *lru_get_impl(struct lru *, const char *, unsigned int, unsigned int, _Bool, _Bool *);
kr_zonecut_set
kr_now
kr_strptime_diff
+ kr_file_mtime
lru_free_items_impl
lru_create_impl
lru_get_impl
dns-root-data
lua-sec
lua-socket
-lua-filesystem
systemd
libc6
libdnssec7
'lua51-basexx: experimental_dot_auth module',
'lua51-cqueues: http and dns64 module, policy.rpz() function',
'lua51-http: http module',
- 'lua51-filesystem: prefill module',
'lua51-psl: policy.slice_randomize_psl() function',
)
makedepends=(
dns-root-data,
lua-sec,
lua-socket,
- lua-filesystem,
systemd,
${misc:Depends},
${shlibs:Depends},
Requires: lua-psl
Requires: lua-socket
Requires: lua-sec
-Requires: lua-filesystem
Requires(pre): shadow-utils
%endif
%if 0%{?fedora}
Requires: lua5.1-basexx
Requires: lua5.1-cqueues
Recommends: lua5.1-psl
-Requires: lua-filesystem-compat
Requires: lua-socket-compat
Requires: lua-sec-compat
Requires(pre): shadow-utils
%define NINJA ninja
BuildRequires: lmdb-devel
BuildRequires: python3-Sphinx
-Requires: lua51-luafilesystem
Requires: lua51-luasocket
Requires: lua51-luasec
Requires(pre): shadow
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
+#include <sys/stat.h>
#include <sys/un.h>
/* Always compile-in log symbols, even if disabled. */
return knot_rrsig_type_covered(rdata);
}
+time_t kr_file_mtime (const char* fname) {
+ struct stat fstat;
+
+ if (stat(fname, &fstat) != 0) {
+ return 0;
+ }
+
+ return fstat.st_mtime;
+}
+
KR_EXPORT uint32_t kr_rrsig_sig_inception(const knot_rdata_t *rdata);
KR_EXPORT uint32_t kr_rrsig_sig_expiration(const knot_rdata_t *rdata);
KR_EXPORT uint16_t kr_rrsig_type_covered(const knot_rdata_t *rdata);
+KR_EXPORT time_t kr_file_mtime (const char* fname);
Dependencies
^^^^^^^^^^^^
-Depends on the luasec_ and luafilesystem_ libraries.
+Depends on the luasec_ library.
.. _luasec: https://luarocks.org/modules/brunoos/luasec
-.. _luafilesystem: https://keplerproject.github.io/luafilesystem/
local https = require('ssl.https')
local ltn12 = require('ltn12')
-local lfs = require('lfs')
+local ffi = require('ffi')
local rz_url = "https://www.internic.net/domain/root.zone"
local rz_local_fname = "root.zone"
-- returns: number of seconds the file is valid for
-- 0 indicates immediate download
local function get_file_ttl(fname)
- local attrs = lfs.attributes(fname)
- if attrs then
- local age = os.time() - attrs.modification
+ local c_str = ffi.new("char[?]", #fname)
+ ffi.copy(c_str, fname)
+ local mtime = tonumber(ffi.C.kr_file_mtime(c_str))
+
+ if mtime > 0 then
+ local age = os.time() - mtime
return math.max(
rz_cur_interval - age,
0)