Example #1
0
 ///<summary>Processes a PORT command, sent from the client.</summary>
 ///<param name="Input">The parameters of the PORT command.</param>
 private void ProcessPortCommand(string Input)
 {
     try {
         string [] Parts = Input.Split(',');
         if (Parts.Length == 6)
         {
             DataForward = new FtpDataConnection();
             string Reply = DataForward.ProcessPort(new IPEndPoint(IPAddress.Parse(String.Join(".", Parts, 0, 4)), int.Parse(Parts[4]) * 256 + int.Parse(Parts[5])));
             DestinationSocket.BeginSend(Encoding.ASCII.GetBytes(Reply), 0, Reply.Length, SocketFlags.None, new AsyncCallback(this.OnCommandSent), DestinationSocket);
         }
     } catch {
         Dispose();
     }
 }
Example #2
0
        ///<summary>Processes an FTP command, sent from the client.</summary>
        ///<param name="Command">The command to process.</param>
        ///<returns>True if the command may be sent to the server, false otherwise.</returns>
        private bool ProcessCommand(string Command)
        {
            try
            {
                int Ret = Command.IndexOf(' ');
                if (Ret < 0)
                {
                    Ret = Command.Length;
                }
                switch (Command.Substring(0, Ret).ToUpper().Trim())
                {
                case "OPEN":
                    ConnectTo(ParseIPPort(Command.Substring(Ret + 1)));
                    break;

                case "USER":
                    Ret = Command.IndexOf('@');
                    if (Ret < 0)
                    {
                        return(true);
                    }
                    else
                    {
                        User = Command.Substring(0, Ret).Trim() + "\r\n";
                        ConnectTo(ParseIPPort(Command.Substring(Ret + 1)));
                    }
                    break;

                case "PORT":
                    ProcessPortCommand(Command.Substring(5).Trim());
                    break;

                case "PASV":
                    DataForward = new FtpDataConnection();
                    DataForward.ProcessPasv(this);
                    return(true);

                default:
                    return(true);
                }
                return(false);
            }
            catch
            {
                Dispose();
                return(false);
            }
        }
Example #3
0
	///<summary>Processes an FTP command, sent from the client.</summary>
	///<param name="Command">The command to process.</param>
	///<returns>True if the command may be sent to the server, false otherwise.</returns>
	private bool ProcessCommand(string Command) {
		try {
			int Ret = Command.IndexOf(' ');
			if (Ret < 0) 
				Ret = Command.Length;
			switch (Command.Substring(0, Ret).ToUpper().Trim()) {
				case "OPEN":
					ConnectTo(ParseIPPort(Command.Substring(Ret + 1)));
					break;
				case "USER":
					Ret = Command.IndexOf('@');
					if (Ret < 0) {
						return true;
					} else {
						User = Command.Substring(0, Ret).Trim() + "\r\n";
						ConnectTo(ParseIPPort(Command.Substring(Ret + 1)));
					}
					break;
				case "PORT":
					ProcessPortCommand(Command.Substring(5).Trim());
					break;
				case "PASV":
					DataForward = new FtpDataConnection();
					DataForward.ProcessPasv(this);
					return true;
				default:
					return true;
			}
			return false;
		} catch {
			Dispose();
			return false;
		}
	}
Example #4
0
	///<summary>Processes a PORT command, sent from the client.</summary>
	///<param name="Input">The parameters of the PORT command.</param>
	private void ProcessPortCommand(string Input) {
		try {
			string [] Parts = Input.Split(',');
			if (Parts.Length == 6) {
				DataForward = new FtpDataConnection();
				string Reply = DataForward.ProcessPort(new IPEndPoint(IPAddress.Parse(String.Join(".", Parts, 0, 4)), int.Parse(Parts[4]) * 256 + int.Parse(Parts[5])));
				DestinationSocket.BeginSend(Encoding.ASCII.GetBytes(Reply), 0, Reply.Length, SocketFlags.None, new AsyncCallback(this.OnCommandSent), DestinationSocket);
			}
		} catch {
			Dispose();
		}
	}