pub struct Networking { /* private fields */ }Expand description
A RuleSet representing syscalls that perform network operations - accept/listen/bind/connect etc.
§How to use
- Select TCP or UDP (or both) with
enable_tcp(),enable_udp()2a. If you are a server of some sort, strongly consider first binding to your ports and then not allowing further binds by usingrunning_tcp_server()orrunning_udp_server(). Otherwise, 2b. If you are a client, usetcp_client()and/orudp_client(), which does not allowacceptorlistensyscalls. The most common use-case: select TCP or UDP (or both) with.enable_tcp()or.enable_udp(), and then decide if you’re going to allow binding to new ports
§Security considerations
If you enable writing (on either tcp or udp), this enables the write syscall which will
therefore also enable writing to stdout/stderr and any open files. Therefore you should take
care to consider whether you can split up your program (e.g. across separate threads) into a
part that opens and writes to files and a part that speaks to the network. This is a good
security practice in general.
Implementations§
Source§impl Networking
impl Networking
Sourcepub fn nothing() -> Networking
pub fn nothing() -> Networking
By default, allow no networking syscalls.
Sourcepub fn allow_running_tcp_servers(self) -> Networking
pub fn allow_running_tcp_servers(self) -> Networking
Allow a running TCP server to continue running. Does not allow socket or bind,
preventing new sockets from being created.
Sourcepub fn allow_start_tcp_servers(self) -> YesReally<Networking>
pub fn allow_start_tcp_servers(self) -> YesReally<Networking>
Allow starting new TCP servers.
§Security Notes
You probably don’t need to use this. In most cases you can just run your server and then
use allow_running_tcp_servers. See
examples/network_server.rs for an example with warp.
Sourcepub fn allow_running_udp_sockets(self) -> Networking
pub fn allow_running_udp_sockets(self) -> Networking
Allow a running UDP socket to continue running. Does not allow socket or bind,
preventing new sockets from being created.
Sourcepub fn allow_start_udp_servers(self) -> YesReally<Networking>
pub fn allow_start_udp_servers(self) -> YesReally<Networking>
Allow starting new UDP sockets.
§Security Notes
You probably don’t need to use this. In most cases you can just run your server and then
use allow_running_udp_sockets.
Sourcepub fn allow_connect(self) -> YesReally<Networking>
pub fn allow_connect(self) -> YesReally<Networking>
Allow connect syscall
§Security Considerations
This allows connnecting to a potentially dangerous network resource
Sourcepub fn allow_start_tcp_clients(self) -> Networking
pub fn allow_start_tcp_clients(self) -> Networking
Allow starting new TCP clients.
§Security Notes
In some cases you can create the socket ahead of time, but that isn’t possible with e.g. reqwest, so we allow socket but not bind here.
Sourcepub fn allow_running_tcp_clients(self) -> Networking
pub fn allow_running_tcp_clients(self) -> Networking
Allow a running TCP client to continue running. Does not allow socket or connect,
preventing new sockets from being created.
This is technically the same as
allow_running_tcp_servers.
Sourcepub fn allow_start_unix_servers(self) -> YesReally<Networking>
pub fn allow_start_unix_servers(self) -> YesReally<Networking>
Allow starting new Unix domain servers
§Security Notes
You probably don’t need to use this. In most cases you can just run your server and then
use allow_running_unix_servers.
Sourcepub fn allow_running_unix_servers(self) -> Networking
pub fn allow_running_unix_servers(self) -> Networking
Allow a running Unix server to continue running. Does not allow socket or bind,
preventing new sockets from being created.
Sourcepub fn allow_running_unix_clients(self) -> Networking
pub fn allow_running_unix_clients(self) -> Networking
Allow a running Unix socket client to continue running. Does not allow socket or connect,
preventing new sockets from being created.
This is technically the same as
allow_running_unix_servers.