syntax = "proto3";
package turn.server;
import "google/protobuf/empty.proto";
// transport protocol
enum Transport {
TRANSPORT_UNSPECIFIED = 0;
TRANSPORT_UDP = 1;
TRANSPORT_TCP = 2;
}
// network interface
message Interface {
string address = 1;
string external = 2;
Transport transport = 3;
}
// connection identifier
message Identifier {
string source = 1;
string external = 2;
string interface = 3;
Transport transport = 4;
}
// port or channel bind address
message BindAddress {
int32 key = 2;
Identifier value = 1;
}
// turn server info
message TurnServerInfo {
// software info
string software = 1;
// uptime seconds
uint64 uptime = 2;
// interfaces
repeated Interface interfaces = 3;
// port capacity size
uint32 port_capacity = 4;
// port allocated size
uint32 port_allocated = 5;
}
// turn session
message TurnSession {
string username = 1;
// allocated port number
optional int32 allocated_port = 2;
// expires seconds
int64 expires = 3;
// permissions port bind addresses
repeated BindAddress permissions = 4;
// channels number bind addresses
repeated BindAddress channels = 5;
}
// turn session statistics
message TurnSessionStatistics {
// received bytes
uint64 received_bytes = 1;
// send bytes
uint64 send_bytes = 2;
// received packets
uint64 received_pkts = 3;
// send packets
uint64 send_pkts = 4;
// error packets
uint64 error_pkts = 5;
}
// turn service
service TurnService {
// get server info
rpc GetInfo(google.protobuf.Empty) returns (TurnServerInfo);
// get session
rpc GetSession(Identifier) returns (TurnSession);
// get session statistics
rpc GetSessionStatistics(Identifier) returns (TurnSessionStatistics);
// destroy session
rpc DestroySession(Identifier) returns (google.protobuf.Empty);
}
// turn allocated event
message TurnAllocatedEvent {
Identifier id = 1;
string username = 2;
int32 port = 3;
}
// turn channel bind event
message TurnChannelBindEvent {
Identifier id = 1;
string username = 2;
int32 channel = 3;
}
// turn create permission event
message TurnCreatePermissionEvent {
Identifier id = 1;
string username = 2;
repeated int32 ports = 3;
}
// turn refresh event
message TurnRefreshEvent {
Identifier id = 1;
string username = 2;
int32 lifetime = 3;
}
// turn destroy event
message TurnDestroyEvent {
Identifier id = 1;
string username = 2;
}
enum PasswordAlgorithm {
PASSWORD_ALGORITHM_UNSPECIFIED = 0;
PASSWORD_ALGORITHM_MD5 = 1;
PASSWORD_ALGORITHM_SHA256 = 2;
}
// get turn message integrity request
message GetTurnPasswordRequest {
Identifier id = 1;
PasswordAlgorithm algorithm = 2;
string username = 3;
string realm = 4;
}
// get turn message integrity response
message GetTurnPasswordResponse {
bytes password = 2;
}
// turn hooks service
service TurnHooksService {
// hooks
rpc GetPassword(GetTurnPasswordRequest) returns (GetTurnPasswordResponse);
// events
rpc OnAllocatedEvent(TurnAllocatedEvent) returns (google.protobuf.Empty);
rpc OnChannelBindEvent(TurnChannelBindEvent) returns (google.protobuf.Empty);
rpc OnCreatePermissionEvent(TurnCreatePermissionEvent) returns (google.protobuf.Empty);
rpc OnRefreshEvent(TurnRefreshEvent) returns (google.protobuf.Empty);
rpc OnDestroyEvent(TurnDestroyEvent) returns (google.protobuf.Empty);
}