pub struct I2pConfig { /* private fields */ }Expand description
Configuration for publishing an I2P eepsite via Server::serve_i2p_config.
See the module docs for a full example, and — importantly — for the
forbid(unsafe_code) disclosure that applies to this whole feature.
Implementations§
Source§impl I2pConfig
impl I2pConfig
Sourcepub fn new(nickname: impl Into<String>) -> Self
pub fn new(nickname: impl Into<String>) -> Self
Creates a new configuration for a service published under nickname. nickname also
seeds libi2pd’s own default data directory name (its router keys/netDb cache, separate
from this eepsite’s own persistent destination keys — see data_dir).
Defaults: plaintext only (see the module docs for why TLS defaults off here,
unlike Tor’s OnionConfig), no on_ready hook, destination keys stored under
./.tachyon-i2p/<nickname>.keys relative to the current working directory,
SigType::default for the identity’s signature algorithm (only used the first time
this destination’s keys are generated — see
signature_type), and no explicit
crypto_type override — which means the destination publishes
libi2pd’s own automatic hybrid encryption set rather than a single fixed algorithm; see
crypto_type’s docs before assuming a specific one is always used.
Sourcepub fn data_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn data_dir(self, dir: impl Into<PathBuf>) -> Self
Overrides the directory this eepsite’s persistent destination keys file is stored under
(as <data_dir>/<nickname>.keys). Reusing the same directory (and nickname) across
restarts keeps the same .b32.i2p address. Defaults to ./.tachyon-i2p relative to the
current working directory.
Sourcepub const fn signature_type(self, sig: SigType) -> Self
pub const fn signature_type(self, sig: SigType) -> Self
Overrides the signature algorithm used the first time this destination’s keys are
generated — irrelevant if a keys file already exists at the resolved path (an existing
destination keeps whatever algorithm it was originally created with). See
tachyon_i2p::SigType’s own docs for what’s available and why RSA isn’t one of the
options; defaults to SigType::default (Eddsa25519, the I2P network’s own default).
Sourcepub fn crypto_type(self, crypto: CryptoType) -> Self
pub fn crypto_type(self, crypto: CryptoType) -> Self
Overrides which encryption algorithm this destination’s LeaseSet2 advertises as usable —
convenience for the common single-algorithm case; see
encryption_types (which this is built on) for the general
case, including “prefer post-quantum but still accept classical” multi-algorithm setups.
See tachyon_i2p::CryptoType’s own docs for the available options.
Not calling this at all (the default) publishes libi2pd’s own automatic hybrid set —
ElGamal + ECIES-X25519, plus ML-KEM-768+X25519 if this was built against a
post-quantum-capable crypto backend — which is what most callers want. Call this to
narrow that down to exactly one algorithm instead, e.g. for a smaller LeaseSet2 or to
deliberately exclude the post-quantum component.
Sourcepub fn encryption_types(self, types: &[CryptoType]) -> Self
pub fn encryption_types(self, types: &[CryptoType]) -> Self
Overrides which encryption algorithm(s) this destination’s LeaseSet2 advertises as usable
— unlike signature_type, this applies on every run, not just
first-time key generation (the identity’s own certificate is always plain ElGamal
regardless of this setting, per real I2P clients’ requirements — this only controls the
destination’s advertised encryption capability).
Order matters: the first entry becomes the preferred type (published first in the
actual LeaseSet2, and what a peer that understands multiple of the listed types will
choose), with every later entry a fallback for peers that don’t recognize it — publishing
something a given peer doesn’t understand at all is harmless, not an error, since it
simply skips entries it can’t use and tries the next one. This is how to express “prefer
post-quantum, but still reachable by peers that don’t support it yet”:
use tachyon_web::server::i2p::I2pConfig;
use tachyon_i2p::CryptoType;
let config = I2pConfig::new("my-eepsite").encryption_types(&[
CryptoType::EciesMlkem1024X25519, // preferred: strongest post-quantum option
CryptoType::EciesX25519, // fallback: peers that don't understand ML-KEM yet
]);An empty slice restores the default automatic hybrid set described on
crypto_type’s docs.
Sourcepub fn tls_config(self, config: ServerConfig) -> Self
pub fn tls_config(self, config: ServerConfig) -> Self
Enables TLS using a caller-supplied rustls::ServerConfig instead of the plaintext
default — for example, the exact same config passed to
Server::serve_https_config for a clearnet
listener. Requires the tls feature.
Sourcepub fn self_signed_tls(self) -> Self
pub fn self_signed_tls(self) -> Self
Enables TLS using a freshly generated self-signed certificate for the eepsite’s
.b32.i2p address, instead of the plaintext default. Requires the cert-gen feature.
Sourcepub fn no_tls(self) -> Self
pub fn no_tls(self) -> Self
Disables TLS (the default) after a prior tls_config/
self_signed_tls call.
Sourcepub fn on_ready(self, f: impl FnOnce(&str) + Send + 'static) -> Self
pub fn on_ready(self, f: impl FnOnce(&str) + Send + 'static) -> Self
Registers a callback invoked exactly once — with the published .b32.i2p address (no
scheme, e.g. "abcd...xyz.b32.i2p") — as soon as the destination is created, just before
requests start being served. This is the only way to observe the address
programmatically, since serve_i2p_config blocks for the
lifetime of the service; the address is also always logged via tracing at info level.
Sourcepub const fn tls_enabled(&self) -> bool
pub const fn tls_enabled(&self) -> bool
Whether TLS is enabled — false (the default) unless
tls_config/self_signed_tls was called.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for I2pConfig
impl !Sync for I2pConfig
impl !UnwindSafe for I2pConfig
impl Freeze for I2pConfig
impl Send for I2pConfig
impl Unpin for I2pConfig
impl UnsafeUnpin for I2pConfig
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> PossiblyOption<T> for T
impl<T> PossiblyOption<T> for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.