예제 #1
0
 public void PushNewConfig(FtpConnectionSettings NewConfig)
 {
     if (Connection.IsConnected() || ServerThread != null)
     {
         throw new Exception("cannot_change_config_at_service_runtime");
     }
     CurrentConfig = NewConfig;
 }
예제 #2
0
 private void SetupConfig()
 {
     FtpConfig = new FtpConnectionSettings();
     if (!FtpConfig.TryReadFromFile(ConfigFilenameFtp))
     {
         MessageBox.Show("FTP config file could not be parsed (either missing or corrupted).\nPlease fill your information in the config menu.");
     }
 }
예제 #3
0
        public Configuration(FtpConnectionSettings InFtp)
        {
            InitializeComponent();

            InFtpSrettings = InFtp;

            TempFtpSettings = new FtpConnectionSettings();
            TempFtpSettings.CloneFrom(InFtp);

            InFtpHostname.Text      = TempFtpSettings.Hostname;
            InFtpPort.Text          = TempFtpSettings.Port.ToString();
            InFtpUsername.Text      = TempFtpSettings.UserLogin;
            InFtpPassword.Text      = TempFtpSettings.UserPassword;
            CheckFtpSsl.Checked     = TempFtpSettings.UseSsl;
            EnableUnixListing.Value = TempFtpSettings.UnixListing ? 1 : 0;
        }
        internal override bool ParseResponse(string Response)
        {
            Success = Response.StartsWith("229");
            if (!Success)
            {
                switch (NewMode)
                {
                case FtpService.Mode.PassiveV4:
                    NewMode = FtpService.Mode.None;
                    return(true);

                case FtpService.Mode.PassiveV6:
                    NewMode = FtpService.Mode.PassiveV4;
                    return(true);

                default: return(false);
                }
            }
            else
            {
                string IpData = Response.Split('(', ')')[1];
                switch (NewMode)
                {
                case FtpService.Mode.PassiveV4:
                    throw new NotImplementedException();

                case FtpService.Mode.PassiveV6:
                    string Port = IpData.Split(new char[] { '|' }, StringSplitOptions.None)[3];
                    if (!UInt16.TryParse(Port, out TargetPort))
                    {
                        return(false);
                    }
                    TargetHost = ParentService.GetConfig().Hostname;
                    break;
                }
            }

            FtpConnectionSettings DataSettings = new FtpConnectionSettings();

            DataSettings.Hostname    = TargetHost;
            DataSettings.Port        = TargetPort;
            DataSettings.UseSsl      = false;
            ParentService.DataConfig = DataSettings;
            return(true);
        }
예제 #5
0
        internal override string BuildVerb()
        {
            Creds = ParentService.GetConfig();

            switch (AuthState)
            {
            case AuthorizationState.NotStarted:
                AuthState = AuthorizationState.SentLogin;
                return("USER " + Creds.UserLogin + EOL);

            case AuthorizationState.AcceptedLogin:
                AuthState = AuthorizationState.SentPassword;
                return("PASS " + Creds.UserPassword + EOL);

            default:
                throw new Exception("no_verbs_left");
            }
        }