Add host configuration
Needed to fix remote access
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
using YamlDotNet.Serialization;
|
using YamlDotNet.Serialization;
|
||||||
|
|
||||||
@@ -42,6 +43,16 @@ namespace DearFTP.Configurations
|
|||||||
|
|
||||||
public bool Check()
|
public bool Check()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(Server.Host))
|
||||||
|
{
|
||||||
|
Console.WriteLine("Host address is missing.");
|
||||||
|
}
|
||||||
|
if (!IPAddress.TryParse(Server.Host, out var _))
|
||||||
|
{
|
||||||
|
Server.Host = Dns.GetHostEntry(Server.Host).AddressList.First().ToString();
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var share in Shares)
|
foreach (var share in Shares)
|
||||||
{
|
{
|
||||||
share.Name = Path.GetFileName(share.Path);
|
share.Name = Path.GetFileName(share.Path);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
{
|
{
|
||||||
class ServerConfiguration
|
class ServerConfiguration
|
||||||
{
|
{
|
||||||
|
public string Host { get; set; } = "127.0.0.1";
|
||||||
public ushort Port { get; set; } = 21;
|
public ushort Port { get; set; } = 21;
|
||||||
public ushort ForceDataPort { get; set; } = 0;
|
public ushort ForceDataPort { get; set; } = 0;
|
||||||
public ushort ImplicitFtpsPort { get; set; } = 0;
|
public ushort ImplicitFtpsPort { get; set; } = 0;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace DearFTP.Connection.Commands
|
|||||||
|
|
||||||
int port = session.DataConnection.Port;
|
int port = session.DataConnection.Port;
|
||||||
var portBytes = BitConverter.GetBytes((ushort)port).Reverse().Select(x => x.ToString());
|
var portBytes = BitConverter.GetBytes((ushort)port).Reverse().Select(x => x.ToString());
|
||||||
string remote = string.Join(',', session.IP.Split('.').Concat(portBytes));
|
string remote = string.Join(',', session.Configuration.Server.Host.Split('.').Concat(portBytes));
|
||||||
|
|
||||||
stream.Send(ResponseCode.PassiveMode, $"Entering Passive Mode ({remote})");
|
stream.Send(ResponseCode.PassiveMode, $"Entering Passive Mode ({remote})");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user