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

sa,unixsock: add unix domain socket support #600

Merged
merged 10 commits into from
Dec 16, 2022
Merged

sa,unixsock: add unix domain socket support #600

merged 10 commits into from
Dec 16, 2022

Conversation

sreimers
Copy link
Member

@sreimers sreimers commented Nov 25, 2022

Usage example:

	struct sa srv;
	re_sock_t fd;

	err = sa_set_str(&srv, "unix:/run/http.sock", 0);
	if (err)
		return err;

	err = unixsock_listen_fd(&fd, &srv);
	if (err)
		return err;

	re_printf("listen: %j\n", &srv);

	err = http_listen_fd(sock, fd, http_req_handler, mix);

@sreimers sreimers force-pushed the unix_sockets branch 2 times, most recently from f720686 to 60aa8a3 Compare November 25, 2022 13:07
@sreimers sreimers marked this pull request as ready for review November 25, 2022 13:44
@sreimers sreimers added this to the v2.11.0 milestone Nov 25, 2022
@sreimers sreimers changed the title sa: add unix socket support sa,http,tcp: add unix socket support Nov 26, 2022
@sreimers sreimers force-pushed the unix_sockets branch 3 times, most recently from 2745005 to 5575865 Compare November 27, 2022 10:45
include/re_http.h Outdated Show resolved Hide resolved
@alfredh
Copy link
Contributor

alfredh commented Dec 1, 2022

perhaps also update the list of modules:

https://github.com/baresip/re#modules

@sreimers sreimers force-pushed the unix_sockets branch 3 times, most recently from b94e470 to f639366 Compare December 3, 2022 13:15
include/re_types.h Outdated Show resolved Hide resolved
include/re_unixsock.h Outdated Show resolved Hide resolved
@@ -108,6 +108,11 @@ int sa_pton(const char *addr, struct sa *sa)
if (inet_pton(AF_INET, addr, &sa->u.in.sin_addr) > 0) {
sa->u.in.sin_family = AF_INET;
}
else if (!strncmp(addr, "unix:", 5)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

what if the string is 5 bytes ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Since the provided addr string should be always zero terminated, sun_path is empty in this case too.

src/unixsock/unixsock.c Outdated Show resolved Hide resolved
src/http/server.c Outdated Show resolved Hide resolved
@sreimers sreimers force-pushed the unix_sockets branch 4 times, most recently from c131f4c to 0237d26 Compare December 15, 2022 15:50
@sreimers sreimers changed the title sa,http,tcp: add unix socket support sa,unixsock: add unix socket support Dec 15, 2022
@sreimers sreimers changed the title sa,unixsock: add unix socket support sa,unixsock: add unix domain socket support Dec 15, 2022
@alfredh
Copy link
Contributor

alfredh commented Dec 16, 2022

I think this looks good now.

Please go ahead and merge, if you want

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