简体   繁体   English

时间检查:服务器端还是客户端端?

[英]Timechecking: Server side or Client side?

I'm developing a quiz like application. 我正在开发类似测验的应用程序。
This application tracks how much time does the user takes to answer every single question. 此应用程序跟踪用户花费多少时间来回答每个问题。

Should I count time server side or client side? 我应该计算时间服务器端还是客户端端?

I came up with this pros/cons: 我想出了这个优点/缺点:

Server Side: 服务器端:
pros: user cannot "cheat" 优点:用户不能“作弊”
cons: user latency can heavily impact 缺点:用户延迟会严重影响

Client Side: 客户端:
pros: time tracking is more precise 优点:时间追踪更精确
cons: a semi-expert user can use some javascript to "cheat" 缺点:半专业用户可以使用一些JavaScript进行“欺骗”

By desing, changing the logic behind (ie: calculating an average time per answer) would break the purpouse of the application. 通过设计,更改背后的逻辑(即:计算每个答案的平均时间)将破坏应用程序的用途。

Latency can be an issue, since a variation of 5-10 seconds can change the user's final score (multiply it for an average of 50 answers); 延迟可能是一个问题,因为5到10秒的变化会改变用户的最终分数(将其乘以平均50个答案); this application can run on smartphone and tablet, so high I'm expecting high network latency. 此应用程序可以在智能手机和平板电脑上运行,因此期望很高的网络延迟。

I think this can be a general html5/javascript developing problem, but for who's asking, I'm using node.js as server. 我认为这可能是一般的html5 / javascript开发问题,但是对于谁问的问题,我正在使用node.js作为服务器。

If the quiz application is not sensitive then just use the client side's time. 如果测验应用程序不敏感,则只需使用客户端的时间即可。

If it is very time sensitive, I would use both the server and client side's time. 如果它对时间非常敏感,那么我将同时使用服务器和客户端的时间。

If the client side's time is less than that of the server by a large amount of time (say 5 seconds), then it is safe to assume the client was cheating. 如果客户端的时间比服务器的时间少很多时间(例如5秒),则可以安全地假定客户端在作弊。


Also, I should warn you that if the answer to the questions are constant, it is quite easy to create a script which will auto-fill the values. 另外,我还警告您,如果对问题的答案是恒定的,则创建一个脚本将自动填充值非常容易。

Eg. 例如。 document.getElementById("QuestionOne").value="TheCorrectAnswer";void(0) ; document.getElementById("QuestionOne").value="TheCorrectAnswer";void(0) ;

您可以使用客户端时间,并将其与服务器端时间进行比较,即同时使用两者。它不需要太多代码,但是很安全。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM