diff --git a/Cargo.toml b/Cargo.toml index ed51338..bdd74a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,6 +35,7 @@ rustdoc-args = ["--cfg", "docsrs"] fastrace = ["dep:fastrace"] journald = ["dep:libc"] json = ["dep:serde_json", "dep:serde", "jiff/serde"] +native-tls = ["dep:native-tls", "fasyslog?/native-tls"] no-color = ["colored/no-color"] non-blocking = ["dep:crossbeam-channel"] opentelemetry = [ @@ -55,8 +56,9 @@ log = { version = "0.4", features = ["std", "kv_unstable"] } # Optional dependencies crossbeam-channel = { version = "0.5", optional = true } fastrace = { version = "0.7", optional = true } -fasyslog = { version = "0.2", optional = true } +fasyslog = { version = "0.3", optional = true } libc = { version = "0.2.162", optional = true } +native-tls = { version = "0.2", optional = true } opentelemetry = { version = "0.27", features = ["logs"], optional = true } opentelemetry-otlp = { version = "0.27", features = [ "logs", diff --git a/src/append/syslog.rs b/src/append/syslog.rs index 8fcd398..fb754c2 100644 --- a/src/append/syslog.rs +++ b/src/append/syslog.rs @@ -211,6 +211,51 @@ impl SyslogWriter { .map(Self::new) } + /// Create a new syslog writer that broadcast messages to the well-known UDP port (514). + pub fn broadcast_well_known() -> io::Result { + fasyslog::sender::broadcast_well_known() + .map(SyslogSender::Udp) + .map(Self::new) + } + + /// Create a new syslog writer that broadcast messages to the given UDP address. + pub fn broadcast(port: u16) -> io::Result { + fasyslog::sender::broadcast(port) + .map(SyslogSender::Udp) + .map(Self::new) + } + + /// Create a TLS sender that sends messages to the well-known port (6514). + #[cfg(feature = "native-tls")] + pub fn native_tls_well_known>(domain: S) -> io::Result { + fasyslog::sender::native_tls_well_known(domain) + .map(SyslogSender::NativeTlsSender) + .map(Self::new) + } + + /// Create a TLS sender that sends messages to the given address. + #[cfg(feature = "native-tls")] + pub fn native_tls>( + addr: A, + domain: S, + ) -> io::Result { + fasyslog::sender::native_tls(addr, domain) + .map(SyslogSender::NativeTlsSender) + .map(Self::new) + } + + /// Create a TLS sender that sends messages to the given address with certificate builder. + #[cfg(feature = "native-tls")] + pub fn native_tls_with>( + addr: A, + domain: S, + builder: native_tls::TlsConnectorBuilder, + ) -> io::Result { + fasyslog::sender::native_tls_with(addr, domain, builder) + .map(SyslogSender::NativeTlsSender) + .map(Self::new) + } + /// Create a new syslog writer that sends messages to the given Unix stream socket. #[cfg(unix)] pub fn unix_stream(path: impl AsRef) -> io::Result {