From 594e7eb1dd904585974c1d3b5d8e969899e32744 Mon Sep 17 00:00:00 2001 From: Eveldee Date: Sun, 21 Jul 2019 21:28:28 +0200 Subject: [PATCH] Add BypassGuestPassword configuration Used to bypass the password for local connections --- DearFTP/Configurations/ServerConfiguration.cs | 1 + DearFTP/Connection/Commands/UserCommand.cs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/DearFTP/Configurations/ServerConfiguration.cs b/DearFTP/Configurations/ServerConfiguration.cs index 25ffc49..7da8362 100644 --- a/DearFTP/Configurations/ServerConfiguration.cs +++ b/DearFTP/Configurations/ServerConfiguration.cs @@ -13,5 +13,6 @@ public string LogFilePath { get; set; } = "log.txt"; public string Guest { get; set; } = ""; + public bool BypassGuestPassword { get; set; } = false; } } diff --git a/DearFTP/Connection/Commands/UserCommand.cs b/DearFTP/Connection/Commands/UserCommand.cs index 46af1c1..ff3af45 100644 --- a/DearFTP/Connection/Commands/UserCommand.cs +++ b/DearFTP/Connection/Commands/UserCommand.cs @@ -1,4 +1,5 @@ using DearFTP.Utils; +using DearFTP.Utils.Extensions; using System; using System.Linq; @@ -30,7 +31,7 @@ namespace DearFTP.Connection.Commands user = configuration.Users.First(x => x.Name == guest); } - if (!string.IsNullOrWhiteSpace(user.Password)) + if (!string.IsNullOrWhiteSpace(user.Password) && !(session.RemoteIP.IsInternal() && configuration.Server.BypassGuestPassword)) { stream.Send(ResponseCode.NeedPassword, "Please specify the password.");