Skip to main content

GateTarget

Struct GateTarget 

Source
pub struct GateTarget { /* private fields */ }
Expand description

Where a tenant command sends its requests: the canonical origin it signs for, and the local plain-HTTP address it connects to.

The client has no TLS transport in Step 2. It opens plain HTTP to the connect address, sends Host: <canonical authority> and signs <canonical origin><path>, so the gate sees exactly the request it would see behind the public origin. The connect address must be a loopback literal (an address in 127.0.0.0/8, [::1], or localhost, which is dialled as 127.0.0.1 without a name lookup), because a signed request sent in clear text off the machine could be captured and spent.

§Examples

use stratum_node_cli::GateTarget;

let target = GateTarget::new(
    "https://stratum.visionclaw.pro".parse()?,
    Some("127.0.0.1:7461".parse()?),
)?;
assert_eq!(target.connect().authority(), "127.0.0.1:7461");

// The remote transport arrives with the public origin.
assert!(GateTarget::new("https://stratum.visionclaw.pro".parse()?, None).is_err());

// A local http:// origin is reached at its own address.
let local = GateTarget::new("http://127.0.0.1:7461".parse()?, None)?;
assert_eq!(local.connect().authority(), "127.0.0.1:7461");

Implementations§

Source§

impl GateTarget

Source

pub fn new( origin: CanonicalOrigin, connect: Option<ConnectAddress>, ) -> Result<Self, CliError>

Builds a target from --origin and the optional --connect.

§Errors

CliError::Usage when an https:// origin has no connect address (the remote transport arrives with the public origin), when an http:// origin without one is not itself on a loopback address, or when the connect address has a path.

Source

pub fn origin(&self) -> &CanonicalOrigin

Returns the canonical origin requests are signed for.

Source

pub fn connect(&self) -> &LoopbackUrl

Returns the loopback address requests are sent to.

Trait Implementations§

Source§

impl Clone for GateTarget

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GateTarget

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for GateTarget

Source§

impl PartialEq for GateTarget

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for GateTarget

Auto Trait Implementations§

§

impl Forget for GateTarget

§

impl Freeze for GateTarget
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze,

§

impl Move for GateTarget

§

impl RefUnwindSafe for GateTarget

§

impl Send for GateTarget
where RawVecInner: Send,

§

impl Sync for GateTarget
where RawVecInner: Sync,

§

impl Unpin for GateTarget
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for GateTarget

§

impl UnwindSafe for GateTarget
where RawVecInner: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.