Skip to content

Commit

Permalink
Fix #2944.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkocher committed Mar 15, 2011
1 parent 788ab9b commit f8a912f
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 67 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2051,6 +2051,7 @@ source/ch/cyberduck/ui/winforms/taskdialog/VistaTaskDialog.cs -text
source/ch/cyberduck/ui/winforms/taskdialog/VistaTaskDialogCommonDialog.cs -text
source/ch/cyberduck/ui/winforms/taskdialog/VistaTaskDialogNotificationArgs.cs -text
source/ch/cyberduck/ui/winforms/taskdialog/VistaUnsafeNativeMethods.cs -text
source/ch/ethz/ssh2/sftp/PacketListener.java -text
source/com/snoize/SNDisclosableView.m -text
source/de/zathras/UKCrashReporter.m -text
source/de/zathras/UKSystemInfo.h -text
Expand Down
22 changes: 15 additions & 7 deletions source/ch/cyberduck/core/sftp/SFTPSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
import ch.cyberduck.core.*;
import ch.cyberduck.core.Session;
import ch.cyberduck.core.i18n.Locale;
import ch.ethz.ssh2.*;
import ch.ethz.ssh2.channel.ChannelClosedException;
import ch.ethz.ssh2.crypto.PEMDecoder;
import ch.ethz.ssh2.crypto.PEMDecryptException;
import ch.ethz.ssh2.sftp.PacketListener;
import ch.ethz.ssh2.sftp.SFTPv3Client;

import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
Expand All @@ -30,12 +36,6 @@

import java.io.*;

import ch.ethz.ssh2.*;
import ch.ethz.ssh2.channel.ChannelClosedException;
import ch.ethz.ssh2.crypto.PEMDecoder;
import ch.ethz.ssh2.crypto.PEMDecryptException;
import ch.ethz.ssh2.sftp.SFTPv3Client;

/**
* @version $Id$
*/
Expand Down Expand Up @@ -97,7 +97,15 @@ protected SFTPv3Client sftp() throws IOException {
throw new LoginCanceledException();
}
this.message(Locale.localizedString("Starting SFTP subsystem", "Status"));
SFTP = new SFTPv3Client(this.getClient());
SFTP = new SFTPv3Client(this.getClient(), new PacketListener() {
public void read(String packet) {
SFTPSession.this.log(false, packet);
}

public void write(String packet) {
SFTPSession.this.log(true, packet);
}
});
this.message(Locale.localizedString("SFTP subsystem ready", "Status"));
SFTP.setCharset(this.getEncoding());
}
Expand Down
124 changes: 90 additions & 34 deletions source/ch/ethz/ssh2/sftp/Packet.java
Original file line number Diff line number Diff line change
@@ -1,43 +1,99 @@

package ch.ethz.ssh2.sftp;

/**
*
* SFTP Paket Types
*
* @author Christian Plattner, plattner@inf.ethz.ch
* @version $Id$
*
*/
public class Packet
{
public static final int SSH_FXP_INIT = 1;
public static final int SSH_FXP_VERSION = 2;
public static final int SSH_FXP_OPEN = 3;
public static final int SSH_FXP_CLOSE = 4;
public static final int SSH_FXP_READ = 5;
public static final int SSH_FXP_WRITE = 6;
public static final int SSH_FXP_LSTAT = 7;
public static final int SSH_FXP_FSTAT = 8;
public static final int SSH_FXP_SETSTAT = 9;
public static final int SSH_FXP_FSETSTAT = 10;
public static final int SSH_FXP_OPENDIR = 11;
public static final int SSH_FXP_READDIR = 12;
public static final int SSH_FXP_REMOVE = 13;
public static final int SSH_FXP_MKDIR = 14;
public static final int SSH_FXP_RMDIR = 15;
public static final int SSH_FXP_REALPATH = 16;
public static final int SSH_FXP_STAT = 17;
public static final int SSH_FXP_RENAME = 18;
public static final int SSH_FXP_READLINK = 19;
public static final int SSH_FXP_SYMLINK = 20;

public static final int SSH_FXP_STATUS = 101;
public static final int SSH_FXP_HANDLE = 102;
public static final int SSH_FXP_DATA = 103;
public static final int SSH_FXP_NAME = 104;
public static final int SSH_FXP_ATTRS = 105;

public static final int SSH_FXP_EXTENDED = 200;
public static final int SSH_FXP_EXTENDED_REPLY = 201;
public class Packet {
public static final int SSH_FXP_INIT = 1;
public static final int SSH_FXP_VERSION = 2;
public static final int SSH_FXP_OPEN = 3;
public static final int SSH_FXP_CLOSE = 4;
public static final int SSH_FXP_READ = 5;
public static final int SSH_FXP_WRITE = 6;
public static final int SSH_FXP_LSTAT = 7;
public static final int SSH_FXP_FSTAT = 8;
public static final int SSH_FXP_SETSTAT = 9;
public static final int SSH_FXP_FSETSTAT = 10;
public static final int SSH_FXP_OPENDIR = 11;
public static final int SSH_FXP_READDIR = 12;
public static final int SSH_FXP_REMOVE = 13;
public static final int SSH_FXP_MKDIR = 14;
public static final int SSH_FXP_RMDIR = 15;
public static final int SSH_FXP_REALPATH = 16;
public static final int SSH_FXP_STAT = 17;
public static final int SSH_FXP_RENAME = 18;
public static final int SSH_FXP_READLINK = 19;
public static final int SSH_FXP_SYMLINK = 20;

public static final int SSH_FXP_STATUS = 101;
public static final int SSH_FXP_HANDLE = 102;
public static final int SSH_FXP_DATA = 103;
public static final int SSH_FXP_NAME = 104;
public static final int SSH_FXP_ATTRS = 105;

public static final int SSH_FXP_EXTENDED = 200;
public static final int SSH_FXP_EXTENDED_REPLY = 201;

public static String forName(int type) {
switch(type) {
case SSH_FXP_INIT:
return "SSH_FXP_INIT";
case SSH_FXP_VERSION:
return "SSH_FXP_VERSION";
case SSH_FXP_OPEN:
return "SSH_FXP_OPEN";
case SSH_FXP_CLOSE:
return "SSH_FXP_CLOSE";
case SSH_FXP_READ:
return "SSH_FXP_READ";
case SSH_FXP_WRITE:
return "SSH_FXP_WRITE";
case SSH_FXP_LSTAT:
return "SSH_FXP_LSTAT";
case SSH_FXP_FSTAT:
return "SSH_FXP_FSTAT";
case SSH_FXP_SETSTAT:
return "SSH_FXP_SETSTAT";
case SSH_FXP_FSETSTAT:
return "SSH_FXP_FSETSTAT";
case SSH_FXP_OPENDIR:
return "SSH_FXP_OPENDIR";
case SSH_FXP_READDIR:
return "SSH_FXP_READDIR";
case SSH_FXP_REMOVE:
return "SSH_FXP_REMOVE";
case SSH_FXP_MKDIR:
return "SSH_FXP_MKDIR";
case SSH_FXP_RMDIR:
return "SSH_FXP_RMDIR";
case SSH_FXP_REALPATH:
return "SSH_FXP_REALPATH";
case SSH_FXP_STAT:
return "SSH_FXP_STAT";
case SSH_FXP_RENAME:
return "SSH_FXP_RENAME";
case SSH_FXP_READLINK:
return "SSH_FXP_READLINK";
case SSH_FXP_SYMLINK:
return "SSH_FXP_SYMLINK";
case SSH_FXP_STATUS:
return "SSH_FXP_STATUS";
case SSH_FXP_HANDLE:
return "SSH_FXP_HANDLE";
case SSH_FXP_DATA:
return "SSH_FXP_DATA";
case SSH_FXP_NAME:
return "SSH_FXP_NAME";
case SSH_FXP_ATTRS:
return "SSH_FXP_ATTRS";
case SSH_FXP_EXTENDED:
return "SSH_FXP_EXTENDED";
case SSH_FXP_EXTENDED_REPLY:
return "SSH_FXP_EXTENDED_REPLY";
}
return null;
}
}
29 changes: 29 additions & 0 deletions source/ch/ethz/ssh2/sftp/PacketListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package ch.ethz.ssh2.sftp;

/*
* Copyright (c) 2002-2011 David Kocher. All rights reserved.
*
* http://cyberduck.ch/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* Bug fixes, suggestions and comments should be sent to:
* dkocher@cyberduck.ch
*/

/**
* @version $Id:$
*/
public interface PacketListener {
void read(String packet);

void write(String packet);
}
Loading

0 comments on commit f8a912f

Please sign in to comment.