Documentation ¶
Overview ¶
Package api is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Variables
- func RegisterPeerHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterPeerHandlerClient(ctx context.Context, mux *runtime.ServeMux, client PeerClient) error
- func RegisterPeerHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterPeerHandlerServer(ctx context.Context, mux *runtime.ServeMux, server PeerServer) error
- func RegisterPeerServer(s *grpc.Server, srv PeerServer)
- func RegisterTrackerHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterTrackerHandlerClient(ctx context.Context, mux *runtime.ServeMux, client TrackerClient) error
- func RegisterTrackerHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterTrackerHandlerServer(ctx context.Context, mux *runtime.ServeMux, server TrackerServer) error
- func RegisterTrackerServer(s *grpc.Server, srv TrackerServer)
- type DownloadFileRequest
- func (*DownloadFileRequest) Descriptor() ([]byte, []int)deprecated
- func (x *DownloadFileRequest) GetHash() string
- func (*DownloadFileRequest) ProtoMessage()
- func (x *DownloadFileRequest) ProtoReflect() protoreflect.Message
- func (x *DownloadFileRequest) Reset()
- func (x *DownloadFileRequest) String() string
- type DownloadFileResponse
- func (*DownloadFileResponse) Descriptor() ([]byte, []int)deprecated
- func (x *DownloadFileResponse) GetFilePath() string
- func (*DownloadFileResponse) ProtoMessage()
- func (x *DownloadFileResponse) ProtoReflect() protoreflect.Message
- func (x *DownloadFileResponse) Reset()
- func (x *DownloadFileResponse) String() string
- type File
- type FileInfo
- func (*FileInfo) Descriptor() ([]byte, []int)deprecated
- func (x *FileInfo) GetHash() string
- func (x *FileInfo) GetLength() uint64
- func (x *FileInfo) GetName() string
- func (x *FileInfo) GetPieceLength() uint64
- func (x *FileInfo) GetPieces() uint64
- func (*FileInfo) ProtoMessage()
- func (x *FileInfo) ProtoReflect() protoreflect.Message
- func (x *FileInfo) Reset()
- func (x *FileInfo) String() string
- type GetPeersRequest
- func (*GetPeersRequest) Descriptor() ([]byte, []int)deprecated
- func (x *GetPeersRequest) GetHashFile() string
- func (x *GetPeersRequest) GetPeerId() string
- func (*GetPeersRequest) ProtoMessage()
- func (x *GetPeersRequest) ProtoReflect() protoreflect.Message
- func (x *GetPeersRequest) Reset()
- func (x *GetPeersRequest) String() string
- type GetPieceRequest
- func (*GetPieceRequest) Descriptor() ([]byte, []int)deprecated
- func (x *GetPieceRequest) GetHash() string
- func (x *GetPieceRequest) GetSerialNumber() uint64
- func (*GetPieceRequest) ProtoMessage()
- func (x *GetPieceRequest) ProtoReflect() protoreflect.Message
- func (x *GetPieceRequest) Reset()
- func (x *GetPieceRequest) String() string
- type ListFiles
- type ListPeers
- type ListPeers_Peer
- func (*ListPeers_Peer) Descriptor() ([]byte, []int)deprecated
- func (x *ListPeers_Peer) GetAddress() string
- func (x *ListPeers_Peer) GetSerialPieces() []uint64
- func (*ListPeers_Peer) ProtoMessage()
- func (x *ListPeers_Peer) ProtoReflect() protoreflect.Message
- func (x *ListPeers_Peer) Reset()
- func (x *ListPeers_Peer) String() string
- type PeerClient
- type PeerServer
- type Piece
- type PieceInfo
- type TrackerClient
- type TrackerServer
- type UnimplementedPeerServer
- func (*UnimplementedPeerServer) Download(context.Context, *DownloadFileRequest) (*DownloadFileResponse, error)
- func (*UnimplementedPeerServer) GetFileInfo(context.Context, *File) (*FileInfo, error)
- func (*UnimplementedPeerServer) GetPiece(context.Context, *GetPieceRequest) (*Piece, error)
- func (*UnimplementedPeerServer) UploadFile(context.Context, *File) (*empty.Empty, error)
- type UnimplementedTrackerServer
- func (*UnimplementedTrackerServer) GetAvailableFiles(context.Context, *empty.Empty) (*ListFiles, error)
- func (*UnimplementedTrackerServer) GetFileInfo(context.Context, *DownloadFileRequest) (*FileInfo, error)
- func (*UnimplementedTrackerServer) GetPeers(context.Context, *GetPeersRequest) (*ListPeers, error)
- func (*UnimplementedTrackerServer) PostPieceInfo(context.Context, *PieceInfo) (*empty.Empty, error)
- func (*UnimplementedTrackerServer) Upload(context.Context, *UploadFileRequest) (*empty.Empty, error)
- type UploadFileRequest
- func (*UploadFileRequest) Descriptor() ([]byte, []int)deprecated
- func (x *UploadFileRequest) GetClientId() string
- func (x *UploadFileRequest) GetHash() string
- func (x *UploadFileRequest) GetLength() uint64
- func (x *UploadFileRequest) GetName() string
- func (x *UploadFileRequest) GetPieceLength() uint64
- func (x *UploadFileRequest) GetPieces() uint64
- func (*UploadFileRequest) ProtoMessage()
- func (x *UploadFileRequest) ProtoReflect() protoreflect.Message
- func (x *UploadFileRequest) Reset()
- func (x *UploadFileRequest) String() string
Constants ¶
This section is empty.
Variables ¶
var File_torrent_proto protoreflect.FileDescriptor
Functions ¶
func RegisterPeerHandler ¶
RegisterPeerHandler registers the http handlers for service Peer to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterPeerHandlerClient ¶
RegisterPeerHandlerClient registers the http handlers for service Peer to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "PeerClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "PeerClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "PeerClient" to call the correct interceptors.
func RegisterPeerHandlerFromEndpoint ¶
func RegisterPeerHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
RegisterPeerHandlerFromEndpoint is same as RegisterPeerHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterPeerHandlerServer ¶
RegisterPeerHandlerServer registers the http handlers for service Peer to "mux". UnaryRPC :call PeerServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterPeerHandlerFromEndpoint instead.
func RegisterPeerServer ¶
func RegisterPeerServer(s *grpc.Server, srv PeerServer)
func RegisterTrackerHandler ¶
func RegisterTrackerHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
RegisterTrackerHandler registers the http handlers for service Tracker to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterTrackerHandlerClient ¶
func RegisterTrackerHandlerClient(ctx context.Context, mux *runtime.ServeMux, client TrackerClient) error
RegisterTrackerHandlerClient registers the http handlers for service Tracker to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "TrackerClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "TrackerClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "TrackerClient" to call the correct interceptors.
func RegisterTrackerHandlerFromEndpoint ¶
func RegisterTrackerHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
RegisterTrackerHandlerFromEndpoint is same as RegisterTrackerHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterTrackerHandlerServer ¶
func RegisterTrackerHandlerServer(ctx context.Context, mux *runtime.ServeMux, server TrackerServer) error
RegisterTrackerHandlerServer registers the http handlers for service Tracker to "mux". UnaryRPC :call TrackerServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterTrackerHandlerFromEndpoint instead.
func RegisterTrackerServer ¶
func RegisterTrackerServer(s *grpc.Server, srv TrackerServer)
Types ¶
type DownloadFileRequest ¶
type DownloadFileRequest struct { Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` // contains filtered or unexported fields }
func (*DownloadFileRequest) Descriptor
deprecated
func (*DownloadFileRequest) Descriptor() ([]byte, []int)
Deprecated: Use DownloadFileRequest.ProtoReflect.Descriptor instead.
func (*DownloadFileRequest) GetHash ¶
func (x *DownloadFileRequest) GetHash() string
func (*DownloadFileRequest) ProtoMessage ¶
func (*DownloadFileRequest) ProtoMessage()
func (*DownloadFileRequest) ProtoReflect ¶
func (x *DownloadFileRequest) ProtoReflect() protoreflect.Message
func (*DownloadFileRequest) Reset ¶
func (x *DownloadFileRequest) Reset()
func (*DownloadFileRequest) String ¶
func (x *DownloadFileRequest) String() string
type DownloadFileResponse ¶
type DownloadFileResponse struct { FilePath string `protobuf:"bytes,1,opt,name=file_path,json=filePath,proto3" json:"file_path,omitempty"` // contains filtered or unexported fields }
func (*DownloadFileResponse) Descriptor
deprecated
func (*DownloadFileResponse) Descriptor() ([]byte, []int)
Deprecated: Use DownloadFileResponse.ProtoReflect.Descriptor instead.
func (*DownloadFileResponse) GetFilePath ¶
func (x *DownloadFileResponse) GetFilePath() string
func (*DownloadFileResponse) ProtoMessage ¶
func (*DownloadFileResponse) ProtoMessage()
func (*DownloadFileResponse) ProtoReflect ¶
func (x *DownloadFileResponse) ProtoReflect() protoreflect.Message
func (*DownloadFileResponse) Reset ¶
func (x *DownloadFileResponse) Reset()
func (*DownloadFileResponse) String ¶
func (x *DownloadFileResponse) String() string
type File ¶
type File struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // contains filtered or unexported fields }
func (*File) Descriptor
deprecated
func (*File) ProtoMessage ¶
func (*File) ProtoMessage()
func (*File) ProtoReflect ¶
func (x *File) ProtoReflect() protoreflect.Message
type FileInfo ¶
type FileInfo struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // имя файла PieceLength uint64 `protobuf:"varint,2,opt,name=piece_length,json=pieceLength,proto3" json:"piece_length,omitempty"` // длина кусочка Pieces uint64 `protobuf:"varint,3,opt,name=pieces,proto3" json:"pieces,omitempty"` // всего кусочков Length uint64 `protobuf:"varint,4,opt,name=length,proto3" json:"length,omitempty"` // длина файла Hash string `protobuf:"bytes,5,opt,name=hash,proto3" json:"hash,omitempty"` // хэш файла // contains filtered or unexported fields }
func (*FileInfo) Descriptor
deprecated
func (*FileInfo) GetPieceLength ¶
func (*FileInfo) ProtoMessage ¶
func (*FileInfo) ProtoMessage()
func (*FileInfo) ProtoReflect ¶
func (x *FileInfo) ProtoReflect() protoreflect.Message
type GetPeersRequest ¶
type GetPeersRequest struct { HashFile string `protobuf:"bytes,1,opt,name=hash_file,json=hashFile,proto3" json:"hash_file,omitempty"` // хэш файла - файл который надо скачать PeerId string `protobuf:"bytes,2,opt,name=peer_id,json=peerId,proto3" json:"peer_id,omitempty"` // сгенерированный uuid клиента - его пир // contains filtered or unexported fields }
func (*GetPeersRequest) Descriptor
deprecated
func (*GetPeersRequest) Descriptor() ([]byte, []int)
Deprecated: Use GetPeersRequest.ProtoReflect.Descriptor instead.
func (*GetPeersRequest) GetHashFile ¶
func (x *GetPeersRequest) GetHashFile() string
func (*GetPeersRequest) GetPeerId ¶
func (x *GetPeersRequest) GetPeerId() string
func (*GetPeersRequest) ProtoMessage ¶
func (*GetPeersRequest) ProtoMessage()
func (*GetPeersRequest) ProtoReflect ¶
func (x *GetPeersRequest) ProtoReflect() protoreflect.Message
func (*GetPeersRequest) Reset ¶
func (x *GetPeersRequest) Reset()
func (*GetPeersRequest) String ¶
func (x *GetPeersRequest) String() string
type GetPieceRequest ¶
type GetPieceRequest struct { SerialNumber uint64 `protobuf:"varint,1,opt,name=serial_number,json=serialNumber,proto3" json:"serial_number,omitempty"` Hash string `protobuf:"bytes,2,opt,name=hash,proto3" json:"hash,omitempty"` // contains filtered or unexported fields }
func (*GetPieceRequest) Descriptor
deprecated
func (*GetPieceRequest) Descriptor() ([]byte, []int)
Deprecated: Use GetPieceRequest.ProtoReflect.Descriptor instead.
func (*GetPieceRequest) GetHash ¶
func (x *GetPieceRequest) GetHash() string
func (*GetPieceRequest) GetSerialNumber ¶
func (x *GetPieceRequest) GetSerialNumber() uint64
func (*GetPieceRequest) ProtoMessage ¶
func (*GetPieceRequest) ProtoMessage()
func (*GetPieceRequest) ProtoReflect ¶
func (x *GetPieceRequest) ProtoReflect() protoreflect.Message
func (*GetPieceRequest) Reset ¶
func (x *GetPieceRequest) Reset()
func (*GetPieceRequest) String ¶
func (x *GetPieceRequest) String() string
type ListFiles ¶
type ListFiles struct { Count uint64 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"` Files []*FileInfo `protobuf:"bytes,2,rep,name=files,proto3" json:"files,omitempty"` // contains filtered or unexported fields }
func (*ListFiles) Descriptor
deprecated
func (*ListFiles) ProtoMessage ¶
func (*ListFiles) ProtoMessage()
func (*ListFiles) ProtoReflect ¶
func (x *ListFiles) ProtoReflect() protoreflect.Message
type ListPeers ¶
type ListPeers struct { Count uint64 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"` Peers []*ListPeers_Peer `protobuf:"bytes,2,rep,name=peers,proto3" json:"peers,omitempty"` // contains filtered or unexported fields }
func (*ListPeers) Descriptor
deprecated
func (*ListPeers) GetPeers ¶
func (x *ListPeers) GetPeers() []*ListPeers_Peer
func (*ListPeers) ProtoMessage ¶
func (*ListPeers) ProtoMessage()
func (*ListPeers) ProtoReflect ¶
func (x *ListPeers) ProtoReflect() protoreflect.Message
type ListPeers_Peer ¶
type ListPeers_Peer struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // summary address SerialPieces []uint64 `protobuf:"varint,2,rep,packed,name=serial_pieces,json=serialPieces,proto3" json:"serial_pieces,omitempty"` // номера доступных кусочков // contains filtered or unexported fields }
func (*ListPeers_Peer) Descriptor
deprecated
func (*ListPeers_Peer) Descriptor() ([]byte, []int)
Deprecated: Use ListPeers_Peer.ProtoReflect.Descriptor instead.
func (*ListPeers_Peer) GetAddress ¶
func (x *ListPeers_Peer) GetAddress() string
func (*ListPeers_Peer) GetSerialPieces ¶
func (x *ListPeers_Peer) GetSerialPieces() []uint64
func (*ListPeers_Peer) ProtoMessage ¶
func (*ListPeers_Peer) ProtoMessage()
func (*ListPeers_Peer) ProtoReflect ¶
func (x *ListPeers_Peer) ProtoReflect() protoreflect.Message
func (*ListPeers_Peer) Reset ¶
func (x *ListPeers_Peer) Reset()
func (*ListPeers_Peer) String ¶
func (x *ListPeers_Peer) String() string
type PeerClient ¶
type PeerClient interface { GetPiece(ctx context.Context, in *GetPieceRequest, opts ...grpc.CallOption) (*Piece, error) UploadFile(ctx context.Context, in *File, opts ...grpc.CallOption) (*empty.Empty, error) GetFileInfo(ctx context.Context, in *File, opts ...grpc.CallOption) (*FileInfo, error) Download(ctx context.Context, in *DownloadFileRequest, opts ...grpc.CallOption) (*DownloadFileResponse, error) }
PeerClient is the client API for Peer service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
func NewPeerClient ¶
func NewPeerClient(cc grpc.ClientConnInterface) PeerClient
type PeerServer ¶
type PeerServer interface { GetPiece(context.Context, *GetPieceRequest) (*Piece, error) UploadFile(context.Context, *File) (*empty.Empty, error) GetFileInfo(context.Context, *File) (*FileInfo, error) Download(context.Context, *DownloadFileRequest) (*DownloadFileResponse, error) }
PeerServer is the server API for Peer service.
type Piece ¶
type Piece struct { Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` // кусочек SerialNumber uint64 `protobuf:"varint,2,opt,name=serial_number,json=serialNumber,proto3" json:"serial_number,omitempty"` // номер кусочка // contains filtered or unexported fields }
func (*Piece) Descriptor
deprecated
func (*Piece) GetPayload ¶
func (*Piece) GetSerialNumber ¶
func (*Piece) ProtoMessage ¶
func (*Piece) ProtoMessage()
func (*Piece) ProtoReflect ¶
func (x *Piece) ProtoReflect() protoreflect.Message
type PieceInfo ¶
type PieceInfo struct { HashFile string `protobuf:"bytes,1,opt,name=hash_file,json=hashFile,proto3" json:"hash_file,omitempty"` Serial uint64 `protobuf:"varint,2,opt,name=serial,proto3" json:"serial,omitempty"` // кусочек который скачан и раздается // contains filtered or unexported fields }
func (*PieceInfo) Descriptor
deprecated
func (*PieceInfo) GetHashFile ¶
func (*PieceInfo) ProtoMessage ¶
func (*PieceInfo) ProtoMessage()
func (*PieceInfo) ProtoReflect ¶
func (x *PieceInfo) ProtoReflect() protoreflect.Message
type TrackerClient ¶
type TrackerClient interface { GetAvailableFiles(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*ListFiles, error) GetFileInfo(ctx context.Context, in *DownloadFileRequest, opts ...grpc.CallOption) (*FileInfo, error) Upload(ctx context.Context, in *UploadFileRequest, opts ...grpc.CallOption) (*empty.Empty, error) GetPeers(ctx context.Context, in *GetPeersRequest, opts ...grpc.CallOption) (*ListPeers, error) PostPieceInfo(ctx context.Context, in *PieceInfo, opts ...grpc.CallOption) (*empty.Empty, error) }
TrackerClient is the client API for Tracker service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
func NewTrackerClient ¶
func NewTrackerClient(cc grpc.ClientConnInterface) TrackerClient
type TrackerServer ¶
type TrackerServer interface { GetAvailableFiles(context.Context, *empty.Empty) (*ListFiles, error) GetFileInfo(context.Context, *DownloadFileRequest) (*FileInfo, error) Upload(context.Context, *UploadFileRequest) (*empty.Empty, error) GetPeers(context.Context, *GetPeersRequest) (*ListPeers, error) PostPieceInfo(context.Context, *PieceInfo) (*empty.Empty, error) }
TrackerServer is the server API for Tracker service.
type UnimplementedPeerServer ¶
type UnimplementedPeerServer struct { }
UnimplementedPeerServer can be embedded to have forward compatible implementations.
func (*UnimplementedPeerServer) Download ¶
func (*UnimplementedPeerServer) Download(context.Context, *DownloadFileRequest) (*DownloadFileResponse, error)
func (*UnimplementedPeerServer) GetFileInfo ¶
func (*UnimplementedPeerServer) GetPiece ¶
func (*UnimplementedPeerServer) GetPiece(context.Context, *GetPieceRequest) (*Piece, error)
func (*UnimplementedPeerServer) UploadFile ¶
type UnimplementedTrackerServer ¶
type UnimplementedTrackerServer struct { }
UnimplementedTrackerServer can be embedded to have forward compatible implementations.
func (*UnimplementedTrackerServer) GetAvailableFiles ¶
func (*UnimplementedTrackerServer) GetFileInfo ¶
func (*UnimplementedTrackerServer) GetFileInfo(context.Context, *DownloadFileRequest) (*FileInfo, error)
func (*UnimplementedTrackerServer) GetPeers ¶
func (*UnimplementedTrackerServer) GetPeers(context.Context, *GetPeersRequest) (*ListPeers, error)
func (*UnimplementedTrackerServer) PostPieceInfo ¶
func (*UnimplementedTrackerServer) Upload ¶
func (*UnimplementedTrackerServer) Upload(context.Context, *UploadFileRequest) (*empty.Empty, error)
type UploadFileRequest ¶
type UploadFileRequest struct { ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // имя файла PieceLength uint64 `protobuf:"varint,3,opt,name=piece_length,json=pieceLength,proto3" json:"piece_length,omitempty"` // длина кусочка Pieces uint64 `protobuf:"varint,4,opt,name=pieces,proto3" json:"pieces,omitempty"` // всего кусочков Length uint64 `protobuf:"varint,5,opt,name=length,proto3" json:"length,omitempty"` // длина файла Hash string `protobuf:"bytes,6,opt,name=hash,proto3" json:"hash,omitempty"` // хэш файла // contains filtered or unexported fields }
func (*UploadFileRequest) Descriptor
deprecated
func (*UploadFileRequest) Descriptor() ([]byte, []int)
Deprecated: Use UploadFileRequest.ProtoReflect.Descriptor instead.
func (*UploadFileRequest) GetClientId ¶
func (x *UploadFileRequest) GetClientId() string
func (*UploadFileRequest) GetHash ¶
func (x *UploadFileRequest) GetHash() string
func (*UploadFileRequest) GetLength ¶
func (x *UploadFileRequest) GetLength() uint64
func (*UploadFileRequest) GetName ¶
func (x *UploadFileRequest) GetName() string
func (*UploadFileRequest) GetPieceLength ¶
func (x *UploadFileRequest) GetPieceLength() uint64
func (*UploadFileRequest) GetPieces ¶
func (x *UploadFileRequest) GetPieces() uint64
func (*UploadFileRequest) ProtoMessage ¶
func (*UploadFileRequest) ProtoMessage()
func (*UploadFileRequest) ProtoReflect ¶
func (x *UploadFileRequest) ProtoReflect() protoreflect.Message
func (*UploadFileRequest) Reset ¶
func (x *UploadFileRequest) Reset()
func (*UploadFileRequest) String ¶
func (x *UploadFileRequest) String() string