hfs 0.52.0-beta4 → 0.52.0-beta6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +2 -3
  2. package/admin/assets/index-4CQRk-yB.css +1 -0
  3. package/admin/assets/index-sqjqhfQh.js +810 -0
  4. package/admin/assets/{sha512-3tDoWWX4.js → sha512-t1dU12Dj.js} +1 -1
  5. package/admin/index.html +2 -2
  6. package/frontend/assets/index-fqsRmx7w.css +1 -0
  7. package/frontend/assets/index-w_Bu3TcZ.js +101 -0
  8. package/frontend/assets/{sha512-I2H28VIm.js → sha512-U8GKU-vd.js} +1 -1
  9. package/frontend/index.html +2 -3
  10. package/package.json +3 -3
  11. package/src/acme.js +29 -12
  12. package/src/adminApis.js +3 -3
  13. package/src/api.get_file_list.js +2 -1
  14. package/src/api.monitor.js +3 -1
  15. package/src/api.net.js +3 -1
  16. package/src/api.vfs.js +6 -1
  17. package/src/apiMiddleware.js +1 -1
  18. package/src/block.js +1 -1
  19. package/src/connections.js +3 -1
  20. package/src/const.js +2 -2
  21. package/src/cross.js +16 -4
  22. package/src/geo.js +1 -1
  23. package/src/index.js +1 -1
  24. package/src/langs/hfs-lang-fi.json +37 -5
  25. package/src/langs/hfs-lang-it.json +6 -2
  26. package/src/langs/hfs-lang-nl.json +20 -3
  27. package/src/langs/hfs-lang-ru.json +21 -3
  28. package/src/langs/hfs-lang-vi.json +68 -22
  29. package/src/langs/hfs-lang-zh.json +13 -5
  30. package/src/listen.js +4 -3
  31. package/src/log.js +11 -2
  32. package/src/middlewares.js +2 -2
  33. package/src/misc.js +2 -1
  34. package/src/roots.js +1 -1
  35. package/src/selfCheck.js +4 -5
  36. package/src/serveGuiAndSharedFiles.js +6 -6
  37. package/src/serveGuiFiles.js +56 -43
  38. package/src/update.js +5 -4
  39. package/src/upload.js +5 -4
  40. package/src/util-files.js +1 -1
  41. package/src/util-os.js +53 -15
  42. package/src/vfs.js +9 -5
  43. package/admin/assets/index-gtPWo_px.js +0 -809
  44. package/admin/assets/index-oSvCg3xb.css +0 -1
  45. package/frontend/assets/index-Kys6yJtN.css +0 -1
  46. package/frontend/assets/index-SY22o0dA.js +0 -101
  47. package/plugins/download-counter/storage/counters.yaml +0 -663
@@ -1,4 +1,4 @@
1
- import{g as OF,c as UF}from"./index-SY22o0dA.js";function gF(sF,hF){for(var eF=0;eF<hF.length;eF++){const tF=hF[eF];if(typeof tF!="string"&&!Array.isArray(tF)){for(const w in tF)if(w!=="default"&&!(w in sF)){const lF=Object.getOwnPropertyDescriptor(tF,w);lF&&Object.defineProperty(sF,w,lF.get?lF:{enumerable:!0,get:()=>tF[w]})}}}return Object.freeze(Object.defineProperty(sF,Symbol.toStringTag,{value:"Module"}))}var dF={exports:{}};/*
1
+ import{g as OF,c as UF}from"./index-w_Bu3TcZ.js";function gF(sF,hF){for(var eF=0;eF<hF.length;eF++){const tF=hF[eF];if(typeof tF!="string"&&!Array.isArray(tF)){for(const w in tF)if(w!=="default"&&!(w in sF)){const lF=Object.getOwnPropertyDescriptor(tF,w);lF&&Object.defineProperty(sF,w,lF.get?lF:{enumerable:!0,get:()=>tF[w]})}}}return Object.freeze(Object.defineProperty(sF,Symbol.toStringTag,{value:"Module"}))}var dF={exports:{}};/*
2
2
  * [js-sha512]{@link https://github.com/emn178/js-sha512}
3
3
  *
4
4
  * @version 0.8.0
@@ -4,9 +4,8 @@
4
4
  <meta charset="utf-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=0" />
6
6
  <link href="/fontello.css" rel="stylesheet" />
7
- <script src="//polyfill.io/v3/polyfill.min.js?features=es2022%2Ces2021%2Ces2020%2Ces2019%2Ces2018%2Ces2017"></script>
8
- <script type="module" crossorigin src="/assets/index-SY22o0dA.js"></script>
9
- <link rel="stylesheet" crossorigin href="/assets/index-Kys6yJtN.css">
7
+ <script type="module" crossorigin src="/assets/index-w_Bu3TcZ.js"></script>
8
+ <link rel="stylesheet" crossorigin href="/assets/index-fqsRmx7w.css">
10
9
  </head>
11
10
  <body>
12
11
  <noscript>You need to enable JavaScript to run this app.</noscript>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hfs",
3
- "version": "0.52.0-beta4",
3
+ "version": "0.52.0-beta6",
4
4
  "description": "HTTP File Server",
5
5
  "keywords": [
6
6
  "file server",
@@ -15,8 +15,8 @@
15
15
  "watch-server-proxied": "cross-env FRONTEND_PROXY=3005 ADMIN_PROXY=3006 npm run watch-server",
16
16
  "start-frontend": "npm run start --workspace=frontend",
17
17
  "start-admin": "npm run start --workspace=admin",
18
- "build-all": "npm audit --omit=dev --audit-level=moderate && rm -rf dist && npm i && npm run build-server & npm run build-frontend & npm run build-admin & wait && echo COMPLETED",
19
- "build-server": "rm -rf dist/src dist/plugins && tsc --target es2018 && touch package.json && cp -v -r package.json central.json README* LICENSE* plugins dist && find dist -name .DS_Store -delete && node afterbuild.js",
18
+ "build-all": "npm audit --omit=dev --audit-level=moderate && rm -rf dist && npm i && npm run build-server && npm run build-frontend && npm run build-admin && echo COMPLETED",
19
+ "build-server": "rm -rf dist/src dist/plugins && tsc --target es2018 && touch package.json && cp -v -r package.json central.json README* LICENSE* plugins dist && find dist \\( -name .DS_Store -o -name storage \\) -delete && node afterbuild.js",
20
20
  "build-frontend": "npm run build --workspace=frontend",
21
21
  "build-admin": "npm run build --workspace=admin",
22
22
  "server-for-test": "node dist/src --cwd . --config tests && rm custom.html",
package/src/acme.js CHANGED
@@ -21,7 +21,7 @@ const acmeListener = (req, res) => {
21
21
  var _a;
22
22
  const BASE = '/.well-known/acme-challenge/';
23
23
  if (!((_a = req.url) === null || _a === void 0 ? void 0 : _a.startsWith(BASE)))
24
- return res.end('HFS'); // to satisfy self-check with the temporary server
24
+ return;
25
25
  const token = req.url.slice(BASE.length);
26
26
  console.debug("got http challenge", token);
27
27
  res.statusCode = cross_1.HTTP_OK;
@@ -33,6 +33,18 @@ const acmeMiddleware = (ctx, next) => {
33
33
  return next();
34
34
  };
35
35
  exports.acmeMiddleware = acmeMiddleware;
36
+ const TEMP_MAP = { private: 80, public: { host: '', port: 80 }, description: 'hfs temporary', ttl: 5000 }; // from my tests (zyxel VMG8825), lower values won't make a working mapping
37
+ (0, cross_1.repeat)(cross_1.MINUTE, async (stop) => {
38
+ await nat_1.upnpClient.getGateway(); // without this, the next call will break upnp support
39
+ const res = await nat_1.upnpClient.getMappings();
40
+ const leftover = res.find(x => x.description === TEMP_MAP.description); // in case the process is interrupted
41
+ if (!leftover)
42
+ return void (stop()); // we are good
43
+ if (acmeMiddlewareEnabled)
44
+ return; // it doesn't count, as we are in the middle of something. Retry later
45
+ stop();
46
+ return nat_1.upnpClient.removeMapping(TEMP_MAP);
47
+ });
36
48
  async function generateSSLCert(domain, email, altNames) {
37
49
  // will answer challenge through our koa app (if on port 80) or must we spawn a dedicated server?
38
50
  const nat = await (0, nat_1.getNatInfo)();
@@ -44,18 +56,18 @@ async function generateSSLCert(domain, email, altNames) {
44
56
  resolve(); // go on anyway
45
57
  }));
46
58
  acmeMiddlewareEnabled = true;
47
- console.debug('acme challenge server ready');
59
+ console.debug("acme challenge server ready");
48
60
  let tempMap;
49
61
  try {
50
- const checkUrl = `http://${domain}`;
62
+ const checkUrl = `http://${domain.split(',')[0]}`;
51
63
  let check = await (0, selfCheck_1.selfCheck)(checkUrl); // some check services may not consider the domain, but we already verified that
52
- if (check && !check.success && nat.upnp && !nat.mapped80) {
64
+ if ((check === null || check === void 0 ? void 0 : check.success) === false && nat.upnp && !nat.mapped80) {
53
65
  console.debug("setting temporary port forward");
54
- tempMap = await nat_1.upnpClient.createMapping({ private: 80, public: { host: '', port: 80 }, description: 'hfs temporary', ttl: 0 }).catch(() => { });
66
+ tempMap = await (0, cross_1.haveTimeout)(10000, nat_1.upnpClient.createMapping(TEMP_MAP).catch(() => { })).catch(() => { });
55
67
  check = await (0, selfCheck_1.selfCheck)(checkUrl); // repeat test
56
68
  }
57
69
  //if (!check) throw new ApiError(HTTP_FAILED_DEPENDENCY, "couldn't test port 80")
58
- if (!(check === null || check === void 0 ? void 0 : check.success))
70
+ if ((check === null || check === void 0 ? void 0 : check.success) === false)
59
71
  throw new apiMiddleware_1.ApiError(cross_1.HTTP_FAILED_DEPENDENCY, "port 80 is not working on the specified domain");
60
72
  const acmeClient = new acme_client_1.default.Client({
61
73
  accountKey: await acme_client_1.default.crypto.createPrivateKey(),
@@ -72,12 +84,13 @@ async function generateSSLCert(domain, email, altNames) {
72
84
  async challengeCreateFn(_, c, ka) { acmeTokens[c.token] = ka; },
73
85
  async challengeRemoveFn(_, c) { delete acmeTokens[c.token]; },
74
86
  });
87
+ console.log("acme certificate generated");
75
88
  return { key, cert };
76
89
  }
77
90
  finally {
78
91
  if (tempMap) {
79
92
  console.debug("removing temporary port forward");
80
- nat_1.upnpClient.removeMapping({ public: { host: '', port: 80 } }).catch(() => { });
93
+ nat_1.upnpClient.removeMapping(TEMP_MAP).catch(() => { }); // clean after ourselves
81
94
  }
82
95
  acmeMiddlewareEnabled = false;
83
96
  if (tempSrv)
@@ -88,8 +101,12 @@ async function generateSSLCert(domain, email, altNames) {
88
101
  exports.makeCert = (0, debounceAsync_1.debounceAsync)(async (domain, email, altNames) => {
89
102
  if (!domain)
90
103
  return new apiMiddleware_1.ApiError(cross_1.HTTP_BAD_REQUEST, 'bad params');
91
- const res = await generateSSLCert(domain, email, altNames);
92
- const CERT_FILE = 'acme.cert';
104
+ const res = await generateSSLCert(domain, email, altNames).catch(e => {
105
+ var _a;
106
+ throw !((_a = e.message) === null || _a === void 0 ? void 0 : _a.includes('not match this challenge')) ? e // another acme server?
107
+ : Error("a different server is responding on port 80 of your domain(s)");
108
+ });
109
+ const CERT_FILE = 'acme.cer';
93
110
  const KEY_FILE = 'acme.key';
94
111
  await promises_1.default.writeFile(CERT_FILE, res.cert);
95
112
  await promises_1.default.writeFile(KEY_FILE, res.key);
@@ -102,7 +119,7 @@ const acmeRenew = (0, config_1.defineConfig)('acme_renew', false); // handle con
102
119
  events_1.default.once('https ready', () => (0, cross_1.repeat)(cross_1.HOUR, renewCert));
103
120
  // checks if the cert is near expiration date, and if so renews it
104
121
  const renewCert = (0, debounceAsync_1.debounceAsync)(async () => {
105
- const domain = acmeDomain.get();
122
+ const [domain, ...altNames] = acmeDomain.get().split(',');
106
123
  if (!acmeRenew.get() || !domain)
107
124
  return;
108
125
  const cert = (0, listen_1.getCertObject)();
@@ -113,6 +130,6 @@ const renewCert = (0, debounceAsync_1.debounceAsync)(async () => {
113
130
  // not expiring in a month
114
131
  if (now > new Date(cert.validFrom) && now < validTo && validTo.getTime() - now.getTime() >= 30 * cross_1.DAY)
115
132
  return console.log("certificate still good");
116
- await (0, exports.makeCert)(domain, acmeEmail.get())
117
- .catch(e => console.log("error renewing certificate: ", String(e)));
133
+ await (0, exports.makeCert)(domain, acmeEmail.get(), altNames)
134
+ .catch(e => console.log("error renewing certificate: ", String(e.message || e)));
118
135
  }, 0, { retain: cross_1.DAY, retainFailure: cross_1.HOUR });
package/src/adminApis.js CHANGED
@@ -64,7 +64,7 @@ exports.adminApis = {
64
64
  };
65
65
  },
66
66
  set_config_text: ({ text }) => config_1.configFile.save(text, { reparse: true }),
67
- update: ({ tag }) => (0, update_1.update)(tag),
67
+ update: ({ tag }) => (0, update_1.update)(tag).catch(e => { var _a, _b; return ((_a = e.cause) === null || _a === void 0 ? void 0 : _a.statusCode) ? new apiMiddleware_1.ApiError((_b = e.cause) === null || _b === void 0 ? void 0 : _b.statusCode) : e; }),
68
68
  async check_update() {
69
69
  return { options: await (0, update_1.getUpdates)() };
70
70
  },
@@ -103,7 +103,7 @@ exports.adminApis = {
103
103
  ips: await (0, listen_1.getIps)(false),
104
104
  baseUrl: (0, listen_1.getBaseUrlOrDefault)(),
105
105
  roots: roots_1.roots.get(),
106
- updatePossible: !(0, update_1.updateSupported)() ? false : await (0, update_1.localUpdateAvailable)() ? 'local' : true,
106
+ updatePossible: !await (0, update_1.updateSupported)() ? false : (await (0, update_1.localUpdateAvailable)()) ? 'local' : true,
107
107
  proxyDetected: (0, middlewares_1.getProxyDetected)(),
108
108
  frpDetected: exports.localhostAdmin.get() && !(0, middlewares_1.getProxyDetected)()
109
109
  && (0, connections_1.getConnections)().every(misc_1.isLocalHost)
@@ -113,7 +113,7 @@ exports.adminApis = {
113
113
  async save_pem({ cert, private_key, name = 'self' }) {
114
114
  if (!cert || !private_key)
115
115
  return new apiMiddleware_1.ApiError(const_1.HTTP_BAD_REQUEST);
116
- const files = { cert: name + '.cert', private_key: name + '.key' };
116
+ const files = { cert: name + '.cer', private_key: name + '.key' };
117
117
  await (0, promises_1.writeFile)(files.private_key, private_key);
118
118
  await (0, promises_1.writeFile)(files.cert, cert);
119
119
  return files;
@@ -37,7 +37,8 @@ const get_file_list = async ({ uri = '/', offset, limit, search, c, onlyFolders,
37
37
  const can_archive = admin || (0, vfs_1.hasPermission)(node, 'can_archive', ctx);
38
38
  const can_comment = can_upload && (0, comments_1.areCommentsEnabled)();
39
39
  const can_overwrite = can_upload && (can_delete || !upload_1.dontOverwriteUploading.get());
40
- const props = { can_archive, can_upload, can_delete, can_overwrite, accept: node.accept, can_comment };
40
+ const comment = await (0, comments_1.getCommentFor)(node.source);
41
+ const props = { can_archive, can_upload, can_delete, can_overwrite, can_comment, comment, accept: node.accept };
41
42
  ctx.state.browsing = uri.replace(/\/{2,}/g, '/');
42
43
  (0, connections_1.updateConnectionForCtx)(ctx);
43
44
  if (!list)
@@ -81,12 +81,14 @@ exports.default = {
81
81
  },
82
82
  async *get_connection_stats() {
83
83
  while (1) {
84
+ const filtered = (0, connections_1.getConnections)().filter(x => !ignore(x));
84
85
  yield {
85
86
  outSpeed: throttler_1.totalOutSpeed,
86
87
  inSpeed: throttler_1.totalInSpeed,
87
88
  got: throttler_1.totalGot,
88
89
  sent: throttler_1.totalSent,
89
- connections: lodash_1.default.sumBy((0, connections_1.getConnections)(), x => ignore(x) ? 0 : 1),
90
+ connections: filtered.length,
91
+ ips: lodash_1.default.uniqBy(filtered, x => x.ip).length,
90
92
  };
91
93
  await (0, misc_1.wait)(1000);
92
94
  }
package/src/api.net.js CHANGED
@@ -75,7 +75,9 @@ const apis = {
75
75
  return results.length ? results : new apiMiddleware_1.ApiError(const_1.HTTP_SERVICE_UNAVAILABLE);
76
76
  },
77
77
  async make_cert({ domain, email, altNames }) {
78
- await (0, acme_1.makeCert)(domain, email, altNames);
78
+ await (0, acme_1.makeCert)(domain, email, altNames).catch(e => {
79
+ throw new apiMiddleware_1.ApiError(const_1.HTTP_SERVER_ERROR, e.message || String(e));
80
+ });
79
81
  return {};
80
82
  },
81
83
  get_cert() {
package/src/api.vfs.js CHANGED
@@ -170,6 +170,7 @@ const apis = {
170
170
  await (0, promises_1.mkdir)(path, { recursive: true });
171
171
  return {};
172
172
  },
173
+ get_disk_spaces: util_os_1.getDiskSpaces,
173
174
  get_ls({ path, files = true, fileMask }, ctx) {
174
175
  return new SendList_1.SendListReadable({
175
176
  async doAtStart(list) {
@@ -183,6 +184,10 @@ const apis = {
183
184
  }
184
185
  return;
185
186
  }
187
+ try {
188
+ list.props((0, util_os_1.getDiskSpaceSync)(path));
189
+ }
190
+ catch (_a) { } // continue anyway
186
191
  try {
187
192
  const matching = (0, misc_1.makeMatcher)(fileMask);
188
193
  path = (0, misc_1.isWindowsDrive)(path) ? path + '\\' : (0, path_1.resolve)(path || '/');
@@ -202,7 +207,7 @@ const apis = {
202
207
  k: isDir ? 'd' : undefined,
203
208
  });
204
209
  }
205
- catch (_a) { } // just ignore entries we can't stat
210
+ catch (_b) { } // just ignore entries we can't stat
206
211
  }
207
212
  list.close();
208
213
  }
@@ -52,7 +52,7 @@ function apiMiddleware(apis) {
52
52
  }
53
53
  catch (e) {
54
54
  if (typeof e === 'number')
55
- e = new ApiError(const_1.HTTP_NOT_FOUND);
55
+ e = new ApiError(e);
56
56
  res = e;
57
57
  }
58
58
  if (isAsyncGenerator(res))
package/src/block.js CHANGED
@@ -19,7 +19,7 @@ const block = (0, config_1.defineConfig)('block', [], rules => {
19
19
  });
20
20
  function applyBlock(socket, ip = (0, connections_1.normalizeIp)(socket.remoteAddress || '')) {
21
21
  if (ip && block.compiled().find(rule => rule(ip)))
22
- return (0, connections_1.disconnect)(socket);
22
+ return (0, connections_1.disconnect)(socket, 'block-ip');
23
23
  }
24
24
  exports.applyBlock = applyBlock;
25
25
  setInterval(() => {
@@ -68,9 +68,11 @@ function updateConnection(conn, change, changeState) {
68
68
  events_1.default.emit('connectionUpdated', conn, change);
69
69
  }
70
70
  exports.updateConnection = updateConnection;
71
- function disconnect(what) {
71
+ function disconnect(what, debugLog = '') {
72
72
  if ('socket' in what)
73
73
  what = what.socket;
74
+ if (debugLog)
75
+ console.debug("disconnection:", debugLog, what.remoteAddress);
74
76
  return what.destroy();
75
77
  }
76
78
  exports.disconnect = disconnect;
package/src/const.js CHANGED
@@ -37,7 +37,7 @@ const os_1 = require("os");
37
37
  const fs_1 = require("fs");
38
38
  const path_1 = require("path");
39
39
  __exportStar(require("./cross-const"), exports);
40
- exports.API_VERSION = 8.65;
40
+ exports.API_VERSION = 8.71;
41
41
  exports.COMPATIBLE_API_VERSION = 1; // while changes in the api are not breaking, this number stays the same, otherwise it is made equal to API_VERSION
42
42
  exports.HFS_REPO = 'rejetto/hfs';
43
43
  exports.argv = (0, minimist_1.default)(process.argv.slice(2));
@@ -45,7 +45,7 @@ exports.DEV = process.env.DEV || exports.argv.dev ? 'DEV' : '';
45
45
  exports.ORIGINAL_CWD = process.cwd();
46
46
  exports.HFS_STARTED = new Date();
47
47
  const PKG_PATH = (0, path_1.join)(__dirname, '..', 'package.json');
48
- exports.BUILD_TIMESTAMP = "2024-02-11T10:59:36.071Z";
48
+ exports.BUILD_TIMESTAMP = "2024-03-24T16:21:00.359Z";
49
49
  const pkg = JSON.parse(fs.readFileSync(PKG_PATH, 'utf8'));
50
50
  exports.VERSION = pkg.version;
51
51
  exports.RUNNING_BETA = exports.VERSION.includes('-');
package/src/cross.js CHANGED
@@ -18,7 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.typedEntries = exports.typedKeys = exports.objRenameKey = exports.randomId = exports.getOrSet = exports.waitFor = exports.newObj = exports.findDefined = exports.isOrderedEqual = exports.swap = exports.tryJson = exports.dirname = exports.basename = exports.pendingPromise = exports._dbg = exports._log = exports.wantArray = exports.formatPerc = exports.with_ = exports.try_ = exports.setHidden = exports.onlyTruthy = exports.truthy = exports.splitAt = exports.strinsert = exports.removeStarting = exports.enforceFinal = exports.objSameKeys = exports.haveTimeout = exports.wait = exports.prefix = exports.formatSpeed = exports.formatBytes = exports.isWhoObject = exports.PERM_KEYS = exports.defaultPerms = exports.WHO_ANY_ACCOUNT = exports.WHO_NO_ONE = exports.WHO_ANYONE = exports.LIST = exports.CFG = exports.THEME_OPTIONS = exports.SORT_BY_OPTIONS = exports.FRONTEND_OPTIONS = exports.MAX_TILE_SIZE = exports.DAY = exports.HOUR = exports.MINUTE = exports.WIKI_URL = exports.REPO_URL = void 0;
21
- exports.shortenAgent = exports.inCommon = exports.replace = exports.matches = exports.makeMatcher = exports.runAt = exports.pathEncode = exports.promiseBestEffort = exports.escapeHTML = exports.ipForUrl = exports.isIpLan = exports.isIpLocalHost = exports.xlate = exports.isEqualLax = exports.isWindowsDrive = exports.isIP = exports.isPrimitive = exports.formatTimestamp = exports.repeat = exports.asyncGeneratorToArray = exports.filterMapGenerator = exports.throw_ = exports.hasProp = void 0;
21
+ exports.shortenAgent = exports.mapFilter = exports.inCommon = exports.replace = exports.matches = exports.makeMatcher = exports.runAt = exports.pathEncode = exports.promiseBestEffort = exports.escapeHTML = exports.ipForUrl = exports.isIpLan = exports.isIpLocalHost = exports.xlate = exports.isEqualLax = exports.isWindowsDrive = exports.isIP = exports.isPrimitive = exports.formatTimestamp = exports.repeat = exports.asyncGeneratorToArray = exports.filterMapGenerator = exports.throw_ = exports.hasProp = void 0;
22
22
  // This file is part of HFS - Copyright 2021-2023, Massimo Melina <a@rejetto.com> - License https://www.gnu.org/licenses/gpl-3.0.txt
23
23
  // all content here is shared between client and server
24
24
  const lodash_1 = __importDefault(require("lodash"));
@@ -82,7 +82,7 @@ function formatSpeed(n, options = {}) {
82
82
  }
83
83
  exports.formatSpeed = formatSpeed;
84
84
  function prefix(pre, v, post = '') {
85
- return v ? pre + v + post : '';
85
+ return v ? (pre || '') + v + (post || '') : '';
86
86
  }
87
87
  exports.prefix = prefix;
88
88
  function wait(ms, val) {
@@ -305,10 +305,13 @@ exports.asyncGeneratorToArray = asyncGeneratorToArray;
305
305
  function repeat(everyMs, cb) {
306
306
  let stop = false;
307
307
  setTimeout(async () => {
308
- while (!stop && await Promise.allSettled([cb()]))
308
+ while (!stop && await Promise.allSettled([cb(stopIt)]))
309
309
  await wait(everyMs);
310
310
  });
311
- return () => stop = true;
311
+ return stopIt;
312
+ function stopIt() {
313
+ stop = true;
314
+ }
312
315
  }
313
316
  exports.repeat = repeat;
314
317
  function formatTimestamp(x) {
@@ -413,6 +416,15 @@ function inCommon(a, b) {
413
416
  return i;
414
417
  }
415
418
  exports.inCommon = inCommon;
419
+ function mapFilter(arr, map, filter = (x) => x === undefined, invert = false) {
420
+ return arr[invert ? 'reduceRight' : 'reduce']((ret, x, idx) => {
421
+ const y = map(x, idx);
422
+ if (filter(y))
423
+ ret.push(y); // push is much faster than unshift, therefore invert using reduceRight https://measurethat.net/Benchmarks/Show/29/0/array-push-vs-unshift
424
+ return ret;
425
+ }, []);
426
+ }
427
+ exports.mapFilter = mapFilter;
416
428
  function shortenAgent(agent) {
417
429
  var _a;
418
430
  return lodash_1.default.findKey(BROWSERS, re => re.test(agent))
package/src/geo.js CHANGED
@@ -27,7 +27,7 @@ const geoFilter = async (ctx, next) => {
27
27
  (0, connections_1.updateConnection)(connection, { country });
28
28
  if (!ctx.state.skipFilters && allow.get() !== null)
29
29
  if (country ? list.get().includes(country) !== allow.get() : !allowUnknown.get())
30
- return (0, connections_1.disconnect)(ctx);
30
+ return (0, connections_1.disconnect)(ctx, 'geo-filter');
31
31
  }
32
32
  await next();
33
33
  };
package/src/index.js CHANGED
@@ -38,8 +38,8 @@ const keys = ((_a = process.env.COOKIE_SIGN_KEYS) === null || _a === void 0 ? vo
38
38
  exports.app = new koa_1.default({ keys });
39
39
  exports.app.use(middlewares_1.sessionMiddleware)
40
40
  .use(selfCheck_1.selfCheckMiddleware)
41
- .use(middlewares_1.someSecurity)
42
41
  .use(acme_1.acmeMiddleware)
42
+ .use(middlewares_1.someSecurity)
43
43
  .use(middlewares_1.prepareState)
44
44
  .use(geo_1.geoFilter)
45
45
  .use(middlewares_1.gzipper)
@@ -1,7 +1,7 @@
1
1
  {
2
- "author": "Pultsari",
3
- "version": 1.0,
4
- "hfs_version": "0.47.0",
2
+ "author": "Pultsari & Win_7",
3
+ "version": 1.2,
4
+ "hfs_version": "0.52.0",
5
5
  "translate": {
6
6
  "Select": "Valitse",
7
7
  "n_files": "{n,plural,one{# tiedosto} other{# tiedostoa}}",
@@ -100,7 +100,7 @@
100
100
  "Name": "Nimi",
101
101
  "file_open": "Avaa",
102
102
  "Download": "Lataa",
103
- "Missing permission": "Oikeudet puuuttuvat",
103
+ "Missing permission": "Oikeudet puuttuvat",
104
104
  "Reload": "Päivitä",
105
105
  "Get list": "Näytä listana",
106
106
  "Skip existing files": "Ohita jo olemassa olevat tiedostot",
@@ -126,6 +126,38 @@
126
126
  "showHelp_space_body": "valitse",
127
127
  "showHelp_D_body": "lataa",
128
128
  "showHelp_Z_body": "vaihda zoomauksen tilaa",
129
- "showHelp_F_body": "koko näyttö"
129
+ "showHelp_F_body": "koko näyttö",
130
+ "Destination": "Kohde",
131
+ "in_queue": "{n} jonossa",
132
+ "enter_comment": "Kirjoita kommentti tälle tiedostolle / hakemistolle",
133
+ "Comment": "Kommentti",
134
+ "upload_dd_hint": "Voit lähettää tiedostoja raahaamalla niitä tiedostolistauksessa",
135
+ "Upload not available": "Lähettäminen ei ole mahdollista",
136
+ "Cut": "Leikkaa",
137
+ "n_items": "{n,plural, one{# tiedosto / hakemisto leikepöydällä} other{# tiedostoa / hakemistoa leikepöydällä}}",
138
+ "good_bad": "{good} siirretty, {bad} epäonnistui",
139
+ "after_cut": "Valintasi on nyt leikepöydällä.\nMene kohdekansioon liittääksesi.",
140
+ "Cancel clipboard": "Sulje leikepöytä",
141
+ "to_clipboard_source": "Takaisin lähdekansioon",
142
+ "Paste": "Liitä",
143
+ "clipboard_list": "Kohteet leikepöydällä:",
144
+ "Close": "Sulje",
145
+ "Folder": "Kansio",
146
+ "Web page": "Verkko sivu",
147
+ "Link": "Linkki",
148
+ "Auto-play": "Auto-toisto",
149
+ "autoplay_seconds": "Sekunteja odottaa kuvissa",
150
+ "Select all": "Valitse kaikki",
151
+ "go_first": "Mene ensimmäiseen kohteeseen",
152
+ "go_last": "Mene viimeiseen kohteeseen",
153
+ "Shuffle": "Sekoita",
154
+ "Repeat": "Toisto",
155
+ "showHelpListShortcut": "Tiedosto listalta, klikkaa kun painat {key} Näyttääksesi nopeasti",
156
+ "Invalid value": "Virheellinen arvo",
157
+ "upload_skipped": "{n} ohitettu",
158
+ "Overwrite policy": "Ylikirjoitus käytäntö",
159
+ "Rename to avoid overwriting": "Uudelleen nimeä jotta ei ylikirjoiteta",
160
+ "Overwrite existing files": "Ylikirjoita olemassa olevat tiedostot",
161
+ "Menu": "Valikko"
130
162
  }
131
163
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Massimo Melina",
3
3
  "version": 1.9,
4
- "hfs_version": "0.51.0",
4
+ "hfs_version": "0.52.0",
5
5
  "translate": {
6
6
  "Select": "Seleziona",
7
7
  "n_files": "{n} file",
@@ -141,6 +141,10 @@
141
141
  "Shuffle": "Riproduzione casuale",
142
142
  "Repeat": "Ripeti a fine lista",
143
143
  "showHelpListShortcut": "Dalla lista dei file, clicca tenendo {key} per accedere velocemente al File Show",
144
- "Invalid value": "Valore non valido"
144
+ "Invalid value": "Valore non valido",
145
+ "upload_skipped": "{n,plural, one{# saltato} other{# saltati}}",
146
+ "Overwrite policy": "Per i file esistenti",
147
+ "Rename to avoid overwriting": "Rinomina per non sovrascrivere",
148
+ "Overwrite existing files": "Sovrascrivi i file esistenti"
145
149
  }
146
150
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "H.F.P. Pit - PH5HP",
3
- "version": 1.1,
4
- "hfs_version": "0.50.0",
3
+ "version": 1.2,
4
+ "hfs_version": "0.52.0",
5
5
  "translate": {
6
6
  "Select": "Selecteer",
7
7
  "n_files": "{n,plural,one{# bestand} other{# bestanden}}",
@@ -122,6 +122,23 @@
122
122
  "Cancel clipboard": "Cancel clipboard",
123
123
  "to_clipboard_source": "Naar map",
124
124
  "Paste": "Plakken",
125
- "clipboard_list": "Items in het klembord:"
125
+ "clipboard_list": "Items in het klembord:",
126
+ "Close": "Sluit",
127
+ "Folder": "Map",
128
+ "Web page": "Web pagina",
129
+ "Link": "Link",
130
+ "Auto-play": "Automatisch afspelen",
131
+ "autoplay_seconds": "Secondes tussen het afspelen van afbeeldingen",
132
+ "Select all": "Selecteer alles",
133
+ "go_first": "Ga naar het 1e item",
134
+ "go_last": "Ga naar het laatste item",
135
+ "Shuffle": "Mix door elkaar",
136
+ "Repeat": "Herhaal",
137
+ "showHelpListShortcut": "In de bestanden lijst, klik de bestandsnaam aan met de {key} ingedrukt om het snel te tonen",
138
+ "Invalid value": "Foutieve waarde",
139
+ "upload_skipped": "{n} overgeslagen",
140
+ "Overwrite policy": "Overschrijf beleid",
141
+ "Rename to avoid overwriting": "Hernoem om overschrijven te vermijden",
142
+ "Overwrite existing files": "Overschrijf bestaande bestanden"
126
143
  }
127
144
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Mefistofell, SanokKule",
3
- "version": 2.4,
4
- "hfs_version": "0.51.0",
3
+ "version": 2.5,
4
+ "hfs_version": "0.52.0",
5
5
  "translate": {
6
6
  "Select": "Выбор",
7
7
  "n_files": "{n,plural, one{# файл} few{# файла} many{# файлов}}",
@@ -81,7 +81,7 @@
81
81
  "parent folder": "Родительская папка",
82
82
  "home": "Домашняя папка",
83
83
  "Continue": "Продолжить",
84
- "Confirm": "Да",
84
+ "Confirm": "Подтвердить",
85
85
  "Don't": "Нет",
86
86
  "Warning": "Внимание",
87
87
  "Error": "Ошибка",
@@ -141,6 +141,24 @@
141
141
  "to_clipboard_source": "В папку",
142
142
  "Paste": "Вставить",
143
143
  "clipboard_list": "Элементы в буфере обмена:",
144
+ "Close": "Закрыть",
145
+ "Folder": "Папка",
146
+ "Web page": "Веб адрес",
147
+ "Link": "Ссылка",
148
+ "Auto-play": "Автовоспроизведение",
149
+ "autoplay_seconds": "Сколько секунд ждать между изображениями",
150
+ "Select all": "Выбрать всё",
151
+ "go_first": "К первому элементу",
152
+ "go_last": "К последнему элементу",
153
+ "Shuffle": "Перемешать",
154
+ "Repeat": "Повтор",
155
+ "showHelpListShortcut": "Из списка файлов нажмите {key} чтобы быстро открыть Просмотр файла",
156
+ "Invalid value": "Недействительное значение",
157
+ "upload_skipped": "{n,plural, one{# пропущен} other{# пропущено}}",
158
+ "Overwrite policy": "Правило перезаписи",
159
+ "Rename to avoid overwriting": "Переименовать для избежания перезаписи",
160
+ "Overwrite existing files": "Перезаписать существующие файлы",
161
+ "Menu": "Меню",
144
162
  "_PLUGINS SECTION": "",
145
163
  "_PLUGIN thumbnails": "",
146
164
  "Enable tiles mode": "Просмотр в режиме плиток",