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

Use JSON for Controls protocol messages #379

Closed
Castaglia opened this issue Dec 31, 2016 · 3 comments
Closed

Use JSON for Controls protocol messages #379

Castaglia opened this issue Dec 31, 2016 · 3 comments
Assignees
Milestone

Comments

@Castaglia
Copy link
Member

Castaglia commented Dec 31, 2016

The Controls support in ProFTPD uses protocol messages that are length-prefixed strings. Nice and simple. The length is expressed as an int, read from a (Unix domain) socket. While this works because both client (ftpdctl) and server (mod_ctrls) are on the same host, it is not necessarily the best design. Nor does this format allow for more complex expressions of relationships, e.g. tables, lists, or nested arrangements thereof.

Thus the proposal to use JSON as the protocol message format instead. There is still the issue of expressing the length of the JSON message (using a length prefix again, or simply rely on EOF on read?), as well as the loss of "streaminess" when reading/writing the protocol messages. However, neither of these concerns really afflict the Controls protocol right now. And moving to JSON would make other, future actions easier.

When JSON support is used (with a flag for using the old format?), it should be done in a backward-compatible way. If, for example, we assume that all JSON-formatted Controls messages are JSON objects, then the first character (a char, or byte) would be {, which is an int value of 125. There are currently no Control actions whose name is 125 (or greater) bytes. We could impose a maximum action length of e.g. 80 characters, and thus provided a good sentinel for knowing whether to treat the message as JSON or not. The server (mod_ctrls) must always respond using the format requested by the client, to preserve interoperability.

@Castaglia Castaglia added this to the 1.3.7 milestone Dec 31, 2016
@Castaglia Castaglia self-assigned this Dec 31, 2016
@Castaglia
Copy link
Member Author

Keep in mind how many existing action handlers would also need to be updated to provide JSON.

@Castaglia
Copy link
Member Author

In thinking about this more, I think that preserving backward compatibility may not be worth the effort; most sites that use Controls, ftpdctl will install a ProFTPD package that's all the same version. I may need to provide/implement a different set of Controls API functions for this JSON version, and make the existing API functions all return errors, just in case.

@Castaglia
Copy link
Member Author

And for all of the existing action handlers, there should be a way to preserve their existing API, but format the messages using JSON. That is, the struct of the message on the wire shouldn't leak into the API such that existing action handlers have to change at all.

@Castaglia Castaglia modified the milestones: 1.3.8, 1.3.9 Apr 3, 2022
Castaglia added a commit that referenced this issue Jan 2, 2023
…tion to using JSON as the wire format for Controls messages.

As part of this, I noticed that the `pr_ctrls_parse_msg` function is unused,
so remove it.
Castaglia added a commit that referenced this issue Jan 2, 2023
Issue #379: Start polishing up the Controls API, preparing our transi…
Castaglia added a commit that referenced this issue Jan 7, 2023
Castaglia added a commit that referenced this issue Jan 7, 2023
Castaglia added a commit that referenced this issue Jan 7, 2023
Issue #379: Change the internal implementation/format of Controls mes…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant