01: package com.coldcore.coloradoftp.connection;
02:
03: /**
04: * Initiates a data connection with user.
05: *
06: * This class establishes a new connection to user's machine as a result of a PORT command.
07: * This class is a part of a control connection and is created on a per user basis.
08: *
09: * When a user wants a server to establish a data connection with his/her machine, this class
10: * is executed by a control connection untill a data connection is established or failed.
11: * In the latter case it is a responsibility of this class to send a failed reply to the user
12: * (this will also clear the INTERRUPT state of the control connection).
13: * Otherwise, if data connection is established, this class must add it to a connection pool
14: * and set control connection's reference to the new data connection.
15: *
16: * This class can establish connection with user only after user gets "150" reply from the
17: * control connection and not before. Data port listener and data connection do not have to
18: * check for "150" reply, but this class has to.
19: *
20: * The easiest way to test this condition is:
21: * 1. Before producing "150" relpy, a command saves into a user session amount of bytes
22: * the control connection has sent to the user so far (byte marker)
23: * 2. This class must wait until byte marker apperas in the session and the control
24: * connection writes beyond it
25: * 3. When control connection clears its outgoing buffer the "150" reply is sent to the user
26: * NB! This class may or may not remove byte marker from the session later, so it is the
27: * responsibility of a file command to clear the byte marker before initiating a new
28: * data connection to make sure that this class will wait for a proper "150" reply.
29: *
30: *
31: * ColoradoFTP - The Open Source FTP Server (http://cftp.coldcore.com)
32: */
33: public interface DataConnectionInitiator {
34:
35: /** Set IP address to connect to
36: * @param ip User's IP address
37: */
38: public void setIp(String ip);
39:
40: /** Get IP address to connect to
41: * @return User's IP address
42: */
43: public String getIp();
44:
45: /** Set port number to connect to
46: * @param port User's port number
47: */
48: public void setPort(int port);
49:
50: /** Get port number to connect to
51: * @return User's port number
52: */
53: public int getPort();
54:
55: /** Test if data connection initiator is active and should be executed by a control connection.
56: * @return TRUE if it is active, FALSE otherwise
57: */
58: public boolean isActive();
59:
60: /** Activate (start connecting) */
61: public void activate();
62:
63: /** Abort data connection initializer (if active then stop connection attempts and send failed reply).
64: * This method has nothong to do with ABOR command and reply must not be to ABOR command.
65: */
66: public void abort();
67:
68: /** Get control connection of this data connection initiator
69: * @return Control connection
70: */
71: public ControlConnection getControlConnection();
72:
73: /** Set control connection of this control connection initiator
74: * @param controlConnection Control connection
75: */
76: public void setControlConnection(ControlConnection controlConnection);
77: }
|