Skip to content

Conversation

@RemZapCypher
Copy link
Contributor

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

glaslos commented May 20, 2025

@tank0nf are you still planning to work on this issue?

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