add: demo server and client
This commit is contained in:
189
proto/peernet_service.proto
Normal file
189
proto/peernet_service.proto
Normal file
@@ -0,0 +1,189 @@
|
||||
|
||||
syntax = "proto2";
|
||||
package peernet;
|
||||
|
||||
option go_package = "peernet/";
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
import "google/api/field_behavior.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
|
||||
service PeerNetService {
|
||||
rpc GetRoom(GetRoomRequest) returns (Room) {
|
||||
option (google.api.http) = {
|
||||
get: "/v1/{name=rooms/*}"
|
||||
};
|
||||
};
|
||||
|
||||
rpc CreateServer(CreateServerRequest) returns (Server) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/servers"
|
||||
body: "server"
|
||||
};
|
||||
};
|
||||
rpc DeleteServer(DeleteServerRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {
|
||||
delete: "/v1/servers/*"
|
||||
};
|
||||
};
|
||||
|
||||
rpc CreateService(CreateServiceRequest) returns (Service) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/{parent=servers/*}/services"
|
||||
body: "service"
|
||||
};
|
||||
};
|
||||
rpc DeleteService(DeleteServiceRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {
|
||||
delete: "/v1/{name=servers/*/services/*}"
|
||||
};
|
||||
};
|
||||
|
||||
// Creates a knock that will be answered by the peer; the signaler may
|
||||
// delete the knock, regardless of the state, when it ages.
|
||||
rpc CreateKnock(CreateKnockRequest) returns (Knock){
|
||||
option (google.api.http) = {
|
||||
post: "/v1/{parent=servers/*/services/*}/knocks"
|
||||
body: "knock"
|
||||
};
|
||||
};
|
||||
rpc UpdateKnock(UpdateKnockRequest) returns (Knock) {
|
||||
option (google.api.http) = {
|
||||
patch: "/v1/{knock.name=servers/*/services/*/knocks/*}"
|
||||
body: "knock"
|
||||
};
|
||||
};
|
||||
rpc ListKnocks(ListKnocksRequest) returns (ListKnocksResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/v1/{parent=servers/*/services/*}/knocks"
|
||||
};
|
||||
};
|
||||
rpc GetKnock(GetKnockRequest) returns (Knock) {
|
||||
option (google.api.http) = {
|
||||
get: "/v1/{name=servers/*/services/*/knocks/*}"
|
||||
};
|
||||
};
|
||||
|
||||
rpc CreateIceCandidate(CreateIceCandidateRequest) returns (IceCandidate) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/{parent=sessions/*}/candidates"
|
||||
body: "ice_candidate"
|
||||
};
|
||||
};;
|
||||
// Acts as both List and Delete atomically.
|
||||
rpc ClaimIceCandidates(ClaimIceCandidatesRequest) returns (ClaimIceCandidatesResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/v1/{parent=sessions/*}/claim/candidates"
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
message GetKnockRequest {
|
||||
required string name = 1;
|
||||
}
|
||||
|
||||
message GetRoomRequest {
|
||||
required string name = 1;
|
||||
}
|
||||
|
||||
message CreateServerRequest {
|
||||
required Server server = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
message DeleteServerRequest {
|
||||
required string name = 1;
|
||||
}
|
||||
|
||||
message CreateServiceRequest {
|
||||
required Service service = 1;
|
||||
}
|
||||
|
||||
message DeleteServiceRequest {
|
||||
required string name = 1;
|
||||
}
|
||||
|
||||
message CreateKnockRequest {
|
||||
required Knock knock = 1;
|
||||
}
|
||||
|
||||
message UpdateKnockRequest {
|
||||
required Knock knock = 1;
|
||||
}
|
||||
|
||||
message ListKnocksRequest { }
|
||||
|
||||
message ListKnocksResponse {
|
||||
repeated Knock knocks = 1;
|
||||
}
|
||||
|
||||
message CreateIceCandidateRequest {
|
||||
required IceCandidate ice_candidate = 1;
|
||||
}
|
||||
|
||||
message ClaimIceCandidatesRequest { }
|
||||
|
||||
message ClaimIceCandidatesResponse {
|
||||
repeated IceCandidate ice_candidates = 1;
|
||||
}
|
||||
|
||||
message Room {
|
||||
required string name = 1;
|
||||
required string display_name = 2;
|
||||
|
||||
repeated Server servers = 3;
|
||||
}
|
||||
|
||||
message Server {
|
||||
required string name = 1;
|
||||
|
||||
// Tracks which rooms the server should be listed in; this will not
|
||||
// be set when a room is listed to preserve privacy of servers.
|
||||
repeated string rooms = 2 [(google.api.field_behavior) = INPUT_ONLY];
|
||||
|
||||
// Used to authenticate requests which access knocks for this server
|
||||
// or attempt to update, delete or create services.
|
||||
// In future calls, add a header with the format:
|
||||
// Authorization: Bearer <auth_token>
|
||||
required string auth_token = 3 [(google.api.field_behavior) = INPUT_ONLY];
|
||||
|
||||
required string display_name = 4;
|
||||
|
||||
repeated Service services = 5;
|
||||
}
|
||||
|
||||
message Service {
|
||||
required string name = 1;
|
||||
required string protocol = 2;
|
||||
required string version = 3;
|
||||
|
||||
// Used to define custom fields per-protocol/version.
|
||||
// We use unverified extensions because this system is meant
|
||||
// to be distributed, with no central owner, hence, no singular
|
||||
// authority to hand out field numbers. Instead, implementations
|
||||
// should use the protocol/version to scope what values are expected.
|
||||
extensions 100 to max [verification = UNVERIFIED];
|
||||
}
|
||||
|
||||
message Knock {
|
||||
required string name = 1;
|
||||
// The service being connected too
|
||||
optional IceSessionDescription offer = 2;
|
||||
optional IceSessionDescription answer = 3;
|
||||
}
|
||||
|
||||
message IceSessionDescription {
|
||||
// A unique identifier which can be used to send ICE candidates
|
||||
// Maps to the session name
|
||||
required string name = 1;
|
||||
// Used to construct the remote description in WebRTC
|
||||
required int64 sdp_type = 3;
|
||||
required string sdp = 4;
|
||||
}
|
||||
|
||||
message IceCandidate {
|
||||
required string name = 1;
|
||||
required string candidate = 2;
|
||||
optional string sdp_mid = 3;
|
||||
optional int32 sdp_line_index = 4;
|
||||
optional string username_fragment = 5;
|
||||
}
|
||||
Reference in New Issue
Block a user