-
-
Notifications
You must be signed in to change notification settings - Fork 68
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
Added the feature of delayed packages #170
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would you use this in Glutton?
|
||
func (h *DelayHandler) GetDelay(port int, protocol string) time.Duration { | ||
// Check port specific delay | ||
for _, pd := range h.config.PerPort { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you solve this without a for loop?
// Check port specific delay | ||
for _, pd := range h.config.PerPort { | ||
if pd.Port == port { | ||
for _, p := range pd.Protocols { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you solve this without a for loop?
config DelayConfig | ||
} | ||
|
||
func (h *DelayHandler) GetDelay(port int, protocol string) time.Duration { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a doc string
if delay < tt.minDelay || delay > tt.maxDelay { | ||
t.Errorf("Delay %v outside expected range [%v, %v]", | ||
delay, tt.minDelay, tt.maxDelay) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the require
package for tests
) | ||
|
||
func TestDelayHandler(t *testing.T) { | ||
config := DelayConfig{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the test config
Hey @glaslos,
Reffering to issue: Tarpit #55
I have tried to add capability to add a delay to responses. Delay should be random in range and can be set in the config.yaml file.
Please review the changes and let me know, if their is any changes necessary.
Thank you,
Tank0nf.