Package org.h2.dev.ftp.server
Class FtpServer
java.lang.Object
org.h2.util.Tool
org.h2.dev.ftp.server.FtpServer
- All Implemented Interfaces:
Service
Small FTP Server. Intended for ad-hoc networks in a secure environment.
Remote connections are possible.
See also https://cr.yp.to/ftp.html http://www.ftpguide.com/
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default port to use for the FTP server.static final StringThe default user name that is allowed to read data.static final StringThe default root directory name used by the FTP server.static final StringThe default user name that is allowed to read and write data.static final StringThe default password of the user that is allowed to read and write data. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ServercreateFtpServer(String... args) Create a new FTP server, but does not start it yet.booleanCheck if remote connections are allowed.getName()Get the human readable name of the service.intgetPort()Gets the port this service is listening on.getType()Get the human readable short name of the service.getURL()Get the URL of this service in a human readable formvoidInitialize the service from command line options.booleanisDaemon()Check if a daemon thread should be used.booleanisRunning(boolean traceError) Check if the service is running.voidlisten()Listen for incoming connections.static voidWhen running without options, -tcp, -web, -browser, and -pg are started.voidRun the tool with the given output stream and arguments.voidsetEventListener(FtpEventListener eventListener) Set the event listener.voidstart()Start the service.voidstop()Stop the service.Methods inherited from class org.h2.util.Tool
getMainClassName, isOption, printNoDatabaseFilesFound, setOut, showUsage, showUsageAndThrowUnsupportedOption, throwUnsupportedOption
-
Field Details
-
DEFAULT_PORT
public static final int DEFAULT_PORTThe default port to use for the FTP server. This value is also in the documentation and in the Server javadoc.- See Also:
-
DEFAULT_ROOT
The default root directory name used by the FTP server. This value is also in the documentation and in the Server javadoc.- See Also:
-
DEFAULT_READ
The default user name that is allowed to read data. This value is also in the documentation and in the Server javadoc.- See Also:
-
DEFAULT_WRITE
The default user name that is allowed to read and write data. This value is also in the documentation and in the Server javadoc.- See Also:
-
DEFAULT_WRITE_PASSWORD
The default password of the user that is allowed to read and write data. This value is also in the documentation and in the Server javadoc.- See Also:
-
-
Constructor Details
-
FtpServer
public FtpServer()
-
-
Method Details
-
main
When running without options, -tcp, -web, -browser, and -pg are started. Options are case sensitive.Supported options [-help] or [-?] Print the list of options [-web] Start the web server with the H2 Console [-webAllowOthers] Allow other computers to connect [-webPort <port>] The port (default: 8082) [-webSSL] Use encrypted (HTTPS) connections [-browser] Start a browser and open a page to login to the web server [-tcp] Start the TCP server [-tcpAllowOthers] Allow other computers to connect [-tcpPort <port>] The port (default: 9092) [-tcpSSL] Use encrypted (SSL) connections [-tcpPassword <pwd>] The password for shutting down a TCP server [-tcpShutdown "<url>"] Stop the TCP server; example: tcp://localhost:9094 [-tcpShutdownForce] Do not wait until all connections are closed [-pg] Start the PG server [-pgAllowOthers] Allow other computers to connect [-pgPort <port>] The port (default: 5435) [-ftp] Start the FTP server [-ftpPort <port>] The port (default: 8021) [-ftpDir <dir>] The base directory (default: ftp) [-ftpRead <user>] The user name for reading (default: guest) [-ftpWrite <user>] The user name for writing (default: sa) [-ftpWritePassword <p>] The write password (default: sa) [-baseDir <dir>] The base directory for H2 databases; for all servers [-ifExists] Only existing databases may be opened; for all servers [-trace] Print additional trace information; for all servers - Parameters:
args- the command line arguments- Throws:
SQLException
-
runTool
Description copied from class:ToolRun the tool with the given output stream and arguments.- Specified by:
runToolin classTool- Parameters:
args- the argument list- Throws:
SQLException- on failure
-
listen
public void listen()Description copied from interface:ServiceListen for incoming connections. This method blocks. -
init
Description copied from interface:ServiceInitialize the service from command line options. -
getURL
Description copied from interface:ServiceGet the URL of this service in a human readable form -
getPort
public int getPort()Description copied from interface:ServiceGets the port this service is listening on. -
start
public void start()Description copied from interface:ServiceStart the service. This usually means create the server socket. This method must not block. -
stop
public void stop()Description copied from interface:ServiceStop the service. -
isRunning
public boolean isRunning(boolean traceError) Description copied from interface:ServiceCheck if the service is running. -
getAllowOthers
public boolean getAllowOthers()Description copied from interface:ServiceCheck if remote connections are allowed.- Specified by:
getAllowOthersin interfaceService- Returns:
- true if remote connections are allowed
-
getType
Description copied from interface:ServiceGet the human readable short name of the service. -
getName
Description copied from interface:ServiceGet the human readable name of the service. -
setEventListener
Set the event listener. Only one listener can be registered.- Parameters:
eventListener- the new listener, or null to de-register
-
createFtpServer
Create a new FTP server, but does not start it yet. Example:Server server = FtpServer.createFtpServer(null).start();
- Parameters:
args- the argument list- Returns:
- the server
- Throws:
SQLException
-
isDaemon
public boolean isDaemon()Description copied from interface:ServiceCheck if a daemon thread should be used.
-