Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop: Add a component to record data usage for every user #481

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from

Conversation

frankfzw
Copy link

In order to support multiple users to use the COW proxy without running out of the capacity of VPS by a few, I add a component to limit the usage of every user.

The major addition is usage.go.

  • Configuration: A new component to do usage recording. The limitation of every user is set in a file named userCapacityFile (more detail in doc/sample-config/rc). It's loaded when the COW starts. The userPasswdFile must been enabled to use the recording. See more details in doc/sample-config/rc .
  • Limitation Check: The limitation check is triggered after Authenticate in proxy.go . Error page is returned if the capacity is run out of.
  • Recording: To record the usage, the accumulatedUsage is called for every HTTP response ( doRequest in proxy.go) and every HTTP CONNECT (copyServer2Client in proxy.go). The current usage is first loaded from _cowDir/record.log if existed. A background thread flush the in-memory record to the disk file every half hour. The record will be reset on every reset date (more detail in doc/sample-config/rc).

This time I fixed the previous data racing bug in usage.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant