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

Chapter 9: Testing TokenBucketv2 #7

Open
mshearer0 opened this issue Jun 19, 2021 · 1 comment
Open

Chapter 9: Testing TokenBucketv2 #7

mshearer0 opened this issue Jun 19, 2021 · 1 comment

Comments

@mshearer0
Copy link
Contributor

In testing TokenBucketv2 by sending curl requests from a single machine i found using r.remoteAddr as UID gave a different value everytime as a new port was assigned for each http request. The throttle therefore was not envoked.

To test i truncated r.remote Addr to just IP by removing port:

import strings

replacing r.remoteAddr in the call to throttled with strings.Split(r.RemoteAddr, ":")[0]

@mshearer0
Copy link
Contributor Author

mshearer0 commented Jun 27, 2021

Having read further could use net package SplitHostPort - https://golang.org/src/net/ipsock.go?s=4766:4832#L146

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

No branches or pull requests

1 participant