使用C#/C++,是否可以限制网络流量?
我正在开发一个家长监控/跟踪应用程序,该应用程序具有锁定所有互联网活动的功能。虽然禁用网络适配器似乎是一个简单的解决方案,但应用程序必须能够远程重新打开互联网 - 因此网络需要在一定限度内保持启用状态。
不幸的是,我在实践中还没有找到合适的方法来实现这一目标。如果没有这个功能,应用程序就几乎死在水中。所以我遇到了一个巨大的障碍,并且我愿意接受任何建议。
对于我的应用程序,我需要满足两个要求:
- 停止所有互联网活动。 然后
- 仅打开指定端口和 IP 地址的互联网活动。 (我的服务,将被轮询)
简单的目标,对吧?最近没那么多了。
虽然我希望在 C# 中实现这一目标,但我知道这可能是一个遥远的目标,并且我对 C++ 解决方案持开放态度,这些解决方案可以通过我的应用程序作为资源调用。
另请注意,我无法在用户系统上安装任何第三方软件,因为此解决方案需要包罗万象。
提前致谢!
I'm developing a parental monitoring/tracking application that has a feature to lock down all internet activity. While disabling the network adapter would seem like a simple solution, the application must have the ability to turn the internet back on remotely -- so the network needs to remain enabled, to a certain limit.
Unfortunately, I haven't found a suitable way to achieve this in practice. Without this feature, the application is pretty much dead in the water. So I've hit a huge road block, and I'm open to any suggestions.
With my application, I need to achieve two requirements:
- Drop all internet activity. and then
- Turn on only internet activity to a specified port and IP address. (my service, which will be polled)
Simple goal, right? Not so much lately.
While I am looking to achieve this in C#, I understand that may be a long-shot and I am open to C++ solutions that could be called as a resource through my application.
Also note, I cannot install any third-party software on the user's system, as this solution needs to be all-encompassing.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要使用 Windows 将自定义层注入 IP 堆栈过滤平台。该 SDK 专门针对家长控制程序等。不用说,与任何内核模块一样,它必须用 C 语言开发,并且您必须具备 Windows 内部结构的专业知识:
You need to inject a custom layer into the IP stack, using Windows Filtering Platform. This SDK targets specifically parental control programs and such. Needless to say, as any kernel module, it has to be developed in C and you must have expert knowledge of Windows internals:
您也许能够利用WinINET API 来实现这一点; WinINET 定义了大多数/许多 Windows 应用程序的基本 Internet 设置,并且可用于定义代理信息。考虑到这一点,您也许可以创建一个代理来拒绝除您的消息之外的所有请求。
You may be able to utilize the WinINET API to achieve this; WinINET defines the basic internet settings for most/many Windows applications and can be used to define proxy information. With this in mind you might be able to create a proxy which rejects all requests except for you messages.
不是直接答案,但这类事情通常是通过串行连接在带外完成的 或使用连接到“可信”LAN 的第二个 NIC。
Not a direct answer, but this sort of things is usually done out-of-band with serial connection or with a second NIC connected to a "trusted" LAN.