diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 7dc4bc1b..dd4d958e 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -5024,10 +5024,20 @@ class HttpCli(object): else: rip = host + defpw = "dave:hunter2" if self.args.usernames else "hunter2" + 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: - pw = "hunter2" + pw = defpw + + unpw = pw + try: + un, pw = unpw.split(":") + except: + un = "" + if self.args.usernames: + un = "dave" html = self.j2s( "svcs", @@ -5041,7 +5051,10 @@ class HttpCli(object): host=html_sh_esc(host), hport=html_sh_esc(hport), aname=aname, + b_un=("%s" % (html_sh_esc(un),)) if un else "k", + un=html_sh_esc(un), pw=html_sh_esc(pw), + unpw=html_sh_esc(unpw), ) self.reply(html.encode("utf-8")) return True diff --git a/copyparty/web/svcs.html b/copyparty/web/svcs.html index 64e2e0db..f63e670f 100644 --- a/copyparty/web/svcs.html +++ b/copyparty/web/svcs.html @@ -31,10 +31,10 @@
placeholders: - {% if accs %}{{ pw }}=password, {% endif %}W:=mountpoint + {% if accs %}{% if un %}{{ un }}=username, {{ unpw }}=username:password, {% endif %}{{ pw }}=password, {% endif %}W:=mountpoint - {% if accs %}{{ pw }}=password, {% endif %}mp=mountpoint + {% if accs %}{% if un %}{{ un }}=username, {{ unpw }}=username:password, {% endif %}{{ pw }}=password, {% endif %}mp=mountpoint {% if accs %}use real password{% endif %} show qr @@ -54,7 +54,7 @@

if you can, install winfsp+rclone and then paste this in cmd:

-                rclone config create {{ aname }}-dav webdav url=http{{ s }}://{{ rip }}{{ hport }} vendor=owncloud pacer_min_sleep=0.01ms{% if accs %} user=k pass={{ pw }}{% 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={{ pw }}{% endif %}
                 rclone mount --vfs-cache-mode writes --dir-cache-time 5s {{ aname }}-dav:{{ rvp }} W:
             

rclone (v1.63 or later) is recommended:

-                rclone config create {{ aname }}-dav webdav url=http{{ s }}://{{ rip }}{{ hport }} vendor=owncloud pacer_min_sleep=0.01ms{% if accs %} user=k pass={{ pw }}{% 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={{ pw }}{% endif %}
                 rclone mount --vfs-cache-mode writes --dir-cache-time 5s {{ aname }}-dav:{{ rvp }} mp
             

if you want to use the native FTP client in windows instead (please dont), press win+R and run this command:

+                {%- if un %}
+                explorer {{ "ftp" if args.ftp else "ftps" }}://{% if accs %}{{ b_un }}:{{ pw }}@{% endif %}{{ host }}:{{ args.ftp or args.ftps }}/{{ rvp }}
+                {%- else %}
                 explorer {{ "ftp" if args.ftp else "ftps" }}://{% if accs %}{{ pw }}:k@{% endif %}{{ host }}:{{ args.ftp or args.ftps }}/{{ rvp }}
+                {%- endif %}
             
@@ -157,14 +183,22 @@ {%- if args.ftp %}

connect with plaintext FTP:

+                {%- if un %}
+                rclone config create {{ aname }}-ftp ftp host={{ rip }} port={{ args.ftp }} user={% if accs %}{{ b_un }} pass={{ pw }}{% else %}anonymous pass=k{% endif %} tls=false
+                {%- else %}
                 rclone config create {{ aname }}-ftp ftp host={{ rip }} port={{ args.ftp }} pass=k user={% if accs %}{{ pw }}{% else %}anonymous{% endif %} tls=false
+                {%- endif %}
                 rclone mount --vfs-cache-mode writes --dir-cache-time 5s {{ aname }}-ftp:{{ rvp }} mp
             
{%- endif %} {%- if args.ftps %}

connect with TLS-encrypted FTPS:

+                {%- if un %}
+                rclone config create {{ aname }}-ftps ftp host={{ rip }} port={{ args.ftps }} user={% if accs %}{{ b_un }} pass={{ pw }}{% 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 %}{{ pw }}{% else %}anonymous{% endif %} tls=false explicit_tls=true
+                {%- endif %}
                 rclone mount --vfs-cache-mode writes --dir-cache-time 5s {{ aname }}-ftps:{{ rvp }} mp
             
{%- endif %} @@ -179,7 +213,7 @@
                 {%- if accs %}
-                echo {{ pw }} | gio mount ftp{{ "" if args.ftp else "s" }}://k@{{ host }}:{{ args.ftp or args.ftps }}/{{ rvp }}
+                echo {{ pw }} | gio mount ftp{{ "" if args.ftp else "s" }}://{{ b_un }}@{{ host }}:{{ args.ftp or args.ftps }}/{{ rvp }}
                 {%- else %}
                 gio mount -a ftp{{ "" if args.ftp else "s" }}://{{ host }}:{{ args.ftp or args.ftps }}/{{ rvp }}
                 {%- endif %}
@@ -189,7 +223,7 @@
         

note: FTP is read-only on macos; please use WebDAV instead

-                open {{ "ftp" if args.ftp else "ftps" }}://{% if accs %}k:{{ pw }}@{% else %}anonymous:@{% endif %}{{ host }}:{{ args.ftp or args.ftps }}/{{ rvp }}
+                open {{ "ftp" if args.ftp else "ftps" }}://{% if accs %}{{ b_un }}:{{ pw }}@{% else %}anonymous:@{% endif %}{{ host }}:{{ args.ftp or args.ftps }}/{{ rvp }}
             
{%- endif %} @@ -204,7 +238,7 @@ doesn't need root

-            partyfuse.py{% if accs %} -a {{ pw }}{% endif %} http{{ s }}://{{ ep }}/{{ rvp }} W:mp
+            partyfuse.py{% if accs %} -a {{ unpw }}{% endif %} http{{ s }}://{{ ep }}/{{ rvp }} W:mp
         
{%- if s %} @@ -217,6 +251,10 @@ {% if args.smb %}

SMB / CIFS

+ {%- if un %} +

not available on this server because --usernames is enabled in the server config

+ {%- else %} +
                 net use w: \\{{ host }}\a{% if accs %} k /user:{{ pw }}{% endif %}
@@ -235,6 +273,7 @@
             open 'smb://{{ pw }}:k@{{ host }}/a'
         
{%- endif %} + {%- endif %} @@ -247,7 +286,7 @@ { "Version": "15.0.0", "Name": "copyparty", "RequestURL": "http{{ s }}://{{ ep }}/{{ rvp }}", "Headers": { - {% if accs %}"pw": "{{ pw }}", {% endif %}"accept": "url" + {% if accs %}"pw": "{{ unpw }}", {% endif %}"accept": "url" }, "DestinationType": "ImageUploader, TextUploader, FileUploader", "Body": "MultipartFormData", "URL": "{response}", @@ -260,7 +299,7 @@ { "Name": "copyparty", "RequestURL": "http{{ s }}://{{ ep }}/{{ rvp }}", "Headers": { - {% if accs %}"pw": "{{ pw }}", {% endif %}"accept": "url" + {% if accs %}"pw": "{{ unpw }}", {% endif %}"accept": "url" }, "DestinationType": "ImageUploader, TextUploader, FileUploader", "FileFormName": "f" } @@ -278,7 +317,9 @@ { "Name": "copyparty", "RequestURL": "http{{ s }}://{{ ep }}/{{ rvp }}", "Headers": { - {% if accs %}"pw": "{{ pw }}",{% endif %} + {%- if accs %} + "pw": "{{ unpw }}", + {%- endif %} "accept": "json" }, "ResponseURL": "{{ '{{fileurl}}' }}", @@ -295,7 +336,7 @@
                 #!/bin/bash
-                pw="{{ pw }}"
+                pw="{{ unpw }}"
                 url="http{{ s }}://{{ ep }}/{{ rvp }}"
                 filename="$(date +%Y-%m%d-%H%M%S).png"
                 flameshot gui -s -r | curl -sT- "$url$filename?want=url&pw=$pw" | xsel -ib
diff --git a/copyparty/web/svcs.js b/copyparty/web/svcs.js
index dad7faab..0b0f6b91 100644
--- a/copyparty/web/svcs.js
+++ b/copyparty/web/svcs.js
@@ -49,21 +49,47 @@ function setos(os) {
 setos(WINDOWS ? 'win' : LINUX ? 'lin' : MACOS ? 'mac' : 'idk');
 
 
-var pw = '';
+var un, un0, pw, pw0, unpw, up0;
 function setpw(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) {
         if (!v)
             return;
 
         pw = v;
-        var pw0 = ebi('pw0').innerHTML,
-            oa = QSA('b');
-    
+        pw0 = ebi('pw0').innerHTML;
+        var oa = QSA('b');
+
         for (var a = 0; a < oa.length; a++)
             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();
     });
 }