Hello,

(when I'm saying ssh I mean OpenSSH)

Since I have the bad/obscure/fun habit of trying to avoid script-kiddies 
probing port 22, I tend to run in to the problems of applications assuming 
that ssh is always using the default port (22/tcp). So, instead of just 
complaining I thought I'd make life a little more fun, so I created this 
little patch against partial-all-0.0.6.
This patch actually adds 2½ features: 
 * ability to connect/attach via ssh on a non-standard port
 * ability to enable (actually request, please refer to ssh(1)) ssh 
compression.
 * (the ½ feature) A  little extra debug output, debug features "/ssh[1-3]?/", 
which i.e. adds -v or -v up to -vvv for ssh. 

The compression is something I've noticed makes quite a difference when I'm 
using ssh via a wifi link, which tend to be like a modem - slow and 
unreliable. For fast links (e.g. LAN) it's according to ssh(1) probably slower 
(though, I haven't noticed any major degradation when using -C locally).

The new format for attaching to ssh is:
  ssh:host[[:port]:display]
compared to the old:
  ssh:host[:display]

I'm pretty confident this patch won't break anything but only add the listed 
features. Though, I'm not sure I've used the --debug argument correctly, see 
the FIXME comment.

Btw, I'm probably going to start loving xpra just as I do screen :). Though, 
I've had some issues with input not working with xterm (I only get mojibake 
from my keystrokes). But that's a different issue .:)

Happy Hacking 8^)
/Fredrik (aka scientica)

P.S: I'm not (yet ;) on the parti-discuss mailing list, and I'm off to campus 
for a lab-session now so I don't have time to subscribe just now. So don't 
forget to CC me if you reply.

-- 
After all, if you are in school to study computer science, then a professor
saying "use this proprietary software to learn computer science" is the
same as English professor handing you a copy of Shakespeare and saying
"use this book to learn Shakespeare without opening the book itself."
  -- Bradley Kuhn

diff --git a/foreign/xpra/parti-all-0.0.6/xpra.1 b/foreign/xpra/parti-all-0.0.6/xpra.1
index 40c835c..1859d79 100644
--- a/foreign/xpra/parti-all-0.0.6/xpra.1
+++ b/foreign/xpra/parti-all-0.0.6/xpra.1
@@ -18,9 +18,9 @@ xpra \- viewer for remote, persistent X applications
 [\fB\-\-exit\-with\-children\fP] [\fB\-\-no\-daemon\fP]
 [\fB\-\-bind\-tcp=[HOST]:PORT\fP] 
 .HP
-\fBxpra\fP \fBattach\fP [\fI:DISPLAY\fP | \fIssh:HOST:DISPLAY\fP | \fItcp:HOST:DISPLAY\fP] [\fB\-\-remote\-xpra=CMD\fP]
+\fBxpra\fP \fBattach\fP [\fI:DISPLAY\fP | \fIssh:HOST[:port]:DISPLAY\fP | \fItcp:HOST:DISPLAY\fP] [\fB\-\-remote\-xpra=CMD\fP] [\fB--ssh-compression\fP]
 .HP
-\fBxpra\fP \fBstop\fP [\fI:DISPLAY\fP | \fIssh:HOST:DISPLAY\fP | \fItcp:HOST:DISPLAY\fP] [\fB\-\-remote\-xpra=CMD\fP]
+\fBxpra\fP \fBstop\fP [\fI:DISPLAY\fP | \fIssh:HOST[:port]:DISPLAY\fP | \fItcp:HOST:DISPLAY\fP] [\fB\-\-remote\-xpra=CMD\fP]
 .HP
 \fBxpra\fP \fBlist\fP
 .HP
@@ -64,6 +64,10 @@ Use ssh to attach to the xpra server that is running on machine
 \fIfrodo\fP and using display \fI:7\fP.  Any apps running on that
 server will appear on your local screen.
 .TP
+\fBxpra attach\fP \fIssh:frodo:2222:7\fP
+Same as above, but will use port \fI2222\fP instead of the default port
+\fI22\fP for the ssh connection.
+.TP
 \fBxpra start\fP \fI:7\fP \fB&& DISPLAY=\fP\fI:7\fP \fBscreen\fP
 Start an xpra server and a \fBscreen\fP(1) session.  If any of the
 applications inside screen attempt to use X, they will be directed to
@@ -109,20 +113,22 @@ numbers near ten (10, 11, 12, ...).
 When specifying an xpra server to a client program like \fBxpra
 attach\fP or \fBxpra stop\fP, then you can use a display of the form
 \fB:\fP\fINUMBER\fP to refer to a server on the local host, or one of
-the form \fBssh:\fP\fIHOST\fP\fB:\fP\fINUMBER\fP to refer to a server
-on a remote host; xpra will automatically connect to the remote host
-using \fBssh\fP(1).  Generally, if you have only one xpra server
-running on a machine, then you can omit the number entirely; \fBxpra
-attach\fP alone will attach to the lone xpra server on the current
+the form \fBssh:\fP\fIHOST\fP\fB:\fP\fINUMBER\fP or \fBssh:\fP\fIHOST
+\fP\fB:\fP\fIPORT\fP\fB:\fP\fINUMBER\fP to refer to a server on a
+remote host; xpra will automatically connect to the remote host using
+\fBssh\fP(1). The later allows you to connect to a ssh server running
+on a non-standard port number.  Generally, if you have only one xpra
+server running on a machine, then you can omit the number entirely;
+\fBxpra attach\fP alone will attach to the lone xpra server on the current
 machine regardless of its number, \fBxpra attach ssh:frodo\fP will
 similarly attach to the lone xpra server on a remote machine.
 
 If the xpra server was given the \fB\-\-bind\-tcp\fP option when
 started (which is a major security risk, and not recommended!), then
 you can also connect to it using a display of the form
-\fBtcp:HOST:PORT\fP. (Notice that \fBssh:\fP takes an optional
-\fIdisplay\fP number, while \fBtcp:\fP takes a required \fIport\fP
-number.)
+\fBtcp:HOST:PORT\fP. (Notice that \fBssh:\fP takes up to 2 optional
+parameters \fIdisplay\fP number or \fIport\fP:\fIdisplay\fP, while
+\fBtcp:\fP takes a required \fIport\fP number.)
 .\" --------------------------------------------------------------------
 .SH SUBCOMMANDS
 .SS xpra start
@@ -164,6 +170,13 @@ look something like \fBxpra.protocol.raw\fP or \fBwimpiggy\fP
 (wimpiggy is the name of one of xpra's underlying libraries).  A
 filter like \fBxpra.protocol.raw\fP is more specific than one like
 \fBxpra.protocol\fP.
+.SS Options for attach
+.TP
+\fB\-C\fP, \fB\-\-ssh-compression\fP
+Request ssh compression.  This option is only meaningfull when using ssh.
+This is usefull when you're on a slow connection (eg modem, wifi), but
+will likely only slow things down on fast connections (eg LAN).
+Please refer to \fBssh\fP(1) for more details on the compression request.
 .SS Options for start, upgrade
 .TP
 \fB\-\-start\-child=\fP\fICMD\fP
diff --git a/foreign/xpra/parti-all-0.0.6/xpra/scripts/main.py b/foreign/xpra/parti-all-0.0.6/xpra/scripts/main.py
index e36511b..7d51037 100644
--- a/foreign/xpra/parti-all-0.0.6/xpra/scripts/main.py
+++ b/foreign/xpra/parti-all-0.0.6/xpra/scripts/main.py
@@ -59,6 +59,9 @@ def main(script_file, cmdline):
     parser.add_option("-d", "--debug", action="store",
                       dest="debug", default=None, metavar="FILTER1,FILTER2,...",
                       help="List of categories to enable debugging for (or \"all\")")
+    parser.add_option("-C", "--ssh-compression", action="store_true",
+                      dest="ssh_compress", default=None,
+                      help="Request ssh compression (see ssh(1) for details on the -C switch). Good for slow network connections.")
     (options, args) = parser.parse_args(cmdline[1:])
 
     if not args:
@@ -115,8 +118,15 @@ def pick_display(parser, extra_args):
 def client_sock(parser, opts, display_name):
     if display_name.startswith("ssh:"):
         sshspec = display_name[len("ssh:"):]
+        port = None
         if ":" in sshspec:
-            (host, display) = sshspec.split(":", 1)
+            # sshspec is "ssh:host:disp" or "ssh:host:port:disp"
+            ssh_args = sshspec.split(":", 2)
+            if len(ssh_args) == 3:
+                (host, port, display) = ssh_args
+            else:
+                (host, display) = ssh_args
+
             display_args = [":" + display]
         else:
             host = sshspec
@@ -126,9 +136,40 @@ def client_sock(parser, opts, display_name):
             remote_xpra = opts.remote_xpra.split()
         else:
             remote_xpra = ["$HOME/.xpra/run-xpra"]
-        
-        p = subprocess.Popen(["ssh", host, "-e", "none"]
-                             + remote_xpra + ["_proxy"] + display_args,
+
+        ssh_cmd=["ssh", host, "-e", "none"]
+
+        if opts.ssh_compress != None:
+            # enable compression
+            ssh_cmd.append('-C')
+
+        if port != None:
+            # set non standard port
+            ssh_cmd.append("-p")
+            ssh_cmd.append(port)
+
+        # FIXME: probably incorrect usage of opts.debug, please advise.
+        if opts.debug == 'all' or \
+                'ssh' in [x[:3] for x in opts.debug.split(',')]:
+            # set verbose for ssh
+
+            # filter out strings that would match /ssh.*/
+            # and select the _first_ one
+            tmp = [x for x in opts.debug.split(',') if x[:3] == 'ssh'][0]
+
+            if tmp == 'ssh':
+                ssh_cmd.append('-v')
+            else:
+                # tmp mathces /ssh.+/, we expect: /ssh([0-9]).*/
+                # so tmp[3:4] should be /[0-9]/, int will raise
+                # a ValueError exception otherwise.
+                #
+                # N.B: up to most -vvv is accepted by (Open)SSH.
+                ssh_cmd.append('-' +  'v'*min(3, int(tmp[3:4])))
+
+            print '>>>', str(ssh_cmd)
+
+        p = subprocess.Popen(ssh_cmd + remote_xpra + ["_proxy"] + display_args,
                              stdin=b.fileno(), stdout=b.fileno(),
                              bufsize=0)
         return a, False
_______________________________________________
Parti-discuss mailing list
[email protected]
http://lists.partiwm.org/cgi-bin/mailman/listinfo/parti-discuss

Reply via email to