connectpage: usernames

This commit is contained in:
ed 2025-09-06 22:17:48 +00:00
parent 67ba5b0252
commit 3bdef75e88
3 changed files with 101 additions and 21 deletions

View file

@ -5024,10 +5024,20 @@ class HttpCli(object):
else: else:
rip = host rip = host
defpw = "dave:hunter2" if self.args.usernames else "hunter2"
vp = (self.uparam["hc"] or "").lstrip("/") vp = (self.uparam["hc"] or "").lstrip("/")
pw = self.ouparam.get("pw") or "hunter2" pw = self.ouparam.get("pw") or defpw
if pw in self.asrv.sesa: if pw in self.asrv.sesa:
pw = "hunter2" pw = defpw
unpw = pw
try:
un, pw = unpw.split(":")
except:
un = ""
if self.args.usernames:
un = "dave"
html = self.j2s( html = self.j2s(
"svcs", "svcs",
@ -5041,7 +5051,10 @@ class HttpCli(object):
host=html_sh_esc(host), host=html_sh_esc(host),
hport=html_sh_esc(hport), hport=html_sh_esc(hport),
aname=aname, aname=aname,
b_un=("<b>%s</b>" % (html_sh_esc(un),)) if un else "k",
un=html_sh_esc(un),
pw=html_sh_esc(pw), pw=html_sh_esc(pw),
unpw=html_sh_esc(unpw),
) )
self.reply(html.encode("utf-8")) self.reply(html.encode("utf-8"))
return True return True

View file

@ -31,10 +31,10 @@
<br /> <br />
<span class="os win lin mac">placeholders:</span> <span class="os win lin mac">placeholders:</span>
<span class="os win"> <span class="os win">
{% if accs %}<code><b id="pw0">{{ pw }}</b></code>=password, {% endif %}<code><b>W:</b></code>=mountpoint {% if accs %}{% if un %}<code><b id="un0">{{ un }}</b></code>=username, <code><b id="up0">{{ unpw }}</b></code>=username:password, {% endif %}<code><b id="pw0">{{ pw }}</b></code>=password, {% endif %}<code><b>W:</b></code>=mountpoint
</span> </span>
<span class="os lin mac"> <span class="os lin mac">
{% if accs %}<code><b id="pw0">{{ pw }}</b></code>=password, {% endif %}<code><b>mp</b></code>=mountpoint {% if accs %}{% if un %}<code><b id="un0">{{ un }}</b></code>=username, <code><b id="up0">{{ unpw }}</b></code>=username:password, {% endif %}<code><b id="pw0">{{ pw }}</b></code>=password, {% endif %}<code><b>mp</b></code>=mountpoint
</span> </span>
{% if accs %}<a href="#" id="setpw">use real password</a>{% endif %} {% if accs %}<a href="#" id="setpw">use real password</a>{% endif %}
<a href="#" id="qr">show qr</a> <a href="#" id="qr">show qr</a>
@ -54,7 +54,7 @@
<div class="os win"> <div class="os win">
<p>if you can, install <a href="https://winfsp.dev/rel/">winfsp</a>+<a href="https://downloads.rclone.org/rclone-current-windows-amd64.zip">rclone</a> and then paste this in cmd:</p> <p>if you can, install <a href="https://winfsp.dev/rel/">winfsp</a>+<a href="https://downloads.rclone.org/rclone-current-windows-amd64.zip">rclone</a> and then paste this in cmd:</p>
<pre> <pre>
rclone config create {{ aname }}-dav webdav url=http{{ s }}://{{ rip }}{{ hport }} vendor=owncloud pacer_min_sleep=0.01ms{% if accs %} user=k pass=<b>{{ pw }}</b>{% endif %} rclone config create {{ aname }}-dav webdav url=http{{ s }}://{{ rip }}{{ hport }} vendor=owncloud pacer_min_sleep=0.01ms{% if accs %} user={{ b_un }} pass=<b>{{ pw }}</b>{% endif %}
rclone mount --vfs-cache-mode writes --dir-cache-time 5s {{ aname }}-dav:{{ rvp }} <b>W:</b> rclone mount --vfs-cache-mode writes --dir-cache-time 5s {{ aname }}-dav:{{ rvp }} <b>W:</b>
</pre> </pre>
<ul> <ul>
@ -66,14 +66,18 @@
<p>if you want to use the native WebDAV client in windows instead (slow and buggy), first run <a href="{{ r }}/.cpr/a/webdav-cfg.bat">webdav-cfg.bat</a> to remove the 47 MiB filesize limit (also fixes latency and password login), then connect:</p> <p>if you want to use the native WebDAV client in windows instead (slow and buggy), first run <a href="{{ r }}/.cpr/a/webdav-cfg.bat">webdav-cfg.bat</a> to remove the 47 MiB filesize limit (also fixes latency and password login), then connect:</p>
<pre> <pre>
{%- if un %}
net use <b>w:</b> http{{ s }}://{{ ep }}/{{ rvp }}{% if accs %} <b>{{ pw }}</b> /user:{{ b_un }}{% endif %}
{%- else %}
net use <b>w:</b> http{{ s }}://{{ ep }}/{{ rvp }}{% if accs %} k /user:<b>{{ pw }}</b>{% endif %} net use <b>w:</b> http{{ s }}://{{ ep }}/{{ rvp }}{% if accs %} k /user:<b>{{ pw }}</b>{% endif %}
{%- endif %}
</pre> </pre>
</div> </div>
<div class="os lin"> <div class="os lin">
<p>rclone (v1.63 or later) is recommended:</p> <p>rclone (v1.63 or later) is recommended:</p>
<pre> <pre>
rclone config create {{ aname }}-dav webdav url=http{{ s }}://{{ rip }}{{ hport }} vendor=owncloud pacer_min_sleep=0.01ms{% if accs %} user=k pass=<b>{{ pw }}</b>{% endif %} rclone config create {{ aname }}-dav webdav url=http{{ s }}://{{ rip }}{{ hport }} vendor=owncloud pacer_min_sleep=0.01ms{% if accs %} user={{ b_un }} pass=<b>{{ pw }}</b>{% endif %}
rclone mount --vfs-cache-mode writes --dir-cache-time 5s {{ aname }}-dav:{{ rvp }} <b>mp</b> rclone mount --vfs-cache-mode writes --dir-cache-time 5s {{ aname }}-dav:{{ rvp }} <b>mp</b>
</pre> </pre>
<ul> <ul>
@ -86,18 +90,28 @@
<p>alternatively use davfs2 (requires root, is slower, forgets lastmodified-timestamp on upload):</p> <p>alternatively use davfs2 (requires root, is slower, forgets lastmodified-timestamp on upload):</p>
<pre> <pre>
yum install davfs2 yum install davfs2
{%- if un %}
{% if accs %}printf '%s\n' {{ b_un }} <b>{{ pw }}</b> | {% endif %}mount -t davfs -ouid=1000 http{{ s }}://{{ ep }}/{{ rvp }} <b>mp</b>
{%- else %}
{% if accs %}printf '%s\n' <b>{{ pw }}</b> k | {% endif %}mount -t davfs -ouid=1000 http{{ s }}://{{ ep }}/{{ rvp }} <b>mp</b> {% if accs %}printf '%s\n' <b>{{ pw }}</b> k | {% endif %}mount -t davfs -ouid=1000 http{{ s }}://{{ ep }}/{{ rvp }} <b>mp</b>
{%- endif %}
</pre> </pre>
{%- if accs %}
<p>make davfs2 automount on boot:</p> <p>make davfs2 automount on boot:</p>
<pre> <pre>
{%- if un %}
printf '%s\n' "http{{ s }}://{{ ep }}/{{ rvp }} {{ b_un }} <b>{{ pw }}</b>" >> /etc/davfs2/secrets
{%- else %}
printf '%s\n' "http{{ s }}://{{ ep }}/{{ rvp }} <b>{{ pw }}</b> k" >> /etc/davfs2/secrets printf '%s\n' "http{{ s }}://{{ ep }}/{{ rvp }} <b>{{ pw }}</b> k" >> /etc/davfs2/secrets
{%- endif %}
printf '%s\n' "http{{ s }}://{{ ep }}/{{ rvp }} <b>mp</b> davfs rw,user,uid=1000,noauto 0 0" >> /etc/fstab printf '%s\n' "http{{ s }}://{{ ep }}/{{ rvp }} <b>mp</b> davfs rw,user,uid=1000,noauto 0 0" >> /etc/fstab
</pre> </pre>
{%- endif %}
<p>or the emergency alternative (gnome/gui-only):</p> <p>or the emergency alternative (gnome/gui-only):</p>
<!-- gnome-bug: ignores vp --> <!-- gnome-bug: ignores vp -->
<pre> <pre>
{%- if accs %} {%- if accs %}
echo <b>{{ pw }}</b> | gio mount dav{{ s }}://k@{{ ep }}/{{ rvp }} echo <b>{{ pw }}</b> | gio mount dav{{ s }}://{{ b_un }}@{{ ep }}/{{ rvp }}
{%- else %} {%- else %}
gio mount -a dav{{ s }}://{{ ep }}/{{ rvp }} gio mount -a dav{{ s }}://{{ ep }}/{{ rvp }}
{%- endif %} {%- endif %}
@ -107,11 +121,11 @@
<div class="os mac"> <div class="os mac">
<pre> <pre>
osascript -e ' mount volume "http{{ s }}://k:<b>{{ pw }}</b>@{{ ep }}/{{ rvp }}" ' osascript -e ' mount volume "http{{ s }}://{{ b_un }}:<b>{{ pw }}</b>@{{ ep }}/{{ rvp }}" '
</pre> </pre>
<p>or you can open up a Finder, press command-K and paste this instead:</p> <p>or you can open up a Finder, press command-K and paste this instead:</p>
<pre> <pre>
http{{ s }}://k:<b>{{ pw }}</b>@{{ ep }}/{{ rvp }} http{{ s }}://{{ b_un }}:<b>{{ pw }}</b>@{{ ep }}/{{ rvp }}
</pre> </pre>
{%- if s %} {%- if s %}
@ -130,14 +144,22 @@
{%- if args.ftp %} {%- if args.ftp %}
<p>connect with plaintext FTP:</p> <p>connect with plaintext FTP:</p>
<pre> <pre>
{%- if un %}
rclone config create {{ aname }}-ftp ftp host={{ rip }} port={{ args.ftp }} user={% if accs %}{{ b_un }} pass=<b>{{ pw }}</b>{% else %}anonymous pass=k{% endif %} tls=false
{%- else %}
rclone config create {{ aname }}-ftp ftp host={{ rip }} port={{ args.ftp }} pass=k user={% if accs %}<b>{{ pw }}</b>{% else %}anonymous{% endif %} tls=false rclone config create {{ aname }}-ftp ftp host={{ rip }} port={{ args.ftp }} pass=k user={% if accs %}<b>{{ pw }}</b>{% else %}anonymous{% endif %} tls=false
{%- endif %}
rclone mount --vfs-cache-mode writes --dir-cache-time 5s {{ aname }}-ftp:{{ rvp }} <b>W:</b> rclone mount --vfs-cache-mode writes --dir-cache-time 5s {{ aname }}-ftp:{{ rvp }} <b>W:</b>
</pre> </pre>
{%- endif %} {%- endif %}
{%- if args.ftps %} {%- if args.ftps %}
<p>connect with TLS-encrypted FTPS:</p> <p>connect with TLS-encrypted FTPS:</p>
<pre> <pre>
{%- if un %}
rclone config create {{ aname }}-ftps ftp host={{ rip }} port={{ args.ftps }} user={% if accs %}{{ b_un }} pass=<b>{{ pw }}</b>{% else %}anonymous pass=k{% endif %} tls=false explicit_tls=true
{%- else %}
rclone config create {{ aname }}-ftps ftp host={{ rip }} port={{ args.ftps }} pass=k user={% if accs %}<b>{{ pw }}</b>{% else %}anonymous{% endif %} tls=false explicit_tls=true rclone config create {{ aname }}-ftps ftp host={{ rip }} port={{ args.ftps }} pass=k user={% if accs %}<b>{{ pw }}</b>{% else %}anonymous{% endif %} tls=false explicit_tls=true
{%- endif %}
rclone mount --vfs-cache-mode writes --dir-cache-time 5s {{ aname }}-ftps:{{ rvp }} <b>W:</b> rclone mount --vfs-cache-mode writes --dir-cache-time 5s {{ aname }}-ftps:{{ rvp }} <b>W:</b>
</pre> </pre>
{%- endif %} {%- endif %}
@ -149,7 +171,11 @@
</ul> </ul>
<p>if you want to use the native FTP client in windows instead (please dont), press <code>win+R</code> and run this command:</p> <p>if you want to use the native FTP client in windows instead (please dont), press <code>win+R</code> and run this command:</p>
<pre> <pre>
{%- if un %}
explorer {{ "ftp" if args.ftp else "ftps" }}://{% if accs %}{{ b_un }}:<b>{{ pw }}</b>@{% endif %}{{ host }}:{{ args.ftp or args.ftps }}/{{ rvp }}
{%- else %}
explorer {{ "ftp" if args.ftp else "ftps" }}://{% if accs %}<b>{{ pw }}</b>:k@{% endif %}{{ host }}:{{ args.ftp or args.ftps }}/{{ rvp }} explorer {{ "ftp" if args.ftp else "ftps" }}://{% if accs %}<b>{{ pw }}</b>:k@{% endif %}{{ host }}:{{ args.ftp or args.ftps }}/{{ rvp }}
{%- endif %}
</pre> </pre>
</div> </div>
@ -157,14 +183,22 @@
{%- if args.ftp %} {%- if args.ftp %}
<p>connect with plaintext FTP:</p> <p>connect with plaintext FTP:</p>
<pre> <pre>
{%- if un %}
rclone config create {{ aname }}-ftp ftp host={{ rip }} port={{ args.ftp }} user={% if accs %}{{ b_un }} pass=<b>{{ pw }}</b>{% else %}anonymous pass=k{% endif %} tls=false
{%- else %}
rclone config create {{ aname }}-ftp ftp host={{ rip }} port={{ args.ftp }} pass=k user={% if accs %}<b>{{ pw }}</b>{% else %}anonymous{% endif %} tls=false rclone config create {{ aname }}-ftp ftp host={{ rip }} port={{ args.ftp }} pass=k user={% if accs %}<b>{{ pw }}</b>{% else %}anonymous{% endif %} tls=false
{%- endif %}
rclone mount --vfs-cache-mode writes --dir-cache-time 5s {{ aname }}-ftp:{{ rvp }} <b>mp</b> rclone mount --vfs-cache-mode writes --dir-cache-time 5s {{ aname }}-ftp:{{ rvp }} <b>mp</b>
</pre> </pre>
{%- endif %} {%- endif %}
{%- if args.ftps %} {%- if args.ftps %}
<p>connect with TLS-encrypted FTPS:</p> <p>connect with TLS-encrypted FTPS:</p>
<pre> <pre>
{%- if un %}
rclone config create {{ aname }}-ftps ftp host={{ rip }} port={{ args.ftps }} user={% if accs %}{{ b_un }} pass=<b>{{ pw }}</b>{% else %}anonymous pass=k{% endif %} tls=false explicit_tls=true
{%- else %}
rclone config create {{ aname }}-ftps ftp host={{ rip }} port={{ args.ftps }} pass=k user={% if accs %}<b>{{ pw }}</b>{% else %}anonymous{% endif %} tls=false explicit_tls=true rclone config create {{ aname }}-ftps ftp host={{ rip }} port={{ args.ftps }} pass=k user={% if accs %}<b>{{ pw }}</b>{% else %}anonymous{% endif %} tls=false explicit_tls=true
{%- endif %}
rclone mount --vfs-cache-mode writes --dir-cache-time 5s {{ aname }}-ftps:{{ rvp }} <b>mp</b> rclone mount --vfs-cache-mode writes --dir-cache-time 5s {{ aname }}-ftps:{{ rvp }} <b>mp</b>
</pre> </pre>
{%- endif %} {%- endif %}
@ -179,7 +213,7 @@
<!-- gnome-bug: ignores vp --> <!-- gnome-bug: ignores vp -->
<pre> <pre>
{%- if accs %} {%- if accs %}
echo <b>{{ pw }}</b> | gio mount ftp{{ "" if args.ftp else "s" }}://k@{{ host }}:{{ args.ftp or args.ftps }}/{{ rvp }} echo <b>{{ pw }}</b> | gio mount ftp{{ "" if args.ftp else "s" }}://{{ b_un }}@{{ host }}:{{ args.ftp or args.ftps }}/{{ rvp }}
{%- else %} {%- else %}
gio mount -a ftp{{ "" if args.ftp else "s" }}://{{ host }}:{{ args.ftp or args.ftps }}/{{ rvp }} gio mount -a ftp{{ "" if args.ftp else "s" }}://{{ host }}:{{ args.ftp or args.ftps }}/{{ rvp }}
{%- endif %} {%- endif %}
@ -189,7 +223,7 @@
<div class="os mac"> <div class="os mac">
<p>note: FTP is read-only on macos; please use WebDAV instead</p> <p>note: FTP is read-only on macos; please use WebDAV instead</p>
<pre> <pre>
open {{ "ftp" if args.ftp else "ftps" }}://{% if accs %}k:<b>{{ pw }}</b>@{% else %}anonymous:@{% endif %}{{ host }}:{{ args.ftp or args.ftps }}/{{ rvp }} open {{ "ftp" if args.ftp else "ftps" }}://{% if accs %}{{ b_un }}:<b>{{ pw }}</b>@{% else %}anonymous:@{% endif %}{{ host }}:{{ args.ftp or args.ftps }}/{{ rvp }}
</pre> </pre>
</div> </div>
{%- endif %} {%- endif %}
@ -204,7 +238,7 @@
<span class="os lin">doesn't need root</span> <span class="os lin">doesn't need root</span>
</p> </p>
<pre> <pre>
partyfuse.py{% if accs %} -a <b>{{ pw }}</b>{% endif %} http{{ s }}://{{ ep }}/{{ rvp }} <b><span class="os win">W:</span><span class="os lin mac">mp</span></b> partyfuse.py{% if accs %} -a <b>{{ unpw }}</b>{% endif %} http{{ s }}://{{ ep }}/{{ rvp }} <b><span class="os win">W:</span><span class="os lin mac">mp</span></b>
</pre> </pre>
{%- if s %} {%- if s %}
<ul><li>if you are on LAN (or just dont have valid certificates), add <code>-td</code></li></ul> <ul><li>if you are on LAN (or just dont have valid certificates), add <code>-td</code></li></ul>
@ -217,6 +251,10 @@
{% if args.smb %} {% if args.smb %}
<h1>SMB / CIFS</h1> <h1>SMB / CIFS</h1>
{%- if un %}
<h2>not available on this server because <code>--usernames</code> is enabled in the server config</h2>
{%- else %}
<div class="os win"> <div class="os win">
<pre> <pre>
net use <b>w:</b> \\{{ host }}\a{% if accs %} k /user:<b>{{ pw }}</b>{% endif %} net use <b>w:</b> \\{{ host }}\a{% if accs %} k /user:<b>{{ pw }}</b>{% endif %}
@ -235,6 +273,7 @@
open 'smb://<b>{{ pw }}</b>:k@{{ host }}/a' open 'smb://<b>{{ pw }}</b>:k@{{ host }}/a'
</pre> </pre>
{%- endif %} {%- endif %}
{%- endif %}
@ -247,7 +286,7 @@
{ "Version": "15.0.0", "Name": "copyparty", { "Version": "15.0.0", "Name": "copyparty",
"RequestURL": "http{{ s }}://{{ ep }}/{{ rvp }}", "RequestURL": "http{{ s }}://{{ ep }}/{{ rvp }}",
"Headers": { "Headers": {
{% if accs %}"pw": "<b>{{ pw }}</b>", {% endif %}"accept": "url" {% if accs %}"pw": "<b>{{ unpw }}</b>", {% endif %}"accept": "url"
}, },
"DestinationType": "ImageUploader, TextUploader, FileUploader", "DestinationType": "ImageUploader, TextUploader, FileUploader",
"Body": "MultipartFormData", "URL": "{response}", "Body": "MultipartFormData", "URL": "{response}",
@ -260,7 +299,7 @@
{ "Name": "copyparty", { "Name": "copyparty",
"RequestURL": "http{{ s }}://{{ ep }}/{{ rvp }}", "RequestURL": "http{{ s }}://{{ ep }}/{{ rvp }}",
"Headers": { "Headers": {
{% if accs %}"pw": "<b>{{ pw }}</b>", {% endif %}"accept": "url" {% if accs %}"pw": "<b>{{ unpw }}</b>", {% endif %}"accept": "url"
}, },
"DestinationType": "ImageUploader, TextUploader, FileUploader", "DestinationType": "ImageUploader, TextUploader, FileUploader",
"FileFormName": "f" } "FileFormName": "f" }
@ -278,7 +317,9 @@
{ "Name": "copyparty", { "Name": "copyparty",
"RequestURL": "http{{ s }}://{{ ep }}/{{ rvp }}", "RequestURL": "http{{ s }}://{{ ep }}/{{ rvp }}",
"Headers": { "Headers": {
{% if accs %}"pw": "<b>{{ pw }}</b>",{% endif %} {%- if accs %}
"pw": "<b>{{ unpw }}</b>",
{%- endif %}
"accept": "json" "accept": "json"
}, },
"ResponseURL": "{{ '{{fileurl}}' }}", "ResponseURL": "{{ '{{fileurl}}' }}",
@ -295,7 +336,7 @@
<pre class="dl" name="flameshot.sh"> <pre class="dl" name="flameshot.sh">
#!/bin/bash #!/bin/bash
pw="<b>{{ pw }}</b>" pw="<b>{{ unpw }}</b>"
url="http{{ s }}://{{ ep }}/{{ rvp }}" url="http{{ s }}://{{ ep }}/{{ rvp }}"
filename="$(date +%Y-%m%d-%H%M%S).png" filename="$(date +%Y-%m%d-%H%M%S).png"
flameshot gui -s -r | curl -sT- "$url$filename?want=url&pw=$pw" | xsel -ib flameshot gui -s -r | curl -sT- "$url$filename?want=url&pw=$pw" | xsel -ib

View file

@ -49,21 +49,47 @@ function setos(os) {
setos(WINDOWS ? 'win' : LINUX ? 'lin' : MACOS ? 'mac' : 'idk'); setos(WINDOWS ? 'win' : LINUX ? 'lin' : MACOS ? 'mac' : 'idk');
var pw = ''; var un, un0, pw, pw0, unpw, up0;
function setpw(e) { function setpw(e) {
ev(e); ev(e);
if (!ebi('un0'))
return askpw();
modal.prompt('username:', '', function (v) {
if (!v)
return;
un = v;
un0 = ebi('un0').innerHTML;
var oa = QSA('b');
for (var a = 0; a < oa.length; a++)
if (oa[a].innerHTML == un0)
oa[a].textContent = un;
askpw();
});
}
function askpw() {
modal.prompt('password:', '', function (v) { modal.prompt('password:', '', function (v) {
if (!v) if (!v)
return; return;
pw = v; pw = v;
var pw0 = ebi('pw0').innerHTML, pw0 = ebi('pw0').innerHTML;
oa = QSA('b'); var oa = QSA('b');
for (var a = 0; a < oa.length; a++) for (var a = 0; a < oa.length; a++)
if (oa[a].innerHTML == pw0) if (oa[a].innerHTML == pw0)
oa[a].textContent = v; oa[a].textContent = pw;
if (un) {
unpw = un ? (un+':'+pw) : pw;
up0 = ebi('up0').innerHTML;
for (var a = 0; a < oa.length; a++)
if (oa[a].innerHTML == up0)
oa[a].textContent = unpw;
}
add_dls(); add_dls();
}); });
} }