pub fn generate_connect_token(
public_server_addresses: &[SocketAddr],
internal_server_addresses: &[SocketAddr],
expire_seconds: i32,
timeout_seconds: i32,
client_id: u64,
protocol_id: u64,
private_key: &Key,
user_data: &UserData,
) -> Result<[u8; 2048], Error>Expand description
Generates a connect token.
This is what the web backend calls to authorize a client. The returned buffer is
passed to the client over a secure channel (e.g. HTTPS), and the client passes it
to Client::connect.
public_server_addresses are the addresses the client connects to. The matching
entries in internal_server_addresses go inside the encrypted private token and
are what each server checks its own address against; they may differ from the
public addresses when servers sit behind NAT or a load balancer. Both slices must
have the same length, in the range [1, MAX_SERVERS_PER_CONNECT].
The token expires expire_seconds after creation; negative means never expires
(dev only). timeout_seconds is how long a connection can go without receiving
packets before it is dropped; negative disables timeouts (dev only).