Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
beacedab50 | ||
|
|
25139a4358 | ||
|
|
f8491970fd | ||
|
|
da091aec85 | ||
|
|
e9eb5affcd | ||
|
|
c1918bc36c | ||
|
|
fdda567f50 | ||
|
|
603d0ed72b | ||
|
|
b15a4ef79f | ||
|
|
48a6789d36 | ||
|
|
36f2c446af | ||
|
|
69517e4624 | ||
|
|
ea270ab9f2 | ||
|
|
b6cf2d3089 | ||
|
|
e8db3dd37f | ||
|
|
27485a4cb1 | ||
|
|
253a414443 | ||
|
|
f6e693f0f5 | ||
|
|
c5f7cfc355 | ||
|
|
bc2c1e427a | ||
|
|
95d9e693c6 | ||
|
|
70a3cf36d1 | ||
|
|
aa45fccf11 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -12,6 +12,7 @@ copyparty.egg-info/
|
||||
/dist/
|
||||
/py2/
|
||||
/sfx*
|
||||
/pyz/
|
||||
/unt/
|
||||
/log/
|
||||
|
||||
|
||||
54
README.md
54
README.md
@@ -47,6 +47,7 @@ turn almost any device into a file server with resumable uploads/downloads using
|
||||
* [audio equalizer](#audio-equalizer) - and [dynamic range compressor](https://en.wikipedia.org/wiki/Dynamic_range_compression)
|
||||
* [fix unreliable playback on android](#fix-unreliable-playback-on-android) - due to phone / app settings
|
||||
* [markdown viewer](#markdown-viewer) - and there are *two* editors
|
||||
* [markdown vars](#markdown-vars) - dynamic docs with serverside variable expansion
|
||||
* [other tricks](#other-tricks)
|
||||
* [searching](#searching) - search by size, date, path/name, mp3-tags, ...
|
||||
* [server config](#server-config) - using arguments or config files, or a mix of both
|
||||
@@ -60,6 +61,7 @@ turn almost any device into a file server with resumable uploads/downloads using
|
||||
* [tftp server](#tftp-server) - a TFTP server (read/write) can be started using `--tftp 3969`
|
||||
* [smb server](#smb-server) - unsafe, slow, not recommended for wan
|
||||
* [browser ux](#browser-ux) - tweaking the ui
|
||||
* [opengraph](#opengraph) - discord and social-media embeds
|
||||
* [file indexing](#file-indexing) - enables dedup and music search ++
|
||||
* [exclude-patterns](#exclude-patterns) - to save some time
|
||||
* [filesystem guards](#filesystem-guards) - avoid traversing into other filesystems
|
||||
@@ -108,8 +110,9 @@ turn almost any device into a file server with resumable uploads/downloads using
|
||||
* [dependencies](#dependencies) - mandatory deps
|
||||
* [optional dependencies](#optional-dependencies) - install these to enable bonus features
|
||||
* [optional gpl stuff](#optional-gpl-stuff)
|
||||
* [sfx](#sfx) - the self-contained "binary"
|
||||
* [sfx](#sfx) - the self-contained "binary" (recommended!)
|
||||
* [copyparty.exe](#copypartyexe) - download [copyparty.exe](https://github.com/9001/copyparty/releases/latest/download/copyparty.exe) (win8+) or [copyparty32.exe](https://github.com/9001/copyparty/releases/latest/download/copyparty32.exe) (win7+)
|
||||
* [zipapp](#zipapp) - another emergency alternative, [copyparty.pyz](https://github.com/9001/copyparty/releases/latest/download/copyparty.pyz)
|
||||
* [install on android](#install-on-android)
|
||||
* [reporting bugs](#reporting-bugs) - ideas for context to include, and where to submit them
|
||||
* [devnotes](#devnotes) - for build instructions etc, see [./docs/devnotes.md](./docs/devnotes.md)
|
||||
@@ -123,6 +126,7 @@ just run **[copyparty-sfx.py](https://github.com/9001/copyparty/releases/latest/
|
||||
* or if you cannot install python, you can use [copyparty.exe](#copypartyexe) instead
|
||||
* or install [on arch](#arch-package) ╱ [on NixOS](#nixos-module) ╱ [through nix](#nix-package)
|
||||
* or if you are on android, [install copyparty in termux](#install-on-android)
|
||||
* or if your computer is messed up and nothing else works, [try the pyz](#zipapp)
|
||||
* or if you prefer to [use docker](./scripts/docker/) 🐋 you can do that too
|
||||
* docker has all deps built-in, so skip this step:
|
||||
|
||||
@@ -234,9 +238,11 @@ also see [comparison to similar software](./docs/versus.md)
|
||||
* client support
|
||||
* ☑ [folder sync](#folder-sync)
|
||||
* ☑ [curl-friendly](https://user-images.githubusercontent.com/241032/215322619-ea5fd606-3654-40ad-94ee-2bc058647bb2.png)
|
||||
* ☑ [opengraph](#opengraph) (discord embeds)
|
||||
* markdown
|
||||
* ☑ [viewer](#markdown-viewer)
|
||||
* ☑ editor (sure why not)
|
||||
* ☑ [variables](#markdown-vars)
|
||||
|
||||
PS: something missing? post any crazy ideas you've got as a [feature request](https://github.com/9001/copyparty/issues/new?assignees=9001&labels=enhancement&template=feature_request.md) or [discussion](https://github.com/9001/copyparty/discussions/new?category=ideas) 🤙
|
||||
|
||||
@@ -614,9 +620,15 @@ cool trick: download a folder by appending url-params `?tar&opus` or `?tar&mp3`
|
||||
|
||||
## uploading
|
||||
|
||||
drag files/folders into the web-browser to upload (or use the [command-line uploader](https://github.com/9001/copyparty/tree/hovudstraum/bin#u2cpy))
|
||||
drag files/folders into the web-browser to upload
|
||||
|
||||
this initiates an upload using `up2k`; there are two uploaders available:
|
||||
dragdrop is the recommended way, but you may also:
|
||||
|
||||
* select some files (not folders) in your file explorer and press CTRL-V inside the browser window
|
||||
* use the [command-line uploader](https://github.com/9001/copyparty/tree/hovudstraum/bin#u2cpy)
|
||||
* upload using [curl or sharex](#client-examples)
|
||||
|
||||
when uploading files through dragdrop or CTRL-V, this initiates an upload using `up2k`; there are two browser-based uploaders available:
|
||||
* `[🎈] bup`, the basic uploader, supports almost every browser since netscape 4.0
|
||||
* `[🚀] up2k`, the good / fancy one
|
||||
|
||||
@@ -843,6 +855,13 @@ other notes,
|
||||
* the document preview has a max-width which is the same as an A4 paper when printed
|
||||
|
||||
|
||||
### markdown vars
|
||||
|
||||
dynamic docs with serverside variable expansion to replace stuff like `{{self.ip}}` with the client's IP, or `{{srv.htime}}` with the current time on the server
|
||||
|
||||
see [./srv/expand/](./srv/expand/) for usage and examples
|
||||
|
||||
|
||||
## other tricks
|
||||
|
||||
* you can link a particular timestamp in an audio file by adding it to the URL, such as `&20` / `&20s` / `&1m20` / `&t=1:20` after the `.../#af-c8960dab`
|
||||
@@ -1067,7 +1086,22 @@ tweaking the ui
|
||||
* to sort in music order (album, track, artist, title) with filename as fallback, you could `--sort tags/Cirle,tags/.tn,tags/Artist,tags/Title,href`
|
||||
* to sort by upload date, first enable showing the upload date in the listing with `-e2d -mte +.up_at` and then `--sort tags/.up_at`
|
||||
|
||||
see [./docs/rice](./docs/rice) for more
|
||||
see [./docs/rice](./docs/rice) for more, including how to add stuff (css/`<meta>`/...) to the html `<head>` tag
|
||||
|
||||
|
||||
## opengraph
|
||||
|
||||
discord and social-media embeds
|
||||
|
||||
can be enabled globally with `--og` or per-volume with volflag `og`
|
||||
|
||||
note that this disables hotlinking because the opengraph spec demands it; to sneak past this intentional limitation, you can enable opengraph selectively by user-agent, for example `--og-ua '(Discord|Twitter|Slack)bot'` (or volflag `og_ua`)
|
||||
|
||||
you can also hotlink files regardless by appending `?raw` to the url
|
||||
|
||||
NOTE: because discord (and maybe others) strip query args such as `?raw` in opengraph tags, any links which require a filekey or dirkey will not work
|
||||
|
||||
if you want to entirely replace the copyparty response with your own jinja2 template, give the template filepath to `--og-tpl` or volflag `og_tpl` (all members of `HttpCli` are available through the `this` object)
|
||||
|
||||
|
||||
## file indexing
|
||||
@@ -1981,7 +2015,7 @@ these are standalone programs and will never be imported / evaluated by copypart
|
||||
|
||||
# sfx
|
||||
|
||||
the self-contained "binary" [copyparty-sfx.py](https://github.com/9001/copyparty/releases/latest/download/copyparty-sfx.py) will unpack itself and run copyparty, assuming you have python installed of course
|
||||
the self-contained "binary" (recommended!) [copyparty-sfx.py](https://github.com/9001/copyparty/releases/latest/download/copyparty-sfx.py) will unpack itself and run copyparty, assuming you have python installed of course
|
||||
|
||||
you can reduce the sfx size by repacking it; see [./docs/devnotes.md#sfx-repack](./docs/devnotes.md#sfx-repack)
|
||||
|
||||
@@ -2008,6 +2042,16 @@ meanwhile [copyparty-sfx.py](https://github.com/9001/copyparty/releases/latest/d
|
||||
then again, if you are already into downloading shady binaries from the internet, you may also want my [minimal builds](./scripts/pyinstaller#ffmpeg) of [ffmpeg](https://ocv.me/stuff/bin/ffmpeg.exe) and [ffprobe](https://ocv.me/stuff/bin/ffprobe.exe) which enables copyparty to extract multimedia-info, do audio-transcoding, and thumbnails/spectrograms/waveforms, however it's much better to instead grab a [recent official build](https://www.gyan.dev/ffmpeg/builds/ffmpeg-git-full.7z) every once ina while if you can afford the size
|
||||
|
||||
|
||||
## zipapp
|
||||
|
||||
another emergency alternative, [copyparty.pyz](https://github.com/9001/copyparty/releases/latest/download/copyparty.pyz) has less features, requires python 3.7 or newer, worse compression, and more importantly is unable to benefit from more recent versions of jinja2 and such (which makes it less secure)... lots of drawbacks with this one really -- but it *may* just work if the regular sfx fails to start because the computer is messed up in certain funky ways, so it's worth a shot if all else fails
|
||||
|
||||
run it by doubleclicking it, or try typing `python copyparty.pyz` in your terminal/console/commandline/telex if that fails
|
||||
|
||||
it is a python [zipapp](https://docs.python.org/3/library/zipapp.html) meaning it doesn't have to unpack its own python code anywhere to run, so if the filesystem is busted it has a better chance of getting somewhere
|
||||
* but note that it currently still needs to extract the web-resources somewhere (they'll land in the default TEMP-folder of your OS)
|
||||
|
||||
|
||||
# install on android
|
||||
|
||||
install [Termux](https://termux.com/) + its companion app `Termux:API` (see [ocv.me/termux](https://ocv.me/termux/)) and then copy-paste this into Termux (long-tap) all at once:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Maintainer: icxes <dev.null@need.moe>
|
||||
pkgname=copyparty
|
||||
pkgver="1.12.2"
|
||||
pkgver="1.13.0"
|
||||
pkgrel=1
|
||||
pkgdesc="File server with accelerated resumable uploads, dedup, WebDAV, FTP, TFTP, zeroconf, media indexer, thumbnails++"
|
||||
arch=("any")
|
||||
@@ -21,7 +21,7 @@ optdepends=("ffmpeg: thumbnails for videos, images (slower) and audio, music tag
|
||||
)
|
||||
source=("https://github.com/9001/${pkgname}/releases/download/v${pkgver}/${pkgname}-${pkgver}.tar.gz")
|
||||
backup=("etc/${pkgname}.d/init" )
|
||||
sha256sums=("e4fd6733e5361f5ceb2ae950f71f65f2609c2b69d45f47e8b2a2f128fb67de0a")
|
||||
sha256sums=("9ad9ea5d4bdf947ed39f4ae571219d3528794c2ec6d4f470a5f3737899787e03")
|
||||
|
||||
build() {
|
||||
cd "${srcdir}/${pkgname}-${pkgver}"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"url": "https://github.com/9001/copyparty/releases/download/v1.12.2/copyparty-sfx.py",
|
||||
"version": "1.12.2",
|
||||
"hash": "sha256-GJts5N0leK/WHqpqb+eB1JjBvf6TRpzCc9R7AIHkujo="
|
||||
"url": "https://github.com/9001/copyparty/releases/download/v1.13.0/copyparty-sfx.py",
|
||||
"version": "1.13.0",
|
||||
"hash": "sha256-3/ttK5BXAA5F1MztahiQp32QSSZqhuh3V6xb12T/6nM="
|
||||
}
|
||||
29
copyparty/__main__.py
Executable file → Normal file
29
copyparty/__main__.py
Executable file → Normal file
@@ -860,6 +860,7 @@ def add_fs(ap):
|
||||
ap2.add_argument("--rm-retry", metavar="T/R", type=u, default=rm_re_def, help="if a file cannot be deleted because it is busy, continue trying for \033[33mT\033[0m seconds, retry every \033[33mR\033[0m seconds; disable with 0/0 (volflag=rm_retry)")
|
||||
ap2.add_argument("--mv-retry", metavar="T/R", type=u, default=rm_re_def, help="if a file cannot be renamed because it is busy, continue trying for \033[33mT\033[0m seconds, retry every \033[33mR\033[0m seconds; disable with 0/0 (volflag=mv_retry)")
|
||||
ap2.add_argument("--iobuf", metavar="BYTES", type=int, default=256*1024, help="file I/O buffer-size; if your volumes are on a network drive, try increasing to \033[32m524288\033[0m or even \033[32m4194304\033[0m (and let me know if that improves your performance)")
|
||||
ap2.add_argument("--mtab-age", metavar="SEC", type=int, default=60, help="rebuild mountpoint cache every \033[33mSEC\033[0m to keep track of sparse-files support; keep low on servers with removable media")
|
||||
|
||||
|
||||
def add_upload(ap):
|
||||
@@ -1256,19 +1257,38 @@ def add_txt(ap):
|
||||
ap2.add_argument("--exp-lg", metavar="V,V,V", type=u, default=DEF_EXP, help="comma/space-separated list of placeholders to expand in prologue/epilogue files (volflag=exp_lg)")
|
||||
|
||||
|
||||
def add_og(ap):
|
||||
ap2 = ap.add_argument_group('og / open graph / discord-embed options')
|
||||
ap2.add_argument("--og", action="store_true", help="disable hotlinking and return an html document instead; this is required by open-graph, but can also be useful on its own (volflag=og)")
|
||||
ap2.add_argument("--og-ua", metavar="RE", type=u, default="", help="only disable hotlinking / engage OG behavior if the useragent matches regex \033[33mRE\033[0m (volflag=og_ua)")
|
||||
ap2.add_argument("--og-tpl", metavar="PATH", type=u, default="", help="do not return the regular copyparty html, but instead load the jinja2 template at \033[33mPATH\033[0m (if path contains 'EXT' then EXT will be replaced with the requested file's extension) (volflag=og_tpl)")
|
||||
ap2.add_argument("--og-no-head", action="store_true", help="do not automatically add OG entries into <head> (useful if you're doing this yourself in a template or such) (volflag=og_no_head)")
|
||||
ap2.add_argument("--og-th", metavar="FMT", type=u, default="jf3", help="thumbnail format; j=jpeg, jf=jpeg-uncropped, jf3=jpeg-uncropped-large, w=webm, ... (volflag=og_th)")
|
||||
ap2.add_argument("--og-title", metavar="TXT", type=u, default="", help="fallback title if there is nothing in the \033[33m-e2t\033[0m database (volflag=og_title)")
|
||||
ap2.add_argument("--og-title-a", metavar="T", type=u, default="🎵 {{ artist }} - {{ title }}", help="audio title format; takes any metadata key (volflag=og_title_a)")
|
||||
ap2.add_argument("--og-title-v", metavar="T", type=u, default="{{ title }}", help="video title format; takes any metadata key (volflag=og_title_v)")
|
||||
ap2.add_argument("--og-title-i", metavar="T", type=u, default="{{ title }}", help="image title format; takes any metadata key (volflag=og_title_i)")
|
||||
ap2.add_argument("--og-s-title", action="store_true", help="force default title; do not read from tags (volflag=og_s_title)")
|
||||
ap2.add_argument("--og-desc", metavar="TXT", type=u, default="", help="description text; same for all files, disable with [\033[32m-\033[0m] (volflag=og_desc)")
|
||||
ap2.add_argument("--og-site", metavar="TXT", type=u, default="", help="sitename; defaults to \033[33m--name\033[0m, disable with [\033[32m-\033[0m] (volflag=og_site)")
|
||||
ap2.add_argument("--tcolor", metavar="RGB", type=u, default="333", help="accent color (3 or 6 hex digits); may also affect safari and/or android-chrome (volflag=tcolor)")
|
||||
ap2.add_argument("--uqe", action="store_true", help="query-string parceling; translate a request for \033[33m/foo/.uqe/BASE64\033[0m into \033[33m/foo?TEXT\033[0m, or \033[33m/foo/?TEXT\033[0m if the first character in \033[33mTEXT\033[0m is a slash. Automatically enabled for \033[33m--og\033[0m")
|
||||
|
||||
|
||||
def add_ui(ap, retry):
|
||||
ap2 = ap.add_argument_group('ui options')
|
||||
ap2.add_argument("--grid", action="store_true", help="show grid/thumbnails by default (volflag=grid)")
|
||||
ap2.add_argument("--lang", metavar="LANG", type=u, default="eng", help="language; one of the following: \033[32meng nor\033[0m")
|
||||
ap2.add_argument("--theme", metavar="NUM", type=int, default=0, help="default theme to use (0..7)")
|
||||
ap2.add_argument("--themes", metavar="NUM", type=int, default=8, help="number of themes installed")
|
||||
ap2.add_argument("--au-vol", metavar="0-100", type=int, default=50, choices=range(0, 101), help="default audio/video volume percent")
|
||||
ap2.add_argument("--sort", metavar="C,C,C", type=u, default="href", help="default sort order, comma-separated column IDs (see header tooltips), prefix with '-' for descending. Examples: \033[32mhref -href ext sz ts tags/Album tags/.tn\033[0m (volflag=sort)")
|
||||
ap2.add_argument("--unlist", metavar="REGEX", type=u, default="", help="don't show files matching \033[33mREGEX\033[0m in file list. Purely cosmetic! Does not affect API calls, just the browser. Example: [\033[32m\\.(js|css)$\033[0m] (volflag=unlist)")
|
||||
ap2.add_argument("--favico", metavar="TXT", type=u, default="c 000 none" if retry else "🎉 000 none", help="\033[33mfavicon-text\033[0m [ \033[33mforeground\033[0m [ \033[33mbackground\033[0m ] ], set blank to disable")
|
||||
ap2.add_argument("--mpmc", metavar="URL", type=u, default="", help="change the mediaplayer-toggle mouse cursor; URL to a folder with {2..5}.png inside (or disable with [\033[32m.\033[0m])")
|
||||
ap2.add_argument("--js-browser", metavar="L", type=u, help="URL to additional JS to include")
|
||||
ap2.add_argument("--css-browser", metavar="L", type=u, help="URL to additional CSS to include")
|
||||
ap2.add_argument("--html-head", metavar="TXT", type=u, default="", help="text to append to the <head> of all HTML pages")
|
||||
ap2.add_argument("--html-head", metavar="TXT", type=u, default="", help="text to append to the <head> of all HTML pages; can be @PATH to send the contents of a file at PATH, and/or begin with %% to render as jinja2 template (volflag=html_head)")
|
||||
ap2.add_argument("--ih", action="store_true", help="if a folder contains index.html, show that instead of the directory listing by default (can be changed in the client settings UI, or add ?v to URL for override)")
|
||||
ap2.add_argument("--textfiles", metavar="CSV", type=u, default="txt,nfo,diz,cue,readme", help="file extensions to present as plaintext")
|
||||
ap2.add_argument("--txt-max", metavar="KiB", type=int, default=64, help="max size of embedded textfiles on ?doc= (anything bigger will be lazy-loaded by JS)")
|
||||
@@ -1356,6 +1376,7 @@ def run_argparse(
|
||||
add_hooks(ap)
|
||||
add_stats(ap)
|
||||
add_txt(ap)
|
||||
add_og(ap)
|
||||
add_ui(ap, retry)
|
||||
add_admin(ap)
|
||||
add_logging(ap)
|
||||
@@ -1390,12 +1411,16 @@ def run_argparse(
|
||||
return ret
|
||||
|
||||
|
||||
def main(argv: Optional[list[str]] = None) -> None:
|
||||
def main(argv: Optional[list[str]] = None, rsrc: Optional[str] = None) -> None:
|
||||
time.strptime("19970815", "%Y%m%d") # python#7980
|
||||
if WINDOWS:
|
||||
os.system("rem") # enables colors
|
||||
|
||||
init_E(E)
|
||||
|
||||
if rsrc: # pyz
|
||||
E.mod = rsrc
|
||||
|
||||
if argv is None:
|
||||
argv = sys.argv
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# coding: utf-8
|
||||
|
||||
VERSION = (1, 13, 0)
|
||||
VERSION = (1, 13, 1)
|
||||
CODENAME = "race the beam"
|
||||
BUILD_DT = (2024, 4, 20)
|
||||
BUILD_DT = (2024, 5, 6)
|
||||
|
||||
S_VERSION = ".".join(map(str, VERSION))
|
||||
S_BUILD_DT = "{0:04d}-{1:02d}-{2:02d}".format(*BUILD_DT)
|
||||
|
||||
@@ -1442,6 +1442,7 @@ class AuthSrv(object):
|
||||
elif "" not in mount:
|
||||
# there's volumes but no root; make root inaccessible
|
||||
vfs = VFS(self.log_func, "", "", AXS(), {})
|
||||
vfs.flags["tcolor"] = self.args.tcolor
|
||||
vfs.flags["d2d"] = True
|
||||
|
||||
maxdepth = 0
|
||||
@@ -1727,7 +1728,11 @@ class AuthSrv(object):
|
||||
if self.args.e2d or "e2ds" in vol.flags:
|
||||
vol.flags["e2d"] = True
|
||||
|
||||
for ga, vf in [["no_hash", "nohash"], ["no_idx", "noidx"]]:
|
||||
for ga, vf in [
|
||||
["no_hash", "nohash"],
|
||||
["no_idx", "noidx"],
|
||||
["og_ua", "og_ua"],
|
||||
]:
|
||||
if vf in vol.flags:
|
||||
ptn = re.compile(vol.flags.pop(vf))
|
||||
else:
|
||||
@@ -1773,6 +1778,13 @@ class AuthSrv(object):
|
||||
t = 'volume "/%s" has invalid %stry [%s]'
|
||||
raise Exception(t % (vol.vpath, k, vol.flags.get(k + "try")))
|
||||
|
||||
if vol.flags.get("og"):
|
||||
self.args.uqe = True
|
||||
|
||||
zs = str(vol.flags.get("tcolor", "")).lstrip("#")
|
||||
if len(zs) == 3: # fc5 => ffcc55
|
||||
vol.flags["tcolor"] = "".join([x * 2 for x in zs])
|
||||
|
||||
for k1, k2 in IMPLICATIONS:
|
||||
if k1 in vol.flags:
|
||||
vol.flags[k2] = True
|
||||
@@ -2410,7 +2422,7 @@ def expand_config_file(
|
||||
if not cnames:
|
||||
t = "warning: tried to read config-files from folder '%s' but it does not contain any "
|
||||
if names:
|
||||
t += ".conf files; the following files were ignored: %s"
|
||||
t += ".conf files; the following files/subfolders were ignored: %s"
|
||||
t = t % (fp, ", ".join(names[:8]))
|
||||
else:
|
||||
t += "files at all"
|
||||
|
||||
@@ -39,6 +39,9 @@ def vf_bmap() -> dict[str, str]:
|
||||
"magic",
|
||||
"no_sb_md",
|
||||
"no_sb_lg",
|
||||
"og",
|
||||
"og_no_head",
|
||||
"og_s_title",
|
||||
"rand",
|
||||
"xdev",
|
||||
"xlink",
|
||||
@@ -61,12 +64,23 @@ def vf_vmap() -> dict[str, str]:
|
||||
}
|
||||
for k in (
|
||||
"dbd",
|
||||
"html_head",
|
||||
"lg_sbf",
|
||||
"md_sbf",
|
||||
"nrand",
|
||||
"og_desc",
|
||||
"og_site",
|
||||
"og_th",
|
||||
"og_title",
|
||||
"og_title_a",
|
||||
"og_title_v",
|
||||
"og_title_i",
|
||||
"og_tpl",
|
||||
"og_ua",
|
||||
"mv_retry",
|
||||
"rm_retry",
|
||||
"sort",
|
||||
"tcolor",
|
||||
"unlist",
|
||||
"u2abort",
|
||||
"u2ts",
|
||||
@@ -81,7 +95,6 @@ def vf_cmap() -> dict[str, str]:
|
||||
for k in (
|
||||
"exp_lg",
|
||||
"exp_md",
|
||||
"html_head",
|
||||
"mte",
|
||||
"mth",
|
||||
"mtp",
|
||||
@@ -201,7 +214,7 @@ flagcats = {
|
||||
"grid": "show grid/thumbnails by default",
|
||||
"sort": "default sort order",
|
||||
"unlist": "dont list files matching REGEX",
|
||||
"html_head=TXT": "includes TXT in the <head>",
|
||||
"html_head=TXT": "includes TXT in the <head>, or @PATH for file at PATH",
|
||||
"robots": "allows indexing by search engines (default)",
|
||||
"norobots": "kindly asks search engines to leave",
|
||||
"no_sb_md": "disable js sandbox for markdown files",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# coding: utf-8
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
@@ -17,20 +18,26 @@ if True: # pylint: disable=using-constant-test
|
||||
|
||||
|
||||
class Fstab(object):
|
||||
def __init__(self, log: "RootLogger"):
|
||||
def __init__(self, log: "RootLogger", args: argparse.Namespace):
|
||||
self.log_func = log
|
||||
|
||||
self.warned = False
|
||||
self.trusted = False
|
||||
self.tab: Optional[VFS] = None
|
||||
self.oldtab: Optional[VFS] = None
|
||||
self.srctab = "a"
|
||||
self.cache: dict[str, str] = {}
|
||||
self.age = 0.0
|
||||
self.maxage = args.mtab_age
|
||||
|
||||
def log(self, msg: str, c: Union[int, str] = 0) -> None:
|
||||
self.log_func("fstab", msg, c)
|
||||
|
||||
def get(self, path: str) -> str:
|
||||
if len(self.cache) > 9000:
|
||||
self.age = time.time()
|
||||
now = time.time()
|
||||
if now - self.age > self.maxage or len(self.cache) > 9000:
|
||||
self.age = now
|
||||
self.oldtab = self.tab or self.oldtab
|
||||
self.tab = None
|
||||
self.cache = {}
|
||||
|
||||
@@ -75,7 +82,7 @@ class Fstab(object):
|
||||
self.trusted = False
|
||||
|
||||
def build_tab(self) -> None:
|
||||
self.log("building tab")
|
||||
self.log("inspecting mtab for changes")
|
||||
|
||||
sptn = r"^.*? on (.*) type ([^ ]+) \(.*"
|
||||
if MACOS:
|
||||
@@ -84,6 +91,7 @@ class Fstab(object):
|
||||
ptn = re.compile(sptn)
|
||||
so, _ = chkcmd(["mount"])
|
||||
tab1: list[tuple[str, str]] = []
|
||||
atab = []
|
||||
for ln in so.split("\n"):
|
||||
m = ptn.match(ln)
|
||||
if not m:
|
||||
@@ -91,6 +99,15 @@ class Fstab(object):
|
||||
|
||||
zs1, zs2 = m.groups()
|
||||
tab1.append((str(zs1), str(zs2)))
|
||||
atab.append(ln)
|
||||
|
||||
# keep empirically-correct values if mounttab unchanged
|
||||
srctab = "\n".join(sorted(atab))
|
||||
if srctab == self.srctab:
|
||||
self.tab = self.oldtab
|
||||
return
|
||||
|
||||
self.log("mtab has changed; reevaluating support for sparse files")
|
||||
|
||||
tab1.sort(key=lambda x: (len(x[0]), x[0]))
|
||||
path1, fs1 = tab1[0]
|
||||
@@ -99,6 +116,7 @@ class Fstab(object):
|
||||
tab.add(fs, path.lstrip("/"))
|
||||
|
||||
self.tab = tab
|
||||
self.srctab = srctab
|
||||
|
||||
def relabel(self, path: str, nval: str) -> None:
|
||||
assert self.tab
|
||||
@@ -133,7 +151,9 @@ class Fstab(object):
|
||||
self.trusted = True
|
||||
except:
|
||||
# prisonparty or other restrictive environment
|
||||
self.log("failed to build tab:\n{}".format(min_ex()), 3)
|
||||
if not self.warned:
|
||||
self.warned = True
|
||||
self.log("failed to build tab:\n{}".format(min_ex()), 3)
|
||||
self.build_fallback()
|
||||
|
||||
assert self.tab
|
||||
|
||||
@@ -84,6 +84,9 @@ from .util import (
|
||||
sanitize_vpath,
|
||||
sendfile_kern,
|
||||
sendfile_py,
|
||||
ub64dec,
|
||||
ub64enc,
|
||||
ujoin,
|
||||
undot,
|
||||
unescape_cookie,
|
||||
unquotep,
|
||||
@@ -217,6 +220,13 @@ class HttpCli(object):
|
||||
ka["favico"] = self.args.favico
|
||||
ka["s_name"] = self.args.bname
|
||||
ka["s_doctitle"] = self.args.doctitle
|
||||
ka["tcolor"] = self.vn.flags["tcolor"]
|
||||
|
||||
zso = self.vn.flags.get("html_head")
|
||||
if zso:
|
||||
ka["this"] = self
|
||||
self._build_html_head(zso, ka)
|
||||
|
||||
ka["html_head"] = self.html_head
|
||||
return tpl.render(**ka) # type: ignore
|
||||
|
||||
@@ -364,6 +374,21 @@ class HttpCli(object):
|
||||
if "&" in self.req and "?" not in self.req:
|
||||
self.hint = "did you mean '?' instead of '&'"
|
||||
|
||||
if self.args.uqe and "/.uqe/" in self.req:
|
||||
try:
|
||||
vpath, query = self.req.split("?")[0].split("/.uqe/")
|
||||
query = query.split("/")[0] # discard trailing junk
|
||||
# (usually a "filename" to trick discord into behaving)
|
||||
query = ub64dec(query.encode("utf-8")).decode("utf-8", "replace")
|
||||
if query.startswith("/"):
|
||||
self.req = "%s/?%s" % (vpath, query[1:])
|
||||
else:
|
||||
self.req = "%s?%s" % (vpath, query)
|
||||
except Exception as ex:
|
||||
t = "bad uqe in request [%s]: %r" % (self.req, ex)
|
||||
self.loud_reply(t, status=400)
|
||||
return False
|
||||
|
||||
# split req into vpath + uparam
|
||||
uparam = {}
|
||||
if "?" not in self.req:
|
||||
@@ -430,7 +455,8 @@ class HttpCli(object):
|
||||
cookie_pw = ""
|
||||
|
||||
if len(uparam) > 10 or len(cookies) > 50:
|
||||
raise Pebkac(400, "u wot m8")
|
||||
self.loud_reply("u wot m8", status=400)
|
||||
return False
|
||||
|
||||
self.uparam = uparam
|
||||
self.cookies = cookies
|
||||
@@ -718,6 +744,31 @@ class HttpCli(object):
|
||||
or ("; Trident/" in self.ua and not k304)
|
||||
)
|
||||
|
||||
def _build_html_head(self, maybe_html: Any, kv: dict[str, Any]) -> bool:
|
||||
html = str(maybe_html)
|
||||
is_jinja = html[:2] in "%@%"
|
||||
if is_jinja:
|
||||
html = html.replace("%", "", 1)
|
||||
|
||||
if html.startswith("@"):
|
||||
with open(html[1:], "rb") as f:
|
||||
html = f.read().decode("utf-8")
|
||||
|
||||
if html.startswith("%"):
|
||||
html = html[1:]
|
||||
is_jinja = True
|
||||
|
||||
if is_jinja:
|
||||
print("applying jinja")
|
||||
with self.conn.hsrv.mutex:
|
||||
if html not in self.conn.hsrv.j2:
|
||||
j2env = jinja2.Environment()
|
||||
tpl = j2env.from_string(html)
|
||||
self.conn.hsrv.j2[html] = tpl
|
||||
html = self.conn.hsrv.j2[html].render(**kv)
|
||||
|
||||
self.html_head += html + "\n"
|
||||
|
||||
def send_headers(
|
||||
self,
|
||||
length: Optional[int],
|
||||
@@ -2251,6 +2302,10 @@ class HttpCli(object):
|
||||
def handle_login(self) -> bool:
|
||||
assert self.parser
|
||||
pwd = self.parser.require("cppwd", 64)
|
||||
try:
|
||||
uhash = self.parser.require("uhash", 256)
|
||||
except:
|
||||
uhash = ""
|
||||
self.parser.drop()
|
||||
|
||||
self.out_headerlist = [
|
||||
@@ -2263,6 +2318,11 @@ class HttpCli(object):
|
||||
|
||||
dst += self.ourlq()
|
||||
|
||||
uhash = uhash.lstrip("#")
|
||||
if uhash not in ("", "-"):
|
||||
dst += "&" if "?" in dst else "?"
|
||||
dst += "_=1#" + html_escape(uhash, True, True)
|
||||
|
||||
msg = self.get_pwd_cookie(pwd)
|
||||
html = self.j2s("msg", h1=msg, h2='<a href="' + dst + '">ack</a>', redir=dst)
|
||||
self.reply(html.encode("utf-8"))
|
||||
@@ -3188,7 +3248,7 @@ class HttpCli(object):
|
||||
data_end = file_size
|
||||
break
|
||||
|
||||
if num_need != len(job["need"]):
|
||||
if num_need != len(job["need"]) and data_end - lower < 8 * M:
|
||||
num_need = len(job["need"])
|
||||
data_end = 0
|
||||
for cid in job["hash"]:
|
||||
@@ -3484,7 +3544,6 @@ class HttpCli(object):
|
||||
targs = {
|
||||
"r": self.args.SR if self.is_vproxied else "",
|
||||
"ts": self.conn.hsrv.cachebuster(),
|
||||
"html_head": self.html_head,
|
||||
"edit": "edit" in self.uparam,
|
||||
"title": html_escape(self.vpath, crlf=True),
|
||||
"lastmod": int(ts_md * 1000),
|
||||
@@ -3495,6 +3554,13 @@ class HttpCli(object):
|
||||
"md": boundary,
|
||||
"arg_base": arg_base,
|
||||
}
|
||||
|
||||
zfv = self.vn.flags.get("html_head")
|
||||
if zfv:
|
||||
targs["this"] = self
|
||||
self._build_html_head(zfv, targs)
|
||||
|
||||
targs["html_head"] = self.html_head
|
||||
zs = template.render(**targs).encode("utf-8", "replace")
|
||||
html = zs.split(boundary.encode("utf-8"))
|
||||
if len(html) != 2:
|
||||
@@ -3610,8 +3676,6 @@ class HttpCli(object):
|
||||
self.reply(zb, mime="text/plain; charset=utf-8")
|
||||
return True
|
||||
|
||||
self.html_head += self.vn.flags.get("html_head", "")
|
||||
|
||||
html = self.j2s(
|
||||
"splash",
|
||||
this=self,
|
||||
@@ -3656,7 +3720,7 @@ class HttpCli(object):
|
||||
return True
|
||||
|
||||
def set_cfg_reset(self) -> bool:
|
||||
for k in ("k304", "js", "idxh", "cppwd", "cppws"):
|
||||
for k in ("k304", "js", "idxh", "dots", "cppwd", "cppws"):
|
||||
cookie = gencookie(k, "x", self.args.R, False)
|
||||
self.out_headerlist.append(("Set-Cookie", cookie))
|
||||
|
||||
@@ -3867,7 +3931,7 @@ class HttpCli(object):
|
||||
allvols = [x for x in allvols if "e2d" in x.flags]
|
||||
|
||||
for vol in allvols:
|
||||
cur = idx.get_cur(vol.realpath)
|
||||
cur = idx.get_cur(vol)
|
||||
if not cur:
|
||||
continue
|
||||
|
||||
@@ -4082,7 +4146,17 @@ class HttpCli(object):
|
||||
e2d = "e2d" in vn.flags
|
||||
e2t = "e2t" in vn.flags
|
||||
|
||||
self.html_head += vn.flags.get("html_head", "")
|
||||
add_og = "og" in vn.flags
|
||||
if add_og:
|
||||
if "th" in self.uparam or "raw" in self.uparam:
|
||||
og_ua = add_og = False
|
||||
elif self.args.og_ua:
|
||||
og_ua = add_og = self.args.og_ua.search(self.ua)
|
||||
else:
|
||||
og_ua = False
|
||||
add_og = True
|
||||
og_fn = ""
|
||||
|
||||
if "b" in self.uparam:
|
||||
self.out_headers["X-Robots-Tag"] = "noindex, nofollow"
|
||||
|
||||
@@ -4090,13 +4164,15 @@ class HttpCli(object):
|
||||
is_dk = False
|
||||
fk_pass = False
|
||||
icur = None
|
||||
if is_dir and (e2t or e2d):
|
||||
if (e2t or e2d) and (is_dir or add_og):
|
||||
idx = self.conn.get_u2idx()
|
||||
if idx and hasattr(idx, "p_end"):
|
||||
icur = idx.get_cur(dbv.realpath)
|
||||
icur = idx.get_cur(dbv)
|
||||
|
||||
th_fmt = self.uparam.get("th")
|
||||
if self.can_read or (self.can_get and vn.flags.get("dk")):
|
||||
if self.can_read or (
|
||||
self.can_get and (vn.flags.get("dk") or "fk" not in vn.flags)
|
||||
):
|
||||
if th_fmt is not None:
|
||||
nothumb = "dthumb" in dbv.flags
|
||||
if is_dir:
|
||||
@@ -4143,7 +4219,7 @@ class HttpCli(object):
|
||||
elif self.can_write and th_fmt is not None:
|
||||
return self.tx_svg("upload\nonly")
|
||||
|
||||
elif self.can_get and self.avn:
|
||||
if not self.can_read and self.can_get and self.avn:
|
||||
axs = self.avn.axs
|
||||
if self.uname not in axs.uhtml:
|
||||
pass
|
||||
@@ -4189,6 +4265,17 @@ class HttpCli(object):
|
||||
self.log(t % (correct, got, self.req, abspath), 6)
|
||||
return self.tx_404()
|
||||
|
||||
if add_og:
|
||||
if og_ua or self.host not in self.headers.get("referer", ""):
|
||||
self.vpath, og_fn = vsplit(self.vpath)
|
||||
vpath = self.vpath
|
||||
vn, rem = self.asrv.vfs.get(self.vpath, self.uname, False, False)
|
||||
abspath = vn.dcanonical(rem)
|
||||
dbv, vrem = vn.get_dbv(rem)
|
||||
is_dir = stat.S_ISDIR(st.st_mode)
|
||||
is_dk = True
|
||||
vpnodes.pop()
|
||||
|
||||
if (
|
||||
(abspath.endswith(".md") or self.can_delete)
|
||||
and "nohtml" not in vn.flags
|
||||
@@ -4200,9 +4287,10 @@ class HttpCli(object):
|
||||
):
|
||||
return self.tx_md(vn, abspath)
|
||||
|
||||
return self.tx_file(
|
||||
abspath, None if st.st_size or "nopipe" in vn.flags else vn.realpath
|
||||
)
|
||||
if not add_og or not og_fn:
|
||||
return self.tx_file(
|
||||
abspath, None if st.st_size or "nopipe" in vn.flags else vn.realpath
|
||||
)
|
||||
|
||||
elif is_dir and not self.can_read:
|
||||
if self._use_dirkey(abspath):
|
||||
@@ -4249,7 +4337,11 @@ class HttpCli(object):
|
||||
is_ls = "ls" in self.uparam
|
||||
is_js = self.args.force_js or self.cookies.get("js") == "y"
|
||||
|
||||
if not is_ls and (self.ua.startswith("curl/") or self.ua.startswith("fetch")):
|
||||
if (
|
||||
not is_ls
|
||||
and not add_og
|
||||
and (self.ua.startswith("curl/") or self.ua.startswith("fetch"))
|
||||
):
|
||||
self.uparam["ls"] = "v"
|
||||
is_ls = True
|
||||
|
||||
@@ -4323,6 +4415,7 @@ class HttpCli(object):
|
||||
"dsort": vf["sort"],
|
||||
"dcrop": vf["crop"],
|
||||
"dth3x": vf["th3x"],
|
||||
"dvol": self.args.au_vol,
|
||||
"themes": self.args.themes,
|
||||
"turbolvl": self.args.turbo,
|
||||
"u2j": self.args.u2j,
|
||||
@@ -4374,7 +4467,7 @@ class HttpCli(object):
|
||||
|
||||
for k in ["zip", "tar"]:
|
||||
v = self.uparam.get(k)
|
||||
if v is not None:
|
||||
if v is not None and (not add_og or not og_fn):
|
||||
return self.tx_zip(k, v, self.vpath, vn, rem, [])
|
||||
|
||||
fsroot, vfs_ls, vfs_virt = vn.ls(
|
||||
@@ -4388,6 +4481,10 @@ class HttpCli(object):
|
||||
ls_names = [x[0] for x in vfs_ls]
|
||||
ls_names.extend(list(vfs_virt.keys()))
|
||||
|
||||
if add_og and og_fn and not self.can_read:
|
||||
ls_names = [og_fn]
|
||||
is_js = True
|
||||
|
||||
# check for old versions of files,
|
||||
# [num-backups, most-recent, hist-path]
|
||||
hist: dict[str, tuple[int, float, str]] = {}
|
||||
@@ -4449,12 +4546,14 @@ class HttpCli(object):
|
||||
margin = "DIR"
|
||||
elif add_dk:
|
||||
zs = absreal(fspath)
|
||||
margin = '<a href="%s?k=%s&zip" rel="nofollow">zip</a>' % (
|
||||
margin = '<a href="%s?k=%s&zip=crc" rel="nofollow">zip</a>' % (
|
||||
quotep(href),
|
||||
self.gen_fk(2, self.args.dk_salt, zs, 0, 0)[:add_dk],
|
||||
)
|
||||
else:
|
||||
margin = '<a href="%s?zip" rel="nofollow">zip</a>' % (quotep(href),)
|
||||
margin = '<a href="%s?zip=crc" rel="nofollow">zip</a>' % (
|
||||
quotep(href),
|
||||
)
|
||||
elif fn in hist:
|
||||
margin = '<a href="%s.hist/%s">#%s</a>' % (
|
||||
base,
|
||||
@@ -4598,6 +4697,9 @@ class HttpCli(object):
|
||||
else:
|
||||
taglist = list(tagset)
|
||||
|
||||
if not files and not dirs and not readme and not logues[0] and not logues[1]:
|
||||
logues[1] = "this folder is empty"
|
||||
|
||||
if is_ls:
|
||||
ls_ret["dirs"] = dirs
|
||||
ls_ret["files"] = files
|
||||
@@ -4649,6 +4751,148 @@ class HttpCli(object):
|
||||
if "mth" in vn.flags:
|
||||
j2a["def_hcols"] = list(vn.flags["mth"])
|
||||
|
||||
if add_og and "raw" not in self.uparam:
|
||||
j2a["this"] = self
|
||||
cgv["og_fn"] = og_fn
|
||||
if og_fn and vn.flags.get("og_tpl"):
|
||||
tpl = vn.flags["og_tpl"]
|
||||
if "EXT" in tpl:
|
||||
zs = og_fn.split(".")[-1].lower()
|
||||
tpl2 = tpl.replace("EXT", zs)
|
||||
if os.path.exists(tpl2):
|
||||
tpl = tpl2
|
||||
with self.conn.hsrv.mutex:
|
||||
if tpl not in self.conn.hsrv.j2:
|
||||
tdir, tname = os.path.split(tpl)
|
||||
j2env = jinja2.Environment()
|
||||
j2env.loader = jinja2.FileSystemLoader(tdir)
|
||||
self.conn.hsrv.j2[tpl] = j2env.get_template(tname)
|
||||
thumb = ""
|
||||
is_pic = is_vid = is_au = False
|
||||
covernames = self.args.th_coversd
|
||||
for fn in ls_names:
|
||||
if fn.lower() in covernames:
|
||||
thumb = fn
|
||||
break
|
||||
if og_fn:
|
||||
ext = og_fn.split(".")[-1].lower()
|
||||
if ext in self.thumbcli.thumbable:
|
||||
is_pic = (
|
||||
ext in self.thumbcli.fmt_pil
|
||||
or ext in self.thumbcli.fmt_vips
|
||||
or ext in self.thumbcli.fmt_ffi
|
||||
)
|
||||
is_vid = ext in self.thumbcli.fmt_ffv
|
||||
is_au = ext in self.thumbcli.fmt_ffa
|
||||
if not thumb or not is_au:
|
||||
thumb = og_fn
|
||||
file = next((x for x in files if x["name"] == og_fn), None)
|
||||
else:
|
||||
file = None
|
||||
|
||||
url_base = "%s://%s/%s" % (
|
||||
"https" if self.is_https else "http",
|
||||
self.host,
|
||||
self.args.RS + quotep(vpath),
|
||||
)
|
||||
j2a["og_is_pic"] = is_pic
|
||||
j2a["og_is_vid"] = is_vid
|
||||
j2a["og_is_au"] = is_au
|
||||
if thumb:
|
||||
fmt = vn.flags.get("og_th", "j")
|
||||
th_base = ujoin(url_base, quotep(thumb))
|
||||
query = "th=%s&cache" % (fmt,)
|
||||
query = ub64enc(query.encode("utf-8")).decode("utf-8")
|
||||
# discord looks at file extension, not content-type...
|
||||
query += "/a.jpg" if "j" in fmt else "/a.webp"
|
||||
j2a["og_thumb"] = "%s/.uqe/%s" % (th_base, query)
|
||||
|
||||
j2a["og_fn"] = og_fn
|
||||
j2a["og_file"] = file
|
||||
if og_fn:
|
||||
og_fn_q = quotep(og_fn)
|
||||
query = ub64enc(b"raw").decode("utf-8")
|
||||
if "." in og_fn:
|
||||
query += "/a.%s" % (og_fn.split(".")[-1])
|
||||
|
||||
j2a["og_url"] = ujoin(url_base, og_fn_q)
|
||||
j2a["og_raw"] = j2a["og_url"] + "/.uqe/" + query
|
||||
else:
|
||||
j2a["og_url"] = j2a["og_raw"] = url_base
|
||||
|
||||
if not vn.flags.get("og_no_head"):
|
||||
ogh = {"twitter:card": "summary"}
|
||||
|
||||
title = str(vn.flags.get("og_title") or "")
|
||||
|
||||
if thumb:
|
||||
ogh["og:image"] = j2a["og_thumb"]
|
||||
|
||||
zso = vn.flags.get("og_desc") or ""
|
||||
if zso != "-":
|
||||
ogh["og:description"] = str(zso)
|
||||
|
||||
zs = vn.flags.get("og_site") or self.args.name
|
||||
if zs not in ("", "-"):
|
||||
ogh["og:site_name"] = zs
|
||||
|
||||
tagmap = {}
|
||||
if is_au:
|
||||
title = str(vn.flags.get("og_title_a") or "")
|
||||
ogh["og:type"] = "music.song"
|
||||
ogh["og:audio"] = j2a["og_raw"]
|
||||
tagmap = {
|
||||
"artist": "og:music:musician",
|
||||
"album": "og:music:album",
|
||||
".dur": "og:music:duration",
|
||||
}
|
||||
elif is_vid:
|
||||
title = str(vn.flags.get("og_title_v") or "")
|
||||
ogh["og:type"] = "video.other"
|
||||
ogh["og:video"] = j2a["og_raw"]
|
||||
tagmap = {
|
||||
"title": "og:title",
|
||||
".dur": "og:video:duration",
|
||||
}
|
||||
elif is_pic:
|
||||
title = str(vn.flags.get("og_title_i") or "")
|
||||
ogh["twitter:card"] = "summary_large_image"
|
||||
ogh["twitter:image"] = ogh["og:image"] = j2a["og_raw"]
|
||||
|
||||
try:
|
||||
for k, v in file["tags"].items():
|
||||
zs = "{{ %s }}" % (k,)
|
||||
title = title.replace(zs, str(v))
|
||||
except:
|
||||
pass
|
||||
title = re.sub(r"\{\{ [^}]+ \}\}", "", title)
|
||||
while title.startswith(" - "):
|
||||
title = title[3:]
|
||||
while title.endswith(" - "):
|
||||
title = title[:3]
|
||||
|
||||
if vn.flags.get("og_s_title") or not title:
|
||||
title = str(vn.flags.get("og_title") or "")
|
||||
|
||||
for tag, hname in tagmap.items():
|
||||
try:
|
||||
v = file["tags"][tag]
|
||||
if not v:
|
||||
continue
|
||||
ogh[hname] = int(v) if tag == ".dur" else v
|
||||
except:
|
||||
pass
|
||||
|
||||
ogh["og:title"] = title
|
||||
|
||||
oghs = [
|
||||
'\t<meta property="%s" content="%s">'
|
||||
% (k, html_escape(str(v), True, True))
|
||||
for k, v in ogh.items()
|
||||
]
|
||||
zs = self.html_head + "\n%s\n" % ("\n".join(oghs),)
|
||||
self.html_head = zs.replace("\n\n", "\n")
|
||||
|
||||
html = self.j2s(tpl, **j2a)
|
||||
self.reply(html.encode("utf-8", "replace"))
|
||||
return True
|
||||
|
||||
@@ -179,7 +179,7 @@ class Metrics(object):
|
||||
tnbytes = 0
|
||||
tnfiles = 0
|
||||
for vpath, vol in allvols:
|
||||
cur = idx.get_cur(vol.realpath)
|
||||
cur = idx.get_cur(vol)
|
||||
if not cur:
|
||||
continue
|
||||
|
||||
|
||||
@@ -526,7 +526,7 @@ class SvcHub(object):
|
||||
al.exp_md = odfusion(exp, al.exp_md.replace(" ", ","))
|
||||
al.exp_lg = odfusion(exp, al.exp_lg.replace(" ", ","))
|
||||
|
||||
for k in ["no_hash", "no_idx"]:
|
||||
for k in ["no_hash", "no_idx", "og_ua"]:
|
||||
ptn = getattr(self.args, k)
|
||||
if ptn:
|
||||
setattr(self.args, k, re.compile(ptn))
|
||||
@@ -557,6 +557,10 @@ class SvcHub(object):
|
||||
except:
|
||||
raise Exception("invalid --mv-retry [%s]" % (self.args.mv_retry,))
|
||||
|
||||
al.tcolor = al.tcolor.lstrip("#")
|
||||
if len(al.tcolor) == 3: # fc5 => ffcc55
|
||||
al.tcolor = "".join([x * 2 for x in al.tcolor])
|
||||
|
||||
return True
|
||||
|
||||
def _ipa2re(self, txt) -> Optional[re.Pattern]:
|
||||
|
||||
@@ -463,6 +463,12 @@ class TcpSrv(object):
|
||||
sys.stderr.flush()
|
||||
|
||||
def _qr(self, t1: dict[str, list[int]], t2: dict[str, list[int]]) -> str:
|
||||
t2c = {zs: zli for zs, zli in t2.items() if zs in ("127.0.0.1", "::1")}
|
||||
t2b = {zs: zli for zs, zli in t2.items() if ":" in zs and zs not in t2c}
|
||||
t2 = {zs: zli for zs, zli in t2.items() if zs not in t2b and zs not in t2c}
|
||||
t2.update(t2b) # first ipv4, then ipv6...
|
||||
t2.update(t2c) # ...and finally localhost
|
||||
|
||||
ip = None
|
||||
ips = list(t1) + list(t2)
|
||||
qri = self.args.qri
|
||||
|
||||
@@ -62,6 +62,17 @@ class U2idx(object):
|
||||
def log(self, msg: str, c: Union[int, str] = 0) -> None:
|
||||
self.log_func("u2idx", msg, c)
|
||||
|
||||
def shutdown(self) -> None:
|
||||
for cur in self.cur.values():
|
||||
db = cur.connection
|
||||
try:
|
||||
db.interrupt()
|
||||
except:
|
||||
pass
|
||||
|
||||
cur.close()
|
||||
db.close()
|
||||
|
||||
def fsearch(
|
||||
self, uname: str, vols: list[VFS], body: dict[str, Any]
|
||||
) -> list[dict[str, Any]]:
|
||||
@@ -81,14 +92,18 @@ class U2idx(object):
|
||||
except:
|
||||
raise Pebkac(500, min_ex())
|
||||
|
||||
def get_cur(self, ptop: str) -> Optional["sqlite3.Cursor"]:
|
||||
def get_cur(self, vn: VFS) -> Optional["sqlite3.Cursor"]:
|
||||
if not HAVE_SQLITE3:
|
||||
return None
|
||||
|
||||
cur = self.cur.get(ptop)
|
||||
cur = self.cur.get(vn.realpath)
|
||||
if cur:
|
||||
return cur
|
||||
|
||||
if "e2d" not in vn.flags:
|
||||
return None
|
||||
|
||||
ptop = vn.realpath
|
||||
histpath = self.asrv.vfs.histtab.get(ptop)
|
||||
if not histpath:
|
||||
self.log("no histpath for [{}]".format(ptop))
|
||||
@@ -317,7 +332,7 @@ class U2idx(object):
|
||||
ptop = vol.realpath
|
||||
flags = vol.flags
|
||||
|
||||
cur = self.get_cur(ptop)
|
||||
cur = self.get_cur(vol)
|
||||
if not cur:
|
||||
continue
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ class Up2k(object):
|
||||
t = "could not initialize sqlite3, will use in-memory registry only"
|
||||
self.log(t, 3)
|
||||
|
||||
self.fstab = Fstab(self.log_func)
|
||||
self.fstab = Fstab(self.log_func, self.args)
|
||||
self.gen_fk = self._gen_fk if self.args.log_fk else gen_filekey
|
||||
|
||||
if self.args.hash_mt < 2:
|
||||
@@ -4379,6 +4379,18 @@ class Up2k(object):
|
||||
for x in list(self.spools):
|
||||
self._unspool(x)
|
||||
|
||||
for cur in self.cur.values():
|
||||
db = cur.connection
|
||||
try:
|
||||
db.interrupt()
|
||||
except:
|
||||
pass
|
||||
|
||||
cur.close()
|
||||
db.close()
|
||||
|
||||
self.registry = {}
|
||||
|
||||
|
||||
def up2k_chunksize(filesize: int) -> int:
|
||||
chunksize = 1024 * 1024
|
||||
|
||||
@@ -35,6 +35,9 @@ from .__init__ import ANYWIN, EXE, MACOS, PY2, TYPE_CHECKING, VT100, WINDOWS
|
||||
from .__version__ import S_BUILD_DT, S_VERSION
|
||||
from .stolen import surrogateescape
|
||||
|
||||
ub64dec = base64.urlsafe_b64decode
|
||||
ub64enc = base64.urlsafe_b64encode
|
||||
|
||||
try:
|
||||
from datetime import datetime, timezone
|
||||
|
||||
@@ -2031,6 +2034,7 @@ def vsplit(vpath: str) -> tuple[str, str]:
|
||||
return vpath.rsplit("/", 1) # type: ignore
|
||||
|
||||
|
||||
# vpath-join
|
||||
def vjoin(rd: str, fn: str) -> str:
|
||||
if rd and fn:
|
||||
return rd + "/" + fn
|
||||
@@ -2038,6 +2042,14 @@ def vjoin(rd: str, fn: str) -> str:
|
||||
return rd or fn
|
||||
|
||||
|
||||
# url-join
|
||||
def ujoin(rd: str, fn: str) -> str:
|
||||
if rd and fn:
|
||||
return rd.rstrip("/") + "/" + fn.lstrip("/")
|
||||
else:
|
||||
return rd or fn
|
||||
|
||||
|
||||
def _w8dec2(txt: bytes) -> str:
|
||||
"""decodes filesystem-bytes to wtf8"""
|
||||
return surrogateescape.decodefilename(txt)
|
||||
|
||||
@@ -740,6 +740,7 @@ window.baguetteBox = (function () {
|
||||
});
|
||||
image.setAttribute('src', imageSrc);
|
||||
if (is_vid) {
|
||||
image.volume = clamp(fcfg_get('vol', dvol / 100), 0, 1);
|
||||
image.setAttribute('controls', 'controls');
|
||||
image.onended = vidEnd;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
--row-alt: #282828;
|
||||
|
||||
--scroll: #eb0;
|
||||
--sel-fg: var(--bg-d1);
|
||||
--sel-bg: var(--fg);
|
||||
|
||||
--a: #fc5;
|
||||
--a-b: #c90;
|
||||
@@ -330,6 +332,8 @@ html.c {
|
||||
}
|
||||
html.cz {
|
||||
--bgg: var(--bg-u2);
|
||||
--sel-bg: var(--bg-u5);
|
||||
--sel-fg: var(--fg);
|
||||
--srv-3: #fff;
|
||||
--u2-tab-b1: var(--bg-d3);
|
||||
}
|
||||
@@ -343,6 +347,8 @@ html.cy {
|
||||
--bg-d3: #f77;
|
||||
--bg-d2: #ff0;
|
||||
|
||||
--sel-bg: #f77;
|
||||
|
||||
--a: #fff;
|
||||
--a-hil: #fff;
|
||||
--a-h-bg: #000;
|
||||
@@ -588,8 +594,8 @@ html.dy {
|
||||
line-height: 1.2em;
|
||||
}
|
||||
::selection {
|
||||
color: var(--bg-d1);
|
||||
background: var(--fg);
|
||||
color: var(--sel-fg);
|
||||
background: var(--sel-bg);
|
||||
text-shadow: none;
|
||||
}
|
||||
html,body,tr,th,td,#files,a {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<title>{{ title }}</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.8, minimum-scale=0.6">
|
||||
<meta name="theme-color" content="#333">
|
||||
<meta name="theme-color" content="#{{ tcolor }}">
|
||||
<link rel="stylesheet" media="screen" href="{{ r }}/.cpr/ui.css?_={{ ts }}">
|
||||
<link rel="stylesheet" media="screen" href="{{ r }}/.cpr/browser.css?_={{ ts }}">
|
||||
{{ html_head }}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
var XHR = XMLHttpRequest;
|
||||
var XHR = XMLHttpRequest,
|
||||
img_re = /\.(a?png|avif|bmp|gif|heif|jpe?g|jfif|svg|webp|webm|mkv|mp4)(\?|$)/i;
|
||||
|
||||
var Ls = {
|
||||
"eng": {
|
||||
"tt": "English",
|
||||
@@ -283,6 +285,7 @@ var Ls = {
|
||||
|
||||
"im_hnf": "that image no longer exists",
|
||||
|
||||
"f_empty": 'this folder is empty',
|
||||
"f_chide": 'this will hide the column «{0}»\n\nyou can unhide columns in the settings tab',
|
||||
"f_bigtxt": "this file is {0} MiB large -- really view as text?",
|
||||
"fbd_more": '<div id="blazy">showing <code>{0}</code> of <code>{1}</code> files; <a href="#" id="bd_more">show {2}</a> or <a href="#" id="bd_all">show all</a></div>',
|
||||
@@ -337,6 +340,9 @@ var Ls = {
|
||||
"fp_err": "move failed:\n",
|
||||
"fp_confirm": "move these {0} items here?",
|
||||
"fp_etab": 'failed to read clipboard from other browser tab',
|
||||
"fp_name": "uploading a file from your device. Give it a name:",
|
||||
"fp_both_m": '<h6>choose what to paste</h6><code>Enter</code> = Move {0} files from «{1}»\n<code>ESC</code> = Upload {2} files from your device',
|
||||
"fp_both_b": '<a href="#" id="modal-ok">Move</a><a href="#" id="modal-ng">Upload</a>',
|
||||
|
||||
"mk_noname": "type a name into the text field on the left before you do that :p",
|
||||
|
||||
@@ -788,6 +794,7 @@ var Ls = {
|
||||
|
||||
"im_hnf": "bildet finnes ikke lenger",
|
||||
|
||||
"f_empty": 'denne mappen er tom',
|
||||
"f_chide": 'dette vil skjule kolonnen «{0}»\n\nfanen for "andre innstillinger" lar deg vise kolonnen igjen',
|
||||
"f_bigtxt": "denne filen er hele {0} MiB -- vis som tekst?",
|
||||
"fbd_more": '<div id="blazy">viser <code>{0}</code> av <code>{1}</code> filer; <a href="#" id="bd_more">vis {2}</a> eller <a href="#" id="bd_all">vis alle</a></div>',
|
||||
@@ -842,6 +849,9 @@ var Ls = {
|
||||
"fp_err": "flytting feilet:\n",
|
||||
"fp_confirm": "flytt disse {0} filene hit?",
|
||||
"fp_etab": 'kunne ikke lese listen med filer ifra den andre nettleserfanen',
|
||||
"fp_name": "Laster opp én fil fra enheten din. Velg filnavn:",
|
||||
"fp_both_m": '<h6>hva skal limes inn her?</h6><code>Enter</code> = Flytt {0} filer fra «{1}»\n<code>ESC</code> = Last opp {2} filer fra enheten din',
|
||||
"fp_both_b": '<a href="#" id="modal-ok">Flytt</a><a href="#" id="modal-ng">Last opp</a>',
|
||||
|
||||
"mk_noname": "skriv inn et navn i tekstboksen til venstre først :p",
|
||||
|
||||
@@ -1413,6 +1423,12 @@ var ACtx = !IPHONE && (window.AudioContext || window.webkitAudioContext),
|
||||
dk, mp;
|
||||
|
||||
|
||||
if (window.og_fn) {
|
||||
hash0 = 1;
|
||||
hist_replace(vsplit(get_evpath())[0]);
|
||||
}
|
||||
|
||||
|
||||
var mpl = (function () {
|
||||
var have_mctl = 'mediaSession' in navigator && window.MediaMetadata;
|
||||
|
||||
@@ -1714,7 +1730,7 @@ function MPlayer() {
|
||||
}
|
||||
}
|
||||
|
||||
r.vol = clamp(fcfg_get('vol', IPHONE ? 1 : 0.5), 0, 1);
|
||||
r.vol = clamp(fcfg_get('vol', IPHONE ? 1 : dvol / 100), 0, 1);
|
||||
|
||||
r.expvol = function (v) {
|
||||
return 0.5 * v + 0.5 * v * v;
|
||||
@@ -3283,6 +3299,21 @@ function scan_hash(v) {
|
||||
function eval_hash() {
|
||||
window.onpopstate = treectl.onpopfun;
|
||||
|
||||
if (hash0 && window.og_fn) {
|
||||
var all = msel.getall(), mi;
|
||||
for (var a = 0; a < all.length; a++)
|
||||
if (og_fn == uricom_dec(vsplit(all[a].vp)[1].split('?')[0])) {
|
||||
mi = all[a];
|
||||
break;
|
||||
}
|
||||
|
||||
if (mi && img_re.exec(og_fn))
|
||||
hash0 = '#g' + mi.id;
|
||||
|
||||
if (ebi('a' + mi.id))
|
||||
hash0 = '#a' + mi.id;
|
||||
}
|
||||
|
||||
var v = hash0;
|
||||
hash0 = null;
|
||||
if (!v)
|
||||
@@ -3596,6 +3627,7 @@ var fileman = (function () {
|
||||
bdel = ebi('fdel'),
|
||||
bcut = ebi('fcut'),
|
||||
bpst = ebi('fpst'),
|
||||
t_paste,
|
||||
r = {};
|
||||
|
||||
r.clip = null;
|
||||
@@ -4073,8 +4105,73 @@ var fileman = (function () {
|
||||
}
|
||||
};
|
||||
|
||||
r.paste = function (e) {
|
||||
ev(e);
|
||||
document.onpaste = function (e) {
|
||||
var xfer = e.clipboardData || window.clipboardData;
|
||||
if (!xfer || !xfer.files || !xfer.files.length)
|
||||
return;
|
||||
|
||||
var files = [];
|
||||
for (var a = 0, aa = xfer.files.length; a < aa; a++)
|
||||
files.push(xfer.files[a]);
|
||||
|
||||
clearTimeout(t_paste);
|
||||
|
||||
if (!r.clip.length)
|
||||
return r.clip_up(files);
|
||||
|
||||
var src = r.clip.length == 1 ? r.clip[0] : vsplit(r.clip[0])[0],
|
||||
msg = L.fp_both_m.format(r.clip.length, src, files.length);
|
||||
|
||||
modal.confirm(msg, r.paste, function () { r.clip_up(files); }, null, L.fp_both_b);
|
||||
};
|
||||
|
||||
r.clip_up = function (files) {
|
||||
goto_up2k();
|
||||
var good = [], nil = [], bad = [];
|
||||
for (var a = 0, aa = files.length; a < aa; a++) {
|
||||
var fobj = files[a], dst = good;
|
||||
try {
|
||||
if (fobj.size < 1)
|
||||
dst = nil;
|
||||
}
|
||||
catch (ex) {
|
||||
dst = bad;
|
||||
}
|
||||
dst.push([fobj, fobj.name]);
|
||||
}
|
||||
var doit = function (is_img) {
|
||||
jwrite('fman_clip', [Date.now()]);
|
||||
r.clip = [];
|
||||
|
||||
var x = up2k.uc.ask_up;
|
||||
if (is_img)
|
||||
up2k.uc.ask_up = false;
|
||||
|
||||
up2k.gotallfiles[0](good, nil, bad, up2k.gotallfiles.slice(1));
|
||||
up2k.uc.ask_up = x;
|
||||
};
|
||||
if (good.length != 1)
|
||||
return doit();
|
||||
|
||||
var fn = good[0][1],
|
||||
ofs = fn.lastIndexOf('.');
|
||||
|
||||
// stop linux-chrome from adding the fs-path into the <input>
|
||||
setTimeout(function () {
|
||||
modal.prompt(L.fp_name, fn, function (v) {
|
||||
good[0][1] = v;
|
||||
doit(true);
|
||||
}, null, null, 0, ofs > 0 ? ofs : undefined);
|
||||
}, 1);
|
||||
};
|
||||
|
||||
r.d_paste = function () {
|
||||
// gets called before onpaste; defer
|
||||
clearTimeout(t_paste);
|
||||
t_paste = setTimeout(r.paste, 50);
|
||||
};
|
||||
|
||||
r.paste = function () {
|
||||
if (clgot(bpst, 'hide'))
|
||||
return toast.err(3, L.fp_eperm);
|
||||
|
||||
@@ -4684,7 +4781,7 @@ var thegrid = (function () {
|
||||
aplay = ebi('a' + fid),
|
||||
atext = ebi('t' + fid),
|
||||
is_txt = atext && showfile.getlang(href),
|
||||
is_img = /\.(a?png|avif|bmp|gif|heif|jpe?g|jfif|svg|webp|webm|mkv|mp4)(\?|$)/i.test(href),
|
||||
is_img = img_re.test(href),
|
||||
is_dir = href.endsWith('/'),
|
||||
is_srch = !!ebi('unsearch'),
|
||||
in_tree = is_dir && treectl.find(oth.textContent.slice(0, -1)),
|
||||
@@ -5178,6 +5275,9 @@ document.onkeydown = function (e) {
|
||||
if (ebi('hkhelp'))
|
||||
return qsr('#hkhelp');
|
||||
|
||||
if (toast.visible)
|
||||
return toast.hide();
|
||||
|
||||
if (ebi('rn_cancel'))
|
||||
return ebi('rn_cancel').click();
|
||||
|
||||
@@ -5250,7 +5350,7 @@ document.onkeydown = function (e) {
|
||||
return fileman.cut();
|
||||
|
||||
if (k == 'KeyV' || k == 'v')
|
||||
return fileman.paste();
|
||||
return fileman.d_paste();
|
||||
|
||||
if (k == 'KeyK' || k == 'k')
|
||||
return fileman.delete();
|
||||
@@ -6286,6 +6386,9 @@ var treectl = (function () {
|
||||
lg1 = res.logues ? res.logues[1] || "" : "",
|
||||
dirchg = get_evpath() != cdir;
|
||||
|
||||
if (lg1 === Ls.eng.f_empty)
|
||||
lg1 = L.f_empty;
|
||||
|
||||
sandbox(ebi('pro'), sb_lg, '', lg0);
|
||||
if (dirchg)
|
||||
sandbox(ebi('epi'), sb_lg, '', lg1);
|
||||
@@ -7923,6 +8026,9 @@ window.addEventListener("message", function (e) {
|
||||
|
||||
|
||||
if (sb_lg && logues.length) {
|
||||
if (logues[1] === Ls.eng.f_empty)
|
||||
logues[1] = L.f_empty;
|
||||
|
||||
sandbox(ebi('pro'), sb_lg, '', logues[0]);
|
||||
sandbox(ebi('epi'), sb_lg, '', logues[1]);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<title>📝 {{ title }}</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.7">
|
||||
<meta name="theme-color" content="#333">
|
||||
<meta name="theme-color" content="#{{ tcolor }}">
|
||||
<link rel="stylesheet" href="{{ r }}/.cpr/ui.css?_={{ ts }}">
|
||||
<link rel="stylesheet" href="{{ r }}/.cpr/md.css?_={{ ts }}">
|
||||
{%- if edit %}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<title>📝 {{ title }}</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.7">
|
||||
<meta name="theme-color" content="#333">
|
||||
<meta name="theme-color" content="#{{ tcolor }}">
|
||||
<link rel="stylesheet" href="{{ r }}/.cpr/ui.css?_={{ ts }}">
|
||||
<link rel="stylesheet" href="{{ r }}/.cpr/mde.css?_={{ ts }}">
|
||||
<link rel="stylesheet" href="{{ r }}/.cpr/deps/mini-fa.css?_={{ ts }}">
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<title>{{ s_doctitle }}</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.8">
|
||||
<meta name="theme-color" content="#333">
|
||||
<meta name="theme-color" content="#{{ tcolor }}">
|
||||
<link rel="stylesheet" media="screen" href="{{ r }}/.cpr/msg.css?_={{ ts }}">
|
||||
{{ html_head }}
|
||||
</head>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<title>{{ s_doctitle }}</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.8">
|
||||
<meta name="theme-color" content="#333">
|
||||
<meta name="theme-color" content="#{{ tcolor }}">
|
||||
<link rel="stylesheet" media="screen" href="{{ r }}/.cpr/splash.css?_={{ ts }}">
|
||||
<link rel="stylesheet" media="screen" href="{{ r }}/.cpr/ui.css?_={{ ts }}">
|
||||
{{ html_head }}
|
||||
@@ -95,6 +95,7 @@
|
||||
<form method="post" enctype="multipart/form-data" action="{{ r }}/{{ qvpath }}">
|
||||
<input type="hidden" name="act" value="login" />
|
||||
<input type="password" name="cppwd" placeholder=" password" />
|
||||
<input type="hidden" name="uhash" id="uhash" value="x" />
|
||||
<input type="submit" value="Login" />
|
||||
{% if ahttps %}
|
||||
<a id="w" href="{{ ahttps }}">switch to https</a>
|
||||
|
||||
@@ -66,3 +66,5 @@ if (!ebi('c') && o.offsetTop + o.offsetHeight < window.innerHeight)
|
||||
o = ebi('u');
|
||||
if (o && /[0-9]+$/.exec(o.innerHTML))
|
||||
o.innerHTML = shumantime(o.innerHTML);
|
||||
|
||||
ebi('uhash').value = '' + location.hash;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<title>{{ s_doctitle }}</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.8">
|
||||
<meta name="theme-color" content="#333">
|
||||
<meta name="theme-color" content="#{{ tcolor }}">
|
||||
<link rel="stylesheet" media="screen" href="{{ r }}/.cpr/splash.css?_={{ ts }}">
|
||||
<link rel="stylesheet" media="screen" href="{{ r }}/.cpr/ui.css?_={{ ts }}">
|
||||
<style>ul{padding-left:1.3em}li{margin:.4em 0}</style>
|
||||
|
||||
@@ -1539,6 +1539,8 @@ var modal = (function () {
|
||||
cb_up = null,
|
||||
cb_ok = null,
|
||||
cb_ng = null,
|
||||
sel_0 = 0,
|
||||
sel_1 = 0,
|
||||
tok, tng, prim, sec, ok_cancel;
|
||||
|
||||
r.load = function () {
|
||||
@@ -1572,7 +1574,7 @@ var modal = (function () {
|
||||
(inp || a).focus();
|
||||
if (inp)
|
||||
setTimeout(function () {
|
||||
inp.setSelectionRange(0, inp.value.length, "forward");
|
||||
inp.setSelectionRange(sel_0, sel_1, "forward");
|
||||
}, 0);
|
||||
|
||||
document.addEventListener('focus', onfocus);
|
||||
@@ -1695,16 +1697,18 @@ var modal = (function () {
|
||||
r.show(html);
|
||||
}
|
||||
|
||||
r.prompt = function (html, v, cok, cng, fun) {
|
||||
r.prompt = function (html, v, cok, cng, fun, so0, so1) {
|
||||
q.push(function () {
|
||||
_prompt(lf2br(html), v, cok, cng, fun);
|
||||
_prompt(lf2br(html), v, cok, cng, fun, so0, so1);
|
||||
});
|
||||
next();
|
||||
}
|
||||
var _prompt = function (html, v, cok, cng, fun) {
|
||||
var _prompt = function (html, v, cok, cng, fun, so0, so1) {
|
||||
cb_ok = cok;
|
||||
cb_ng = cng === undefined ? cok : null;
|
||||
cb_up = fun;
|
||||
sel_0 = so0 || 0;
|
||||
sel_1 = so1 === undefined ? v.length : so1;
|
||||
html += '<input id="modali" type="text" ' + NOAC + ' /><div id="modalb">' + ok_cancel + '</div>';
|
||||
r.show(html);
|
||||
|
||||
|
||||
@@ -47,3 +47,11 @@ and if you want to have a monospace font in the fancy markdown editor, do this:
|
||||
|
||||
NB: `<textarea id="mt">` and `<div id="mtr">` in the regular markdown editor must have the same font; none of the suggestions above will cause any issues but keep it in mind if you're getting creative
|
||||
|
||||
|
||||
# `<head>`
|
||||
|
||||
to add stuff to the html `<head>`, for example a css `<link>` or `<meta>` tags, use either the global-option `--html-head` or the volflag `html_head`
|
||||
|
||||
if you give it the value `@ASDF` it will try to open a file named ASDF and send the text within
|
||||
|
||||
if the value starts with `%` it will assume a jinja2 template and expand it; the template has access to the `HttpCli` object through a property named `this` as well as everything in `j2a` and the stuff added by `self.j2s`; see [browser.html](https://github.com/9001/copyparty/blob/hovudstraum/copyparty/web/browser.html) for inspiration or look under the hood in [httpcli.py](https://github.com/9001/copyparty/blob/hovudstraum/copyparty/httpcli.py)
|
||||
|
||||
61
scripts/make-pyz.sh
Executable file
61
scripts/make-pyz.sh
Executable file
@@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
echo
|
||||
|
||||
# port install gnutar gsed coreutils
|
||||
gtar=$(command -v gtar || command -v gnutar) || true
|
||||
[ ! -z "$gtar" ] && command -v gsed >/dev/null && {
|
||||
tar() { $gtar "$@"; }
|
||||
sed() { gsed "$@"; }
|
||||
command -v grealpath >/dev/null &&
|
||||
realpath() { grealpath "$@"; }
|
||||
}
|
||||
|
||||
targs=(--owner=1000 --group=1000)
|
||||
[ "$OSTYPE" = msys ] &&
|
||||
targs=()
|
||||
|
||||
[ -e copyparty/__main__.py ] || cd ..
|
||||
[ -e copyparty/__main__.py ] || {
|
||||
echo "run me from within the project root folder"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ -e sfx/copyparty/__main__.py ] || {
|
||||
echo "run ./scripts/make-sfx.py first"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
rm -rf pyz
|
||||
mkdir -p pyz
|
||||
cd pyz
|
||||
|
||||
cp -pR ../sfx/{copyparty,partftpy} .
|
||||
cp -pR ../sfx/{ftp,j2}/* .
|
||||
|
||||
ts=$(date -u +%s)
|
||||
hts=$(date -u +%Y-%m%d-%H%M%S)
|
||||
ver="$(cat ../sfx/ver)"
|
||||
|
||||
mkdir -p ../dist
|
||||
pyz_out=../dist/copyparty.pyz
|
||||
|
||||
echo creating z.tar
|
||||
( cd copyparty
|
||||
tar -cf z.tar "${targs[@]}" --numeric-owner web res
|
||||
rm -rf web res
|
||||
)
|
||||
|
||||
echo creating loader
|
||||
sed -r 's/^(VER = ).*/\1"'"$ver"'"/; s/^(STAMP = ).*/\1'$(date +%s)/ \
|
||||
<../scripts/ziploader.py \
|
||||
>__main__.py
|
||||
|
||||
echo creating pyz
|
||||
rm -f $pyz_out
|
||||
zip -9 -q -r $pyz_out *
|
||||
|
||||
echo done:
|
||||
echo " $(realpath $pyz_out)"
|
||||
@@ -99,9 +99,6 @@ pybin=$(command -v python3 || command -v python) || {
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ $CSN ] ||
|
||||
CSN=sfx
|
||||
|
||||
langs=
|
||||
use_gz=
|
||||
zopf=2560
|
||||
@@ -148,9 +145,9 @@ stamp=$(
|
||||
done | sort | tail -n 1 | sha1sum | cut -c-16
|
||||
)
|
||||
|
||||
rm -rf $CSN/*
|
||||
mkdir -p $CSN build
|
||||
cd $CSN
|
||||
rm -rf sfx$CSN/*
|
||||
mkdir -p sfx$CSN build
|
||||
cd sfx$CSN
|
||||
|
||||
tmpdir="$(
|
||||
printf '%s\n' "$TMPDIR" /tmp |
|
||||
@@ -386,11 +383,13 @@ git describe --tags >/dev/null 2>/dev/null && {
|
||||
ver="$(awk '/^VERSION *= \(/ {
|
||||
gsub(/[^0-9,a-g-]/,""); gsub(/,/,"."); print; exit}' < copyparty/__version__.py)"
|
||||
|
||||
echo "$ver" >ver # pyz
|
||||
|
||||
ts=$(date -u +%s)
|
||||
hts=$(date -u +%Y-%m%d-%H%M%S) # --date=@$ts (thx osx)
|
||||
|
||||
mkdir -p ../dist
|
||||
sfx_out=../dist/copyparty-$CSN
|
||||
sfx_out=../dist/copyparty-sfx$CSN
|
||||
|
||||
echo cleanup
|
||||
find -name '*.pyc' -delete
|
||||
@@ -542,7 +541,7 @@ gzres() {
|
||||
}
|
||||
|
||||
|
||||
zdir="$tmpdir/cpp-mk$CSN"
|
||||
zdir="$tmpdir/cpp-mksfx$CSN"
|
||||
[ -e "$zdir/$stamp" ] || rm -rf "$zdir"
|
||||
mkdir -p "$zdir"
|
||||
echo a > "$zdir/$stamp"
|
||||
|
||||
@@ -42,7 +42,7 @@ $f$s.py --version >/dev/null
|
||||
min=99999999
|
||||
for ((a=0; a<$parallel; a++)); do
|
||||
while [ -e .sfx-run ]; do
|
||||
CSN=sfx$a ./make-sfx.sh re "$@"
|
||||
CSN=$a ./make-sfx.sh re "$@"
|
||||
sz=$(wc -c <$f$a$s.py | awk '{print$1}')
|
||||
[ $sz -ge $min ] && continue
|
||||
mv $f$a$s.py $f$s.py.$sz
|
||||
|
||||
@@ -1,6 +1,21 @@
|
||||
#!/bin/bash
|
||||
set -ex
|
||||
|
||||
if uname | grep -iE '^(msys|mingw)'; then
|
||||
pids=()
|
||||
|
||||
python -m unittest discover -s tests >/dev/null &
|
||||
pids+=($!)
|
||||
|
||||
python scripts/test/smoketest.py &
|
||||
pids+=($!)
|
||||
|
||||
for pid in ${pids[@]}; do
|
||||
wait $pid
|
||||
done
|
||||
exit $?
|
||||
fi
|
||||
|
||||
# osx support
|
||||
gtar=$(command -v gtar || command -v gnutar) || true
|
||||
[ ! -z "$gtar" ] && command -v gfind >/dev/null && {
|
||||
|
||||
112
scripts/ziploader.py
Normal file
112
scripts/ziploader.py
Normal file
@@ -0,0 +1,112 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import atexit
|
||||
import os
|
||||
import platform
|
||||
import sys
|
||||
import tarfile
|
||||
import tempfile
|
||||
import threading
|
||||
import time
|
||||
import traceback
|
||||
|
||||
|
||||
VER = None
|
||||
STAMP = None
|
||||
WINDOWS = sys.platform in ["win32", "msys"]
|
||||
|
||||
|
||||
def msg(*a, **ka):
|
||||
if a:
|
||||
a = ["[ZIP]", a[0]] + list(a[1:])
|
||||
|
||||
ka["file"] = sys.stderr
|
||||
print(*a, **ka)
|
||||
|
||||
|
||||
def utime(top):
|
||||
# avoid cleaners
|
||||
files = [os.path.join(dp, p) for dp, dd, df in os.walk(top) for p in dd + df]
|
||||
try:
|
||||
while True:
|
||||
t = int(time.time())
|
||||
for f in [top] + files:
|
||||
os.utime(f, (t, t))
|
||||
|
||||
time.sleep(78123)
|
||||
except Exception as ex:
|
||||
print("utime:", ex, f)
|
||||
|
||||
|
||||
def confirm(rv):
|
||||
msg()
|
||||
msg("retcode", rv if rv else traceback.format_exc())
|
||||
if WINDOWS:
|
||||
msg("*** hit enter to exit ***")
|
||||
try:
|
||||
input()
|
||||
except:
|
||||
pass
|
||||
|
||||
sys.exit(rv or 1)
|
||||
|
||||
|
||||
def run():
|
||||
import copyparty
|
||||
from copyparty.__main__ import main as cm
|
||||
|
||||
td = tempfile.TemporaryDirectory(prefix="")
|
||||
atexit.register(td.cleanup)
|
||||
rsrc = td.name
|
||||
|
||||
try:
|
||||
from importlib.resources import files
|
||||
|
||||
f = files(copyparty).joinpath("z.tar").open("rb")
|
||||
except:
|
||||
from importlib.resources import open_binary
|
||||
|
||||
f = open_binary("copyparty", "z.tar")
|
||||
|
||||
with tarfile.open(fileobj=f) as tf:
|
||||
try:
|
||||
tf.extractall(rsrc, filter="tar")
|
||||
except TypeError:
|
||||
tf.extractall(rsrc) # nosec (archive is safe)
|
||||
|
||||
f.close()
|
||||
f = None
|
||||
|
||||
msg(" rsrc dir:", rsrc)
|
||||
msg()
|
||||
|
||||
t = threading.Thread(target=utime, args=(rsrc,))
|
||||
t.daemon = True
|
||||
t.start()
|
||||
|
||||
cm(rsrc=rsrc)
|
||||
|
||||
|
||||
def main():
|
||||
sysver = str(sys.version).replace("\n", "\n" + " " * 18)
|
||||
pktime = time.strftime("%Y-%m-%d, %H:%M:%S", time.gmtime(STAMP))
|
||||
msg()
|
||||
msg(" this is: copyparty", VER)
|
||||
msg(" packed at:", pktime, "UTC,", STAMP)
|
||||
msg("python bin:", sys.executable)
|
||||
msg("python ver:", platform.python_implementation(), sysver)
|
||||
|
||||
try:
|
||||
run()
|
||||
except SystemExit as ex:
|
||||
c = ex.code
|
||||
if c not in [0, -15]:
|
||||
confirm(ex.code)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except:
|
||||
confirm(0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -80,7 +80,8 @@ class TestHttpCli(unittest.TestCase):
|
||||
x = " ".join(sorted([x["rp"] for x in x[0]]))
|
||||
self.assertEqual(x, ".f0 .t/.f2 .t/f2 a/da/f4 a/f3 f0 t/.f1 t/f1")
|
||||
|
||||
self.args = Cfg(v=vcfg, a=["u1:u1", "u2:u2"], dotsrch=False)
|
||||
u2idx.shutdown()
|
||||
self.args = Cfg(v=vcfg, a=["u1:u1", "u2:u2"], dotsrch=False, e2d=True)
|
||||
self.asrv = AuthSrv(self.args, self.log)
|
||||
u2idx = U2idx(self)
|
||||
|
||||
@@ -89,6 +90,8 @@ class TestHttpCli(unittest.TestCase):
|
||||
# u1 can see dotfiles in volB so they should be included
|
||||
xe = "a/da/f4 a/f3 f0 t/f1"
|
||||
self.assertEqual(x, xe)
|
||||
u2idx.shutdown()
|
||||
up2k.shutdown()
|
||||
|
||||
##
|
||||
## dirkeys
|
||||
@@ -147,4 +150,4 @@ class TestHttpCli(unittest.TestCase):
|
||||
return conn.s._reply.decode("utf-8").split("\r\n\r\n", 1)
|
||||
|
||||
def log(self, src, msg, c=0):
|
||||
print(msg)
|
||||
print(msg, "\033[0m")
|
||||
|
||||
@@ -6,6 +6,7 @@ import json
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from copyparty.__init__ import ANYWIN
|
||||
from copyparty.authsrv import AuthSrv
|
||||
from tests.util import Cfg
|
||||
|
||||
@@ -51,6 +52,12 @@ class TestVFS(unittest.TestCase):
|
||||
vn = self.nav(au, vp)
|
||||
self.assertNodes(vn, expected)
|
||||
|
||||
def assertApEq(self, ap, rhs):
|
||||
if ANYWIN and len(ap) > 2 and ap[1] == ":":
|
||||
ap = ap[2:].replace("\\", "/")
|
||||
|
||||
return self.assertEqual(ap, rhs)
|
||||
|
||||
def prep(self):
|
||||
here = os.path.abspath(os.path.dirname(__file__))
|
||||
cfgdir = os.path.join(here, "res", "idp")
|
||||
@@ -70,7 +77,7 @@ class TestVFS(unittest.TestCase):
|
||||
au = AuthSrv(Cfg(c=[cfgdir + "/1.conf"], **xcfg), self.log)
|
||||
|
||||
self.assertEqual(au.vfs.vpath, "")
|
||||
self.assertEqual(au.vfs.realpath, "/")
|
||||
self.assertApEq(au.vfs.realpath, "/")
|
||||
self.assertNodes(au.vfs, ["vb"])
|
||||
self.assertNodes(au.vfs.nodes["vb"], [])
|
||||
|
||||
@@ -85,7 +92,7 @@ class TestVFS(unittest.TestCase):
|
||||
au = AuthSrv(Cfg(c=[cfgdir + "/2.conf"], **xcfg), self.log)
|
||||
|
||||
self.assertEqual(au.vfs.vpath, "")
|
||||
self.assertEqual(au.vfs.realpath, "/")
|
||||
self.assertApEq(au.vfs.realpath, "/")
|
||||
self.assertNodes(au.vfs, ["vb", "vc"])
|
||||
self.assertNodes(au.vfs.nodes["vb"], [])
|
||||
self.assertNodes(au.vfs.nodes["vc"], [])
|
||||
@@ -103,7 +110,7 @@ class TestVFS(unittest.TestCase):
|
||||
au = AuthSrv(Cfg(c=[cfgdir + "/3.conf"], **xcfg), self.log)
|
||||
|
||||
self.assertEqual(au.vfs.vpath, "")
|
||||
self.assertEqual(au.vfs.realpath, "")
|
||||
self.assertApEq(au.vfs.realpath, "")
|
||||
self.assertNodes(au.vfs, [])
|
||||
self.assertAxs(au.vfs.axs, [])
|
||||
|
||||
@@ -112,8 +119,8 @@ class TestVFS(unittest.TestCase):
|
||||
self.assertNodesAt(au, "vu", ["iua"]) # same as:
|
||||
self.assertNodes(au.vfs.nodes["vu"], ["iua"])
|
||||
self.assertNodes(au.vfs.nodes["vg"], ["iga"])
|
||||
self.assertEqual(au.vfs.nodes["vu"].realpath, "")
|
||||
self.assertEqual(au.vfs.nodes["vg"].realpath, "")
|
||||
self.assertApEq(au.vfs.nodes["vu"].realpath, "")
|
||||
self.assertApEq(au.vfs.nodes["vg"].realpath, "")
|
||||
self.assertAxs(au.vfs.axs, [])
|
||||
self.assertAxsAt(au, "vu/iua", [["iua"]]) # same as:
|
||||
self.assertAxs(self.nav(au, "vu/iua").axs, [["iua"]])
|
||||
@@ -127,7 +134,7 @@ class TestVFS(unittest.TestCase):
|
||||
au = AuthSrv(Cfg(c=[cfgdir + "/4.conf"], **xcfg), self.log)
|
||||
|
||||
self.assertEqual(au.vfs.vpath, "")
|
||||
self.assertEqual(au.vfs.realpath, "")
|
||||
self.assertApEq(au.vfs.realpath, "")
|
||||
self.assertNodes(au.vfs, ["vu"])
|
||||
self.assertNodesAt(au, "vu", ["ua", "ub"])
|
||||
self.assertAxs(au.vfs.axs, [])
|
||||
@@ -147,10 +154,10 @@ class TestVFS(unittest.TestCase):
|
||||
self.assertAxsAt(au, "vg", [])
|
||||
self.assertAxsAt(au, "vg/iga1", [["iua"]])
|
||||
self.assertAxsAt(au, "vg/iga2", [["iua", "ua"]])
|
||||
self.assertEqual(self.nav(au, "vu/ua").realpath, "/u-ua")
|
||||
self.assertEqual(self.nav(au, "vu/iua").realpath, "/u-iua")
|
||||
self.assertEqual(self.nav(au, "vg/iga1").realpath, "/g1-iga")
|
||||
self.assertEqual(self.nav(au, "vg/iga2").realpath, "/g2-iga")
|
||||
self.assertApEq(self.nav(au, "vu/ua").realpath, "/u-ua")
|
||||
self.assertApEq(self.nav(au, "vu/iua").realpath, "/u-iua")
|
||||
self.assertApEq(self.nav(au, "vg/iga1").realpath, "/g1-iga")
|
||||
self.assertApEq(self.nav(au, "vg/iga2").realpath, "/g2-iga")
|
||||
|
||||
au.idp_checkin(None, "iub", "iga")
|
||||
self.assertAxsAt(au, "vu/iua", [["iua"]])
|
||||
@@ -165,7 +172,7 @@ class TestVFS(unittest.TestCase):
|
||||
au = AuthSrv(Cfg(c=[cfgdir + "/5.conf"], **xcfg), self.log)
|
||||
|
||||
self.assertEqual(au.vfs.vpath, "")
|
||||
self.assertEqual(au.vfs.realpath, "")
|
||||
self.assertApEq(au.vfs.realpath, "")
|
||||
self.assertNodes(au.vfs, ["g", "ga", "gb"])
|
||||
self.assertAxs(au.vfs.axs, [])
|
||||
|
||||
@@ -196,7 +203,7 @@ class TestVFS(unittest.TestCase):
|
||||
|
||||
self.assertAxs(au.vfs.axs, [])
|
||||
self.assertEqual(au.vfs.vpath, "")
|
||||
self.assertEqual(au.vfs.realpath, "")
|
||||
self.assertApEq(au.vfs.realpath, "")
|
||||
self.assertNodes(au.vfs, [])
|
||||
|
||||
au.idp_checkin(None, "iua", "")
|
||||
|
||||
@@ -110,25 +110,25 @@ class Cfg(Namespace):
|
||||
def __init__(self, a=None, v=None, c=None, **ka0):
|
||||
ka = {}
|
||||
|
||||
ex = "daw dav_auth dav_inf dav_mac dav_rt e2d e2ds e2dsa e2t e2ts e2tsr e2v e2vu e2vp early_ban ed emp exp force_js getmod grid hardlink ih ihead magic never_symlink nid nih no_acode no_athumb no_dav no_dedup no_del no_dupe no_lifetime no_logues no_mv no_pipe no_readme no_robots no_sb_md no_sb_lg no_scandir no_tarcmp no_thumb no_vthumb no_zip nrand nw q rand smb srch_dbg stats vague_403 vc ver xdev xlink xvol"
|
||||
ex = "daw dav_auth dav_inf dav_mac dav_rt e2d e2ds e2dsa e2t e2ts e2tsr e2v e2vu e2vp early_ban ed emp exp force_js getmod grid hardlink ih ihead magic never_symlink nid nih no_acode no_athumb no_dav no_dedup no_del no_dupe no_lifetime no_logues no_mv no_pipe no_readme no_robots no_sb_md no_sb_lg no_scandir no_tarcmp no_thumb no_vthumb no_zip nrand nw og og_no_head og_s_title q rand smb srch_dbg stats uqe vague_403 vc ver xdev xlink xvol"
|
||||
ka.update(**{k: False for k in ex.split()})
|
||||
|
||||
ex = "dotpart dotsrch no_dhash no_fastboot no_rescan no_sendfile no_voldump re_dhash plain_ip"
|
||||
ex = "dotpart dotsrch no_dhash no_fastboot no_rescan no_sendfile no_snap no_voldump re_dhash plain_ip"
|
||||
ka.update(**{k: True for k in ex.split()})
|
||||
|
||||
ex = "ah_cli ah_gen css_browser hist js_browser no_forget no_hash no_idx nonsus_urls"
|
||||
ex = "ah_cli ah_gen css_browser hist js_browser no_forget no_hash no_idx nonsus_urls og_tpl og_ua"
|
||||
ka.update(**{k: None for k in ex.split()})
|
||||
|
||||
ex = "hash_mt srch_time u2abort u2j"
|
||||
ka.update(**{k: 1 for k in ex.split()})
|
||||
|
||||
ex = "reg_cap s_thead s_tbody th_convt"
|
||||
ex = "au_vol mtab_age reg_cap s_thead s_tbody th_convt"
|
||||
ka.update(**{k: 9 for k in ex.split()})
|
||||
|
||||
ex = "db_act df k304 loris re_maxage rproxy rsp_jtr rsp_slp s_wr_slp snap_wri theme themes turbo"
|
||||
ka.update(**{k: 0 for k in ex.split()})
|
||||
|
||||
ex = "ah_alg bname doctitle exit favico idp_h_usr html_head lg_sbf log_fk md_sbf name textfiles unlist vname R RS SR"
|
||||
ex = "ah_alg bname doctitle exit favico idp_h_usr html_head lg_sbf log_fk md_sbf name og_desc og_site og_th og_title og_title_a og_title_v og_title_i tcolor textfiles unlist vname R RS SR"
|
||||
ka.update(**{k: "" for k in ex.split()})
|
||||
|
||||
ex = "grp on403 on404 xad xar xau xban xbd xbr xbu xiu xm"
|
||||
@@ -260,3 +260,7 @@ class VHttpConn(object):
|
||||
self.u2fh = FHC()
|
||||
|
||||
self.get_u2idx = self.hsrv.get_u2idx
|
||||
|
||||
|
||||
if WINDOWS:
|
||||
os.system("rem")
|
||||
|
||||
Reference in New Issue
Block a user