使用 C# 将 tcp 通信限制到特定 ip

发布于 2024-08-11 15:00:41 字数 191 浏览 4 评论 0原文

我想制作一个简单的程序,可以限制除某些特定 IP 之外的任何互联网通信。以便用户可以消除任何不需要的流量。它必须简单,并且用户必须能够即时打开和关闭它。

我的第一个想法是使用 Windows 防火墙并使用 C#/WPF 进行设置。这也许是可能的。但有没有更简单的方法呢?

平台:Vindows 7、.NET 3.5

干杯

I want to make a simple program that can restrict any communication over the internet except for some specific ip's. So that the user can eliminate any unwanted traffic. It has to be simple and the user must be able to switch it on and off on the fly.

My first thought was to use Windows Firewall and set it up using C#/WPF. And it might be possible. But is there a more simple way?

Platform: Vindows 7, .NET 3.5

Cheers

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

佼人 2024-08-18 15:00:41

正如你提到的,我只会使用 Windows 防火墙。简单多了。这是一个关于用 C# 修改 Windows 防火墙的很好的教程。

I would just use windows firewall as you mentioned. Much simpler. Here is a good tutorial on modifying the windows firewall in C#.

空城之時有危險 2024-08-18 15:00:41

您本质上是在创建防火墙。一种或更好的选择是使用现有的防火墙并通过您的程序控制它。因为 Windows 内置了一个,所以这将是我的第一选择。

也就是说,另一个选择是在 IP 堆栈中创建一个代理层。最后,如果您的用户仅限于单个通信程序(例如 IE 或其他),那么您可以创建/使用代理服务器类型的程序。

You are essentially creating a firewall. One or your better options would be to use an exising firewall and control it from your program. Since there is one built into windows that would be my first choice.

That said another option is to create a proxy layer into the IP stack . Finally if your users are limited to a single comms program (say IE or what not) then you could just create/use a proxy server type program.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文