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

Added the feature of delayed packages #170

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tank0nf
Copy link

@tank0nf tank0nf commented Jan 31, 2025

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.

Copy link
Member

@glaslos glaslos left a 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 {
Copy link
Member

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 {
Copy link
Member

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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a doc string

Comment on lines +49 to +52
if delay < tt.minDelay || delay > tt.maxDelay {
t.Errorf("Delay %v outside expected range [%v, %v]",
delay, tt.minDelay, tt.maxDelay)
}
Copy link
Member

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{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the test config

@glaslos glaslos mentioned this pull request Feb 2, 2025
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.

2 participants