$.active 相当于非客户端的东西?

发布于 2024-12-05 00:59:38 字数 321 浏览 1 评论 0原文

我制作了一个在 MVC3 .Net 中运行的浏览器游戏。因为每个人都需要处于公平的竞争环境中,为了阻止人们使用宏以每小时一百万英里的速度单击鼠标,我简单地添加了:

    if ($.active < 10) { //stuff }

到我的 JavaScript 中。足够漂亮并且工作正常,但由于它是客户端,因此很难信任。我正在尝试复制这个服务器端,但在尝试提出等效方案时遇到了一些麻烦。还有其他任何人能想到将这种类型的设置移至更好的地方吗? IIS 中的设置,web.config 设置?我浏览过互联网,但找不到任何类似的东西。

想法?

I have a browser game I made that runs in MVC3 .Net. Because everyone needs to be on a level playing field, to stop people using macros to click their mouse at a million miles per hour I simply added:

    if ($.active < 10) { //stuff }

to my javascript. Nifty enough and works fine, but since it's client side it's hard to trust. I'm trying to replicate this server side though and I'm having some trouble trying to come up with an equivalent. Is there anywhere else anyone can think of that would be better to move this type of setting to? A setting in IIS, a web.config setting? I've looked around the internet and can't really find anything that would be similar.

Thoughts?

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

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

发布评论

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

评论(1

七禾 2024-12-12 00:59:39

通常的服务器端解决方案称为“速率限制”。您可以在服务器上识别来自特定客户端的相关请求,跟踪这些请求到达的速度,并选择您允许的每秒最大请求数或每分钟最大请求数。如果超过该数字,您可以决定部署什么策略。您可以延迟它们,返回错误,断开它们的连接,注销用户等等...有时,选择一种策略是有利的,该策略可以让客户端不知道它受到速率限制,因此它无法故意检测和适应,但仍然试图最大化它的吞吐量。

您可以根据需要获得尽可能详细的信息,甚至可以根据需要为 API 中的不同操作选择不同的速率限制策略。

您尝试选择一个合法真实用户永远不会达到的速率限制数字,但显然可以防止机器滥用您的服务器或游戏逻辑。

The usual server-side solution to this is called "rate limiting". You identify relevant requests at the server from a particular client, you keep track of how fast these requests arrive and you pick some maximum number of requests per second or requests per minute that you're going to allow. If that number is exceeded, you decide what strategy to deploy. You can delay them, return an error, disconnect them, logout the user, etc... Sometimes, it's advantageous to pick a strategy that keeps the client from knowing that it's being rate limited so it can't knowingly detect and adapt, still trying to maximize it's throughput.

You can get as detailed as you want, even picking different rate limiting strategies for different actions in the API if needed.

You try to pick a number for the rate limiting that a legitimate real user would never hit, but obviously one that keeps machines from abusing either your servers or the game logic.

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