diff --git a/primitiveFTPd/src/org/primftpd/events/ClientActionEvent.java b/primitiveFTPd/src/org/primftpd/events/ClientActionEvent.java index 0de192c5..526a51e3 100644 --- a/primitiveFTPd/src/org/primftpd/events/ClientActionEvent.java +++ b/primitiveFTPd/src/org/primftpd/events/ClientActionEvent.java @@ -10,8 +10,7 @@ public enum Storage { ROOT, SAF, ROSAF, - QUICKSHARE, - CONFIG + QUICKSHARE } public enum Protocol { diff --git a/primitiveFTPd/src/org/primftpd/filesystem/VirtualConfigFile.java b/primitiveFTPd/src/org/primftpd/filesystem/VirtualConfigFile.java deleted file mode 100644 index e3ca1016..00000000 --- a/primitiveFTPd/src/org/primftpd/filesystem/VirtualConfigFile.java +++ /dev/null @@ -1,105 +0,0 @@ -package org.primftpd.filesystem; - -import org.primftpd.events.ClientActionEvent; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.nio.charset.StandardCharsets; - -/** - * Provides a virtual file to allow clients to read some of server's config. - * - * To support "prim-sync", see prim-sync - * - * For more details see PR - */ -public abstract class VirtualConfigFile extends AbstractFile { - - public static final String NAME = "primftpd.config"; - public static final String ABS_PATH = "/" + NAME; - - private final String content; - - public VirtualConfigFile( - TFileSystemView fileSystemView) { - super( - fileSystemView, - ABS_PATH, - NAME); - this.content = getContent(); - } - - private String getContent() { - return - "{" + - "\"announceName\":\"" + getPftpdService().getPrefsBean().getAnnounceName().replace("\"", "\\\"") + "\"" + - "}"; - } - - public ClientActionEvent.Storage getClientActionStorage() { - return ClientActionEvent.Storage.CONFIG; - } - - public boolean isDirectory() { - return false; - } - - public boolean doesExist() { - return true; - } - - public boolean isReadable() { - return true; - } - - public long getLastModified() { - return 0; - } - - public long getSize() { - return content.length(); - } - - public boolean isFile() { - return true; - } - - public boolean isWritable() { - return false; - } - - public boolean isRemovable() { - return false; - } - - public boolean setLastModified(long time) { - return false; - } - - public boolean mkdir() { - return false; - } - - public boolean delete() { - return false; - } - - public boolean move(AbstractFile target) { - return false; - } - - public OutputStream createOutputStream(long offset) throws IOException{ - throw new IOException(String.format("Can not write file '%s'", absPath)); - } - - public InputStream createInputStream(long offset) { - logger.trace("[{}] createInputStream(offset: {})", name, offset); - postClientAction(ClientActionEvent.ClientAction.DOWNLOAD); - - ByteArrayInputStream bais = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)); - bais.skip(offset); - return bais; - } -} diff --git a/primitiveFTPd/src/org/primftpd/filesystem/VirtualFileSystemView.java b/primitiveFTPd/src/org/primftpd/filesystem/VirtualFileSystemView.java index d31f0be5..da2008b4 100644 --- a/primitiveFTPd/src/org/primftpd/filesystem/VirtualFileSystemView.java +++ b/primitiveFTPd/src/org/primftpd/filesystem/VirtualFileSystemView.java @@ -35,8 +35,6 @@ public VirtualFileSystemView( public abstract TMina createFile(String absPath, AbstractFile delegate); public abstract TMina createFile(String absPath, boolean exists); - public abstract VirtualConfigFile getConfigFile(); - protected abstract String absolute(String file); public TMina getFile(String file) { @@ -64,10 +62,6 @@ public TMina getFile(String file) { logger.debug("Using ROSAF '{}' for '{}'", realPath, absoluteVirtualPath); AbstractFile delegate = roSafFileSystemView.getFile(realPath); return createFile(absoluteVirtualPath, delegate); - } else if (VirtualConfigFile.ABS_PATH.equals(absoluteVirtualPath)) { - logger.debug("Using VirtualFile for CONFIG path '{}'", absoluteVirtualPath); - AbstractFile delegate = getConfigFile(); - return createFile(absoluteVirtualPath, delegate); } else{ logger.debug("Using VirtualFile for unknown path '{}'", absoluteVirtualPath); return createFile(absoluteVirtualPath, false); diff --git a/primitiveFTPd/src/org/primftpd/filesystem/VirtualFtpConfigFile.java b/primitiveFTPd/src/org/primftpd/filesystem/VirtualFtpConfigFile.java deleted file mode 100644 index 988d83da..00000000 --- a/primitiveFTPd/src/org/primftpd/filesystem/VirtualFtpConfigFile.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.primftpd.filesystem; - -import org.apache.ftpserver.ftplet.User; - -public class VirtualFtpConfigFile extends VirtualConfigFile { - - private final User user; - - public VirtualFtpConfigFile(VirtualFtpFileSystemView fileSystemView, User user) { - super(fileSystemView); - this.user = user; - } - - @Override - public String getClientIp() { - return FtpUtils.getClientIp(user); - } -} diff --git a/primitiveFTPd/src/org/primftpd/filesystem/VirtualFtpFileSystemView.java b/primitiveFTPd/src/org/primftpd/filesystem/VirtualFtpFileSystemView.java index 7984bdb1..57cdc8f7 100644 --- a/primitiveFTPd/src/org/primftpd/filesystem/VirtualFtpFileSystemView.java +++ b/primitiveFTPd/src/org/primftpd/filesystem/VirtualFtpFileSystemView.java @@ -44,11 +44,6 @@ public FtpFile createFile(String absPath, boolean exists) { return new VirtualFtpFile(this, absPath, exists, user); } - @Override - public VirtualFtpConfigFile getConfigFile() { - return new VirtualFtpConfigFile(this, user); - } - @Override protected String absolute(String file) { logger.trace(" finding abs path for '{}' with wd '{}'", file, (workingDir != null ? workingDir.getAbsolutePath() : "null")); diff --git a/primitiveFTPd/src/org/primftpd/filesystem/VirtualSshConfigFile.java b/primitiveFTPd/src/org/primftpd/filesystem/VirtualSshConfigFile.java deleted file mode 100644 index 02ddb2f6..00000000 --- a/primitiveFTPd/src/org/primftpd/filesystem/VirtualSshConfigFile.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.primftpd.filesystem; - -import org.apache.sshd.common.Session; - -public class VirtualSshConfigFile extends VirtualConfigFile { - - private final Session session; - - public VirtualSshConfigFile(VirtualSshFileSystemView fileSystemView, Session session) { - super(fileSystemView); - this.session = session; - } - - @Override - public String getClientIp() { - return SshUtils.getClientIp(session); - } -} diff --git a/primitiveFTPd/src/org/primftpd/filesystem/VirtualSshFileSystemView.java b/primitiveFTPd/src/org/primftpd/filesystem/VirtualSshFileSystemView.java index 9f7a2b00..7b4c1a18 100644 --- a/primitiveFTPd/src/org/primftpd/filesystem/VirtualSshFileSystemView.java +++ b/primitiveFTPd/src/org/primftpd/filesystem/VirtualSshFileSystemView.java @@ -40,11 +40,6 @@ public SshFile createFile(String absPath, boolean exists) { return new VirtualSshFile(this, absPath, exists, session); } - @Override - public VirtualSshConfigFile getConfigFile() { - return new VirtualSshConfigFile(this, session); - } - @Override protected String absolute(String file) { return Utils.absoluteOrHome(file, "/" + PREFIX_FS + homeDir.getAbsolutePath());