使用 C#/C++,是否可以限制网络流量? [英] Using C#/C++, is it possible to limit network traffic?

查看:53
本文介绍了使用 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:

  1. 放弃所有互联网活动.然后
  2. 仅开启指定端口和 IP 地址的互联网活动.(我的服务,将被轮询)

简单的目标,对吧?最近没那么多.

Simple goal, right? Not so much lately.

虽然我希望在 C# 中实现这一点,但我知道这可能是一个长期的尝试,而且我对可以通过我的应用程序作为资源调用的 C++ 解决方案持开放态度.

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.

提前致谢!

推荐答案

您需要将自定义层注入 IP 堆栈,使用 Windows 过滤平台.此 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:

Windows 过滤平台 API 是专供程序员使用C/C++开发软件.程序员应该熟悉网络概念和设计系统使用用户模式和内核模式组件.

The Windows Filtering Platform API is designed for use by programmers using C/C++ development software. Programmers should be familiar with networking concepts and design of systems using user-mode and kernel-mode components.

这篇关于使用 C#/C++,是否可以限制网络流量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆