You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow listen to accept an absolute Unix-domain socket path in addition to an IPv4 or IPv6 socket address.
This adds a shared listener/stream abstraction while preserving the existing HTTP request handling, authentication, and TCP behavior. It also documents the new configuration and adds an end-to-end Unix socket test.
Example:
listen = "/run/snare.sock";
Unix socket paths must not already exist when snare starts.
Dumb question: what's the use case for listening on a Unix socket vs. a TCP/HTTP socket?
I generally prefer to host internal services on Unix sockets.
Unix socket paths are more legible than port numbers. /run/snare.sock vs 18239. You don't have to worry about port conflicts.
You can manage multiple configs (eg, for multiple users) without having to allocate port numbers. You can just listen on ~/run/snare.sock, let's say.
You can control permissions granularly, eg, only allow nginx to connect instead of every user on the host. Unix sockets follow filesystem permissions. Otherwise restricting local connections requires complicated iptables rules.
Most OSs can restrict TCP sockets to a given user. That said, I am inclined to see this as a useful feature. Integrating it sensibly might take a bit of finessing. For example, listen no longer has an unambiguous syntax. A first thought is that socket paths would be of the form unix:/path/to/sock and TCP sockets would -- for backwards compatibility -- be either IP:port or tcp:IP:port. [One day we could deprecate the non tcp prefix.] Warning: I haven't thought this through very carefully yet.
listen = IP:PORT and listen = unix:/path/to/socket syntax would match Nginx. I think that's an intuitive approach.
I've updated the PR accordingly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Allow
listento accept an absolute Unix-domain socket path in addition to an IPv4 or IPv6 socket address.This adds a shared listener/stream abstraction while preserving the existing HTTP request handling, authentication, and TCP behavior. It also documents the new configuration and adds an end-to-end Unix socket test.
Example:
Unix socket paths must not already exist when snare starts.
Tests:
cargo test --all-featurescargo clippy --bin snare --all-features -- -D warnings