Struct netcode::ConnectToken
[−]
[src]
pub struct ConnectToken { pub protocol: u64, pub create_utc: u64, pub expire_utc: u64, pub sequence: u64, pub private_data: [u8; 1024], pub hosts: HostList, pub client_to_server_key: [u8; 32], pub server_to_client_key: [u8; 32], pub timeout_sec: u32, }
Token used by clients to connect and authenticate to a netcode Server
Fields
protocol: u64
Protocol ID for messages relayed by netcode.
create_utc: u64
Token creation time in ms from unix epoch.
expire_utc: u64
Token expire time in ms from unix epoch.
sequence: u64
Nonce sequence for decoding private data.
private_data: [u8; 1024]
Private data encryped with server's private key(separate from client <-> server keys).
hosts: HostList
List of hosts this token supports connecting to.
client_to_server_key: [u8; 32]
Private key for client -> server communcation.
server_to_client_key: [u8; 32]
Private key for server -> client communcation.
timeout_sec: u32
Time in seconds connection should wait before disconnecting
Methods
impl ConnectToken
[src]
fn generate_with_string<H, I>(
hosts: H,
private_key: &[u8; 32],
expire_sec: usize,
sequence: u64,
protocol: u64,
client_id: u64,
user_data: Option<&[u8; 256]>
) -> Result<ConnectToken, GenerateError> where
H: ExactSizeIterator<Item = I>,
I: Into<String>,
hosts: H,
private_key: &[u8; 32],
expire_sec: usize,
sequence: u64,
protocol: u64,
client_id: u64,
user_data: Option<&[u8; 256]>
) -> Result<ConnectToken, GenerateError> where
H: ExactSizeIterator<Item = I>,
I: Into<String>,
Generates a new connection token.
Arguments
addrs
: List of allowed hosts to connect to in From
private_key
: Server private key that will be used to authenticate requests.
expire_sec
: How long this token is valid for in seconds.
sequence
: Sequence nonce to use, this should always be unique per server, per token. Use a continously incrementing counter should be sufficient for most cases.
protocol
: Client specific protocol.
client_id
: Unique client identifier.
user_data
: Client specific userdata.
fn generate<H>(
hosts: H,
private_key: &[u8; 32],
expire_sec: usize,
sequence: u64,
protocol: u64,
client_id: u64,
user_data: Option<&[u8; 256]>
) -> Result<ConnectToken, GenerateError> where
H: ExactSizeIterator<Item = SocketAddr>,
hosts: H,
private_key: &[u8; 32],
expire_sec: usize,
sequence: u64,
protocol: u64,
client_id: u64,
user_data: Option<&[u8; 256]>
) -> Result<ConnectToken, GenerateError> where
H: ExactSizeIterator<Item = SocketAddr>,
Generates a new connection token.
Arguments
addrs
: List of allowed hosts to connect to.
private_key
: Server private key that will be used to authenticate requests.
expire_sec
: How long this token is valid for in seconds.
sequence
: Sequence nonce to use, this should always be unique per server, per token. Use a continously incrementing counter should be sufficient for most cases.
protocol
: Client specific protocol.
client_id
: Unique client identifier.
user_data
: Client specific userdata.
fn decode(&mut self, private_key: &[u8; 32]) -> Result<PrivateData, DecodeError>
Decodes the private data stored by this connection token.
private_key
- Server's private key used to generate this token.
sequence
- Nonce sequence used to generate this token.
fn write<W>(&self, out: &mut W) -> Result<(), Error> where
W: Write,
W: Write,
Encodes a ConnectToken into a io::Write
.
fn read<R>(source: &mut R) -> Result<ConnectToken, DecodeError> where
R: Read,
R: Read,
Decodes a ConnectToken from an io::Read
.
Trait Implementations
impl Clone for ConnectToken
[src]
fn clone(&self) -> ConnectToken
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more