Skip to content

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