mirror of
https://github.com/9001/copyparty.git
synced 2025-11-04 13:53:18 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c03c65e07 | ||
|
|
d8ed006b9b | ||
|
|
63c0623a5e | ||
|
|
fd84506db0 | ||
|
|
d8bcb44e44 | ||
|
|
56a26b0916 | ||
|
|
efcf1d6b90 |
7
.vscode/launch.json
vendored
7
.vscode/launch.json
vendored
@@ -20,6 +20,13 @@
|
|||||||
"srv::r:aed:cnodupe"
|
"srv::r:aed:cnodupe"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "No debug",
|
||||||
|
"preLaunchTask": "no_dbg",
|
||||||
|
"type": "python",
|
||||||
|
//"request": "attach", "port": 42069
|
||||||
|
// fork: nc -l 42069 </dev/null
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Run active unit test",
|
"name": "Run active unit test",
|
||||||
"type": "python",
|
"type": "python",
|
||||||
|
|||||||
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
@@ -50,15 +50,9 @@
|
|||||||
"files.associations": {
|
"files.associations": {
|
||||||
"*.makefile": "makefile"
|
"*.makefile": "makefile"
|
||||||
},
|
},
|
||||||
"editor.codeActionsOnSaveTimeout": 9001,
|
|
||||||
"editor.formatOnSaveTimeout": 9001,
|
|
||||||
//
|
|
||||||
// things you may wanna edit:
|
|
||||||
//
|
|
||||||
"python.pythonPath": "/usr/bin/python3",
|
|
||||||
"python.formatting.blackArgs": [
|
"python.formatting.blackArgs": [
|
||||||
"-t",
|
"-t",
|
||||||
"py27"
|
"py27"
|
||||||
],
|
],
|
||||||
//"python.linting.enabled": true,
|
"python.linting.enabled": true,
|
||||||
}
|
}
|
||||||
5
.vscode/tasks.json
vendored
5
.vscode/tasks.json
vendored
@@ -5,6 +5,11 @@
|
|||||||
"label": "pre",
|
"label": "pre",
|
||||||
"command": "true;rm -rf inc/* inc/.hist/;mkdir -p inc;",
|
"command": "true;rm -rf inc/* inc/.hist/;mkdir -p inc;",
|
||||||
"type": "shell"
|
"type": "shell"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "no_dbg",
|
||||||
|
"command": "${config:python.pythonPath} -m copyparty -ed -emp -e2d -e2s -a ed:wark -v srv::r:aed:cnodupe ;exit 1",
|
||||||
|
"type": "shell"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -76,8 +76,8 @@ optional, will eventually enable thumbnails:
|
|||||||
# sfx
|
# sfx
|
||||||
|
|
||||||
currently there are two self-contained binaries:
|
currently there are two self-contained binaries:
|
||||||
* `copyparty-sfx.sh` for unix (linux and osx) -- smaller, more robust
|
* [copyparty-sfx.py](https://github.com/9001/copyparty/releases/latest/download/copyparty-sfx.py) -- pure python, works everywhere
|
||||||
* `copyparty-sfx.py` for windows (unix too) -- crossplatform, beta
|
* [copyparty-sfx.sh](https://github.com/9001/copyparty/releases/latest/download/copyparty-sfx.sh) -- smaller, but only for linux and macos
|
||||||
|
|
||||||
launch either of them (**use sfx.py on systemd**) and it'll unpack and run copyparty, assuming you have python installed of course
|
launch either of them (**use sfx.py on systemd**) and it'll unpack and run copyparty, assuming you have python installed of course
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,12 @@
|
|||||||
* modify `10.13.1.1` as necessary if you wish to support browsers without javascript
|
* modify `10.13.1.1` as necessary if you wish to support browsers without javascript
|
||||||
|
|
||||||
### [`explorer-nothumbs-nofoldertypes.reg`](explorer-nothumbs-nofoldertypes.reg)
|
### [`explorer-nothumbs-nofoldertypes.reg`](explorer-nothumbs-nofoldertypes.reg)
|
||||||
disables thumbnails and folder-type detection in windows explorer, makes it way faster (especially for slow/networked locations (such as copyparty-fuse))
|
* disables thumbnails and folder-type detection in windows explorer
|
||||||
|
* makes it way faster (especially for slow/networked locations (such as copyparty-fuse))
|
||||||
|
|
||||||
|
### [`cfssl.sh`](cfssl.sh)
|
||||||
|
* creates CA and server certificates using cfssl
|
||||||
|
* give a 3rd argument to install it to your copyparty config
|
||||||
|
|
||||||
# OS integration
|
# OS integration
|
||||||
init-scripts to start copyparty as a service
|
init-scripts to start copyparty as a service
|
||||||
|
|||||||
72
contrib/cfssl.sh
Executable file
72
contrib/cfssl.sh
Executable file
@@ -0,0 +1,72 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# ca-name and server-name
|
||||||
|
ca_name="$1"
|
||||||
|
srv_name="$2"
|
||||||
|
|
||||||
|
[ -z "$srv_name" ] && {
|
||||||
|
echo "need arg 1: ca name"
|
||||||
|
echo "need arg 2: server name"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
gen_ca() {
|
||||||
|
(tee /dev/stderr <<EOF
|
||||||
|
{"CN": "$ca_name ca",
|
||||||
|
"CA": {"expiry":"87600h", "pathlen":0},
|
||||||
|
"key": {"algo":"rsa", "size":4096},
|
||||||
|
"names": [{"O":"$ca_name ca"}]}
|
||||||
|
EOF
|
||||||
|
)|
|
||||||
|
cfssl gencert -initca - |
|
||||||
|
cfssljson -bare ca
|
||||||
|
|
||||||
|
mv ca-key.pem ca.key
|
||||||
|
rm ca.csr
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
gen_srv() {
|
||||||
|
(tee /dev/stderr <<EOF
|
||||||
|
{"key": {"algo":"rsa", "size":4096},
|
||||||
|
"names": [{"O":"$ca_name - $srv_name"}]}
|
||||||
|
EOF
|
||||||
|
)|
|
||||||
|
cfssl gencert -ca ca.pem -ca-key ca.key \
|
||||||
|
-profile=www -hostname="$srv_name.$ca_name" - |
|
||||||
|
cfssljson -bare "$srv_name"
|
||||||
|
|
||||||
|
mv "$srv_name-key.pem" "$srv_name.key"
|
||||||
|
rm "$srv_name.csr"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# create ca if not exist
|
||||||
|
[ -e ca.key ] ||
|
||||||
|
gen_ca
|
||||||
|
|
||||||
|
# always create server cert
|
||||||
|
gen_srv
|
||||||
|
|
||||||
|
|
||||||
|
# dump cert info
|
||||||
|
show() {
|
||||||
|
openssl x509 -text -noout -in $1 |
|
||||||
|
awk '!o; {o=0} /[0-9a-f:]{16}/{o=1}'
|
||||||
|
}
|
||||||
|
show ca.pem
|
||||||
|
show "$srv_name.pem"
|
||||||
|
|
||||||
|
|
||||||
|
# write cert into copyparty config
|
||||||
|
[ -z "$3" ] || {
|
||||||
|
mkdir -p ~/.config/copyparty
|
||||||
|
cat "$srv_name".{key,pem} ca.pem >~/.config/copyparty/cert.pem
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# rm *.key *.pem
|
||||||
|
# cfssl print-defaults config
|
||||||
|
# cfssl print-defaults csr
|
||||||
@@ -144,12 +144,11 @@ def configure_ssl_ciphers(al):
|
|||||||
|
|
||||||
is_help = al.ciphers == "help"
|
is_help = al.ciphers == "help"
|
||||||
|
|
||||||
if al.ciphers:
|
if al.ciphers and not is_help:
|
||||||
try:
|
try:
|
||||||
ctx.set_ciphers(al.ciphers)
|
ctx.set_ciphers(al.ciphers)
|
||||||
except:
|
except:
|
||||||
if not is_help:
|
print("\n\033[1;31mfailed to set ciphers\033[0m\n")
|
||||||
print("\n\033[1;31mfailed to set ciphers\033[0m\n")
|
|
||||||
|
|
||||||
if not hasattr(ctx, "get_ciphers"):
|
if not hasattr(ctx, "get_ciphers"):
|
||||||
print("cannot read cipher list: openssl or python too old")
|
print("cannot read cipher list: openssl or python too old")
|
||||||
@@ -211,8 +210,8 @@ def main():
|
|||||||
"print,get" prints the data in the log and returns GET
|
"print,get" prints the data in the log and returns GET
|
||||||
(leave out the ",get" to return an error instead)
|
(leave out the ",get" to return an error instead)
|
||||||
|
|
||||||
see "--ciphers help" for available ssl/tls ciphers,
|
--ciphers help = available ssl/tls ciphers,
|
||||||
see "--ssl-ver help" for available ssl/tls versions,
|
--ssl-ver help = available ssl/tls versions,
|
||||||
default is what python considers safe, usually >= TLS1
|
default is what python considers safe, usually >= TLS1
|
||||||
"""
|
"""
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
VERSION = (0, 7, 5)
|
VERSION = (0, 7, 6)
|
||||||
CODENAME = "keeping track"
|
CODENAME = "keeping track"
|
||||||
BUILD_DT = (2021, 2, 12)
|
BUILD_DT = (2021, 2, 12)
|
||||||
|
|
||||||
|
|||||||
@@ -1095,6 +1095,10 @@ class HttpCli(object):
|
|||||||
if not self.args.ed or "dots" not in self.uparam:
|
if not self.args.ed or "dots" not in self.uparam:
|
||||||
vfs_ls = exclude_dotfiles(vfs_ls)
|
vfs_ls = exclude_dotfiles(vfs_ls)
|
||||||
|
|
||||||
|
hidden = []
|
||||||
|
if fsroot.endswith(str(os.sep) + ".hist"):
|
||||||
|
hidden = ["up2k.db", "up2k.snap"]
|
||||||
|
|
||||||
dirs = []
|
dirs = []
|
||||||
files = []
|
files = []
|
||||||
for fn in vfs_ls:
|
for fn in vfs_ls:
|
||||||
@@ -1106,6 +1110,8 @@ class HttpCli(object):
|
|||||||
|
|
||||||
if fn in vfs_virt:
|
if fn in vfs_virt:
|
||||||
fspath = vfs_virt[fn].realpath
|
fspath = vfs_virt[fn].realpath
|
||||||
|
elif fn in hidden:
|
||||||
|
continue
|
||||||
else:
|
else:
|
||||||
fspath = fsroot + "/" + fn
|
fspath = fsroot + "/" + fn
|
||||||
|
|
||||||
|
|||||||
@@ -130,8 +130,12 @@ class Up2k(object):
|
|||||||
if db:
|
if db:
|
||||||
# can be symlink so don't `and d.startswith(top)``
|
# can be symlink so don't `and d.startswith(top)``
|
||||||
excl = set([d for d in tops if d != top])
|
excl = set([d for d in tops if d != top])
|
||||||
self._build_dir([db, 0, time.time()], top, excl, top)
|
dbw = [db, 0, time.time()]
|
||||||
|
self._build_dir(dbw, top, excl, top)
|
||||||
self._drop_lost(db, top)
|
self._drop_lost(db, top)
|
||||||
|
if dbw[1]:
|
||||||
|
self.log("up2k", "commit {} new files".format(dbw[1]))
|
||||||
|
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
def _build_dir(self, dbw, top, excl, cdir):
|
def _build_dir(self, dbw, top, excl, cdir):
|
||||||
@@ -190,7 +194,7 @@ class Up2k(object):
|
|||||||
dbw[1] += 1
|
dbw[1] += 1
|
||||||
td = time.time() - dbw[2]
|
td = time.time() - dbw[2]
|
||||||
if dbw[1] > 1024 or td > 60:
|
if dbw[1] > 1024 or td > 60:
|
||||||
self.log("up2k", "commit {} files".format(dbw[1]))
|
self.log("up2k", "commit {} new files".format(dbw[1]))
|
||||||
dbw[0].commit()
|
dbw[0].commit()
|
||||||
dbw[1] = 0
|
dbw[1] = 0
|
||||||
dbw[2] = time.time()
|
dbw[2] = time.time()
|
||||||
|
|||||||
@@ -219,6 +219,10 @@ function up2k_init(have_crypto) {
|
|||||||
"hash": [],
|
"hash": [],
|
||||||
"handshake": [],
|
"handshake": [],
|
||||||
"upload": []
|
"upload": []
|
||||||
|
},
|
||||||
|
"bytes": {
|
||||||
|
"hashed": 0,
|
||||||
|
"uploaded": 0
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -357,8 +361,11 @@ function up2k_init(have_crypto) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function hashing_permitted() {
|
function hashing_permitted() {
|
||||||
var lim = multitask ? 1 : 0;
|
if (multitask) {
|
||||||
return handshakes_permitted() && lim >=
|
var ahead = st.bytes.hashed - st.bytes.uploaded;
|
||||||
|
return ahead < 1024 * 1024 * 128;
|
||||||
|
}
|
||||||
|
return handshakes_permitted() && 0 ==
|
||||||
st.todo.handshake.length +
|
st.todo.handshake.length +
|
||||||
st.busy.handshake.length;
|
st.busy.handshake.length;
|
||||||
}
|
}
|
||||||
@@ -512,6 +519,7 @@ function up2k_init(have_crypto) {
|
|||||||
|
|
||||||
var t = st.todo.hash.shift();
|
var t = st.todo.hash.shift();
|
||||||
st.busy.hash.push(t);
|
st.busy.hash.push(t);
|
||||||
|
st.bytes.hashed += t.size;
|
||||||
t.t1 = new Date().getTime();
|
t.t1 = new Date().getTime();
|
||||||
|
|
||||||
var nchunk = 0;
|
var nchunk = 0;
|
||||||
@@ -752,6 +760,7 @@ function up2k_init(have_crypto) {
|
|||||||
xhr.onload = function (xev) {
|
xhr.onload = function (xev) {
|
||||||
if (xhr.status == 200) {
|
if (xhr.status == 200) {
|
||||||
prog(t.n, npart, col_uploaded);
|
prog(t.n, npart, col_uploaded);
|
||||||
|
st.bytes.uploaded += cdr - car;
|
||||||
st.busy.upload.splice(st.busy.upload.indexOf(upt), 1);
|
st.busy.upload.splice(st.busy.upload.indexOf(upt), 1);
|
||||||
t.postlist.splice(t.postlist.indexOf(npart), 1);
|
t.postlist.splice(t.postlist.indexOf(npart), 1);
|
||||||
if (t.postlist.length == 0) {
|
if (t.postlist.length == 0) {
|
||||||
|
|||||||
5
setup.py
5
setup.py
@@ -2,10 +2,8 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import io
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from glob import glob
|
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
|
|
||||||
setuptools_available = True
|
setuptools_available = True
|
||||||
@@ -49,7 +47,7 @@ with open(here + "/README.md", "rb") as f:
|
|||||||
about = {}
|
about = {}
|
||||||
if not VERSION:
|
if not VERSION:
|
||||||
with open(os.path.join(here, NAME, "__version__.py"), "rb") as f:
|
with open(os.path.join(here, NAME, "__version__.py"), "rb") as f:
|
||||||
exec(f.read().decode("utf-8").split("\n\n", 1)[1], about)
|
exec (f.read().decode("utf-8").split("\n\n", 1)[1], about)
|
||||||
else:
|
else:
|
||||||
about["__version__"] = VERSION
|
about["__version__"] = VERSION
|
||||||
|
|
||||||
@@ -116,6 +114,7 @@ args = {
|
|||||||
"Programming Language :: Python :: 3.6",
|
"Programming Language :: Python :: 3.6",
|
||||||
"Programming Language :: Python :: 3.7",
|
"Programming Language :: Python :: 3.7",
|
||||||
"Programming Language :: Python :: 3.8",
|
"Programming Language :: Python :: 3.8",
|
||||||
|
"Programming Language :: Python :: 3.9",
|
||||||
"Programming Language :: Python :: Implementation :: CPython",
|
"Programming Language :: Python :: Implementation :: CPython",
|
||||||
"Programming Language :: Python :: Implementation :: PyPy",
|
"Programming Language :: Python :: Implementation :: PyPy",
|
||||||
"Environment :: Console",
|
"Environment :: Console",
|
||||||
|
|||||||
Reference in New Issue
Block a user