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

refactor: clean up TCP and UDP serving #146

Merged
merged 4 commits into from
Apr 17, 2023
Merged

refactor: clean up TCP and UDP serving #146

merged 4 commits into from
Apr 17, 2023

Conversation

fortuna
Copy link

@fortuna fortuna commented Apr 14, 2023

This PR makes the serving logic a lot simpler. Serve() was already tied to the listener lifetime, so now that's explicit, and closing the listener is the way to stop serving. We no longer need the complicated mutex logic.

This introduces a StreamListener concept that can return any type of StreamConn, allowing for listening on Unix sockets or introduce intermediate transports (e.g. Websockets). We no longer require TCP.

The handler will allow for easier replacement of the protocol in the future. That also makes it easier to test.

@fortuna fortuna requested a review from jyyi1 April 14, 2023 21:35
@fortuna fortuna requested a review from a team as a code owner April 14, 2023 21:35
@fortuna fortuna changed the title Clean up TCP serving refactor: clean up TCP and UDP serving Apr 14, 2023
Copy link
Author

@fortuna fortuna left a comment

Choose a reason for hiding this comment

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

Thanks for the quick review. I ended up adding UDP without realizing you had already reviewed. Would you mind reviewing the new code?

@fortuna fortuna requested review from jyyi1 and removed request for a team April 14, 2023 23:14
Copy link

@jyyi1 jyyi1 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

service/tcp.go Outdated
ciphers: ciphers,
m: m,
readTimeout: timeout,
replayCache: replayCache,
targetIPValidator: onet.RequirePublicIP,
}
})
Copy link

Choose a reason for hiding this comment

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

nit why do we wrap the tcpHandler in brackets () here?

Copy link
Author

Choose a reason for hiding this comment

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

Removed.

service/udp.go Outdated
}

func (s *udpService) SetTargetIPValidator(targetIPValidator onet.TargetIPValidator) {
func (s *packetHandler) SetTargetIPValidator(targetIPValidator onet.TargetIPValidator) {
Copy link

Choose a reason for hiding this comment

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

nit maybe use p (stands for packetHandler) instead of s (stands for udpService)?

Copy link
Author

Choose a reason for hiding this comment

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

Replaced with h, for "handler"

@fortuna fortuna merged commit 766555e into master Apr 17, 2023
@fortuna fortuna deleted the fortuna-clean branch April 17, 2023 17:07
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