pub enum PortSpecification {
One {
port: u16,
},
Range {
range: PortRange,
},
All {
all_ports: AllPorts,
},
}Expand description
PortSpecification, the model’s tagged union: one port, a range, or all of them.
A union rather than the single-field struct this was, and the change is a defect fix
rather than completeness for its own sake. Session::connect_headers(port) and
connect_subprotocols(port) exist to reach another port on the same VM, and they were
built over a token the control plane had minted with allowedPorts: [{port: 9000}] — so
they returned a correct-looking port header behind a credential that did not authorize
it. Measured 2026-08-15 on one VM with a listener on 8080, varying only the mint:
allowedPorts | GET :8080 through the endpoint |
|---|---|
[{port: 9000}] | 403 Access to port denied |
[{port: 9000}, {port: 8080}] | 200, the guest answered |
[{allPorts: {}}] | 200 |
[{range: {startPort: 8000, endPort: 9100}}] | 200 |
One variable, four outcomes, so the token’s scope is the whole of it. On the WebSocket path the same rejection is close code 1006 with no reason, which is why this was invisible to a client-side test: the strings were right and the credential behind them was not.
#[serde(untagged)] because the wire form is the member name as the key —
{"port": 9000}, {"range": {..}}, {"allPorts": {}} — not a discriminator field, and
serde’s default enum representation would emit {"Port": 9000}. Each variant names its
own key through rename.
Variants§
One
Exactly one port. What a session built for the agent port asks for.
Range
An inclusive range. Both members are required by the model.
All
Every port on the VM.
Deliberately not what this client mints by default. A token good for every port is one whose leak is worth more, and the ports a caller actually needs are knowable: the agent port plus whatever it asked for. Present because the model has it and a caller building a general proxy needs it, reached only through an explicit scope.
Implementations§
Source§impl PortSpecification
impl PortSpecification
Sourcepub fn port(port: u16) -> PortSpecification
pub fn port(port: u16) -> PortSpecification
One port.
Sourcepub fn range(start: u16, end: u16) -> PortSpecification
pub fn range(start: u16, end: u16) -> PortSpecification
An inclusive range of ports.
Sourcepub fn all() -> PortSpecification
pub fn all() -> PortSpecification
Every port. See PortSpecification::All for why this is not a default.
Trait Implementations§
Source§impl Clone for PortSpecification
impl Clone for PortSpecification
Source§fn clone(&self) -> PortSpecification
fn clone(&self) -> PortSpecification
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for PortSpecification
Source§impl Debug for PortSpecification
impl Debug for PortSpecification
Source§impl Serialize for PortSpecification
impl Serialize for PortSpecification
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for PortSpecification
impl RefUnwindSafe for PortSpecification
impl Send for PortSpecification
impl Sync for PortSpecification
impl Unpin for PortSpecification
impl UnsafeUnpin for PortSpecification
impl UnwindSafe for PortSpecification
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more