如何在 C# 中从 FTP 请求获取 IP 地址
我有一个传入的 FTP 请求。我想获取传入 FTP 请求中提到的 FTP 服务器的 IP 地址。我必须根据列入白名单的 FTP 服务器列表来验证这一点。
任何帮助将不胜感激..
我的代码如下:
try
{
IPHostEntry host;
string localIP = "?";
host = Dns.GetHostEntry(uri);
foreach (IPAddress ip in host.AddressList)
{
// we are only interested in IPV4 Addresses
if (ip.AddressFamily == AddressFamily.InterNetwork)
{
localIP = ip.ToString();
}
}
return localIP;
}
catch (Exception exception)
{
throw;
}
I have an incoming FTP request. I would like to get the IP Address of the FTP server mentioned in the incoming FTP request. I have to validate this against a list of whitelisted FTP servers.
Any help will be well appreciated..
My code is as follows:
try
{
IPHostEntry host;
string localIP = "?";
host = Dns.GetHostEntry(uri);
foreach (IPAddress ip in host.AddressList)
{
// we are only interested in IPV4 Addresses
if (ip.AddressFamily == AddressFamily.InterNetwork)
{
localIP = ip.ToString();
}
}
return localIP;
}
catch (Exception exception)
{
throw;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,这是我的黑客..
Ok here is my hack..