diff options
| -rw-r--r-- | talpid_core/src/net.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/talpid_core/src/net.rs b/talpid_core/src/net.rs index f5f40688a7..bc0becbfcd 100644 --- a/talpid_core/src/net.rs +++ b/talpid_core/src/net.rs @@ -19,6 +19,34 @@ error_chain! { } +/// Represents a network layer IP address together with the transport layer protocol and port. +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct Endpoint { + /// The address part of this endpoint, contains the IP and port. + pub address: RemoteAddr, + /// The protocol part of this endpoint. + pub protocol: TransportProtocol, +} + +impl Endpoint { + /// Constructs a new `Endpoint` from the given parameters. + pub fn new(address: &str, port: u16, protocol: TransportProtocol) -> Self { + Endpoint { + address: RemoteAddr::new(address, port), + protocol: protocol, + } + } +} + +/// Representation of a transport protocol, either UDP or TCP. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum TransportProtocol { + /// Represents the UDP transport protocol. + Udp, + /// Represents the TCP transport protocol. + Tcp, +} + /// Representation of a TCP or UDP endpoint. The IP level address is represented by either an IP /// directly or a hostname/domain. The IP level address together with a port becomes a socket /// address. |
