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

tcp read and write timeouts #3

Open
cirocosta opened this issue Apr 18, 2021 · 2 comments
Open

tcp read and write timeouts #3

cirocosta opened this issue Apr 18, 2021 · 2 comments

Comments

@cirocosta
Copy link
Owner

cirocosta commented Apr 18, 2021

levin-related: when reading from the tcp sockets that get created for each host, we should enforce some deadlines in order to make sure the opposite of a slow-loris is taking place by a tweaked server

@cirocosta
Copy link
Owner Author

cirocosta commented Jul 28, 2021

https://github.com/cirocosta/drwho/blob/1779a15e1f6df68fe918ec72ebc05a851e38ea23/pkg/who/whois.go#L222-L237

	elapsed := time.Since(start)
	_ = conn.SetWriteDeadline(time.Now().Add(c.timeout - elapsed))


	if _, err = conn.Write(query); err != nil {
		return nil, fmt.Errorf("write query '%s' to server '%s': %w",
			string(query), server, err)
	}


	elapsed = time.Since(start)
	_ = conn.SetReadDeadline(time.Now().Add(c.timeout - elapsed))


	buffer, err := ioutil.ReadAll(conn)
	if err != nil {
		return nil, fmt.Errorf("read response for query '%s' "+
			"on server '%s': %w", string(query), server, err)
	}

@cirocosta
Copy link
Owner Author

#19

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