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

Allow starting server on existing listener #19

Open
andig opened this issue Oct 29, 2022 · 6 comments
Open

Allow starting server on existing listener #19

andig opened this issue Oct 29, 2022 · 6 comments

Comments

@andig
Copy link

andig commented Oct 29, 2022

It would be nice- especially for testing- if an existing listener could be used instead of the server creating it's own listener. Doing so would also externalise the entire TLS checking/handling.

@andig
Copy link
Author

andig commented Nov 1, 2022

I have- for sake of speed and being opinionated in terms of which changes were needed- created a fork at https://github.com/andig/mbserver. The main changes are:

  • start server on existing listener
  • removed the TLS handling- this may really be wrong but I feel this could/should be part of the calling application
  • removed the client- I'm typically relying on grid-x/modbus for that
  • some refactoring, especially around binary.ByteOrder
  • gofmted everything

My changes (which are really to large part removal) are in https://github.com/andig/mbserver. If this should be of any interest please let me know if PRs would be of interest. If possible I'd like not having to maintain a fork.

@simonvetter
Copy link
Owner

Thanks for the heads up andig. I'll dig into your fork and see if there's anything there for me to backport.

@simonvetter
Copy link
Owner

Out of interest, what custom TLS handling is your application doing?

@andig
Copy link
Author

andig commented Nov 1, 2022

Really no TLS handling. I've sort of come from the "I want to determine the listener" side. Once I do that I can't have the TLS handling in the library. If that breaks things it may not be the way to go but is good enough for my purposes.

@andig
Copy link
Author

andig commented Nov 1, 2022

I've opened #21 if you want to take a look. I've not rewritten the server tests yet as I'd need to migrate them to the grid-x client (or use simonvetter/modbus ;).
The whole exercise allows to use the server component for building a modbus proxy in evcc-io/evcc#4981. Having the proxy allows for sharing the modbus connection for devices that otherwise allow a single client only.

@andig
Copy link
Author

andig commented Nov 1, 2022

@simonvetter I'd be happy to open a PR for gofmt and maybe golangcilint- that would already make the diff much smaller.

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

2 participants