service

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2022 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const Name = "API_SERVICE"

Variables

View Source
var (
	SetUsersRequest_Operation_name = map[int32]string{
		0: "Add",
		1: "Delete",
		2: "Modify",
	}
	SetUsersRequest_Operation_value = map[string]int32{
		"Add":    0,
		"Delete": 1,
		"Modify": 2,
	}
)

Enum value maps for SetUsersRequest_Operation.

View Source
var TrojanClientService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "trojan.api.TrojanClientService",
	HandlerType: (*TrojanClientServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "GetTraffic",
			Handler:    _TrojanClientService_GetTraffic_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "api.proto",
}

TrojanClientService_ServiceDesc is the grpc.ServiceDesc for TrojanClientService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

View Source
var TrojanServerService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "trojan.api.TrojanServerService",
	HandlerType: (*TrojanServerServiceServer)(nil),
	Methods:     []grpc.MethodDesc{},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "ListUsers",
			Handler:       _TrojanServerService_ListUsers_Handler,
			ServerStreams: true,
		},
		{
			StreamName:    "GetUsers",
			Handler:       _TrojanServerService_GetUsers_Handler,
			ServerStreams: true,
			ClientStreams: true,
		},
		{
			StreamName:    "SetUsers",
			Handler:       _TrojanServerService_SetUsers_Handler,
			ServerStreams: true,
			ClientStreams: true,
		},
	},
	Metadata: "api.proto",
}

TrojanServerService_ServiceDesc is the grpc.ServiceDesc for TrojanServerService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterTrojanClientServiceServer

func RegisterTrojanClientServiceServer(s grpc.ServiceRegistrar, srv TrojanClientServiceServer)

func RegisterTrojanServerServiceServer

func RegisterTrojanServerServiceServer(s grpc.ServiceRegistrar, srv TrojanServerServiceServer)

func RunClientAPI

func RunClientAPI(ctx context.Context, auth statistic.Authenticator) error

func RunServerAPI

func RunServerAPI(ctx context.Context, auth statistic.Authenticator) error

Types

type APIConfig

type APIConfig struct {
	Enabled bool      `json:"enabled" yaml:"enabled"`
	APIHost string    `json:"api_addr" yaml:"api-addr"`
	APIPort int       `json:"api_port" yaml:"api-port"`
	SSL     SSLConfig `json:"ssl" yaml:"ssl"`
}

type ClientAPI

type ClientAPI struct {
	TrojanClientServiceServer
	// contains filtered or unexported fields
}

func (*ClientAPI) GetTraffic

func (s *ClientAPI) GetTraffic(ctx context.Context, req *GetTrafficRequest) (*GetTrafficResponse, error)

type Config

type Config struct {
	API APIConfig `json:"api" yaml:"api"`
}

type GetTrafficRequest

type GetTrafficRequest struct {
	User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
	// contains filtered or unexported fields
}

func (*GetTrafficRequest) Descriptor deprecated

func (*GetTrafficRequest) Descriptor() ([]byte, []int)

Deprecated: Use GetTrafficRequest.ProtoReflect.Descriptor instead.

func (*GetTrafficRequest) GetUser

func (x *GetTrafficRequest) GetUser() *User

func (*GetTrafficRequest) ProtoMessage

func (*GetTrafficRequest) ProtoMessage()

func (*GetTrafficRequest) ProtoReflect

func (x *GetTrafficRequest) ProtoReflect() protoreflect.Message

func (*GetTrafficRequest) Reset

func (x *GetTrafficRequest) Reset()

func (*GetTrafficRequest) String

func (x *GetTrafficRequest) String() string

type GetTrafficResponse

type GetTrafficResponse struct {
	Success      bool     `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
	Info         string   `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"`
	TrafficTotal *Traffic `protobuf:"bytes,3,opt,name=traffic_total,json=trafficTotal,proto3" json:"traffic_total,omitempty"`
	SpeedCurrent *Speed   `protobuf:"bytes,4,opt,name=speed_current,json=speedCurrent,proto3" json:"speed_current,omitempty"`
	// contains filtered or unexported fields
}

func (*GetTrafficResponse) Descriptor deprecated

func (*GetTrafficResponse) Descriptor() ([]byte, []int)

Deprecated: Use GetTrafficResponse.ProtoReflect.Descriptor instead.

func (*GetTrafficResponse) GetInfo

func (x *GetTrafficResponse) GetInfo() string

func (*GetTrafficResponse) GetSpeedCurrent

func (x *GetTrafficResponse) GetSpeedCurrent() *Speed

func (*GetTrafficResponse) GetSuccess

func (x *GetTrafficResponse) GetSuccess() bool

func (*GetTrafficResponse) GetTrafficTotal

func (x *GetTrafficResponse) GetTrafficTotal() *Traffic

func (*GetTrafficResponse) ProtoMessage

func (*GetTrafficResponse) ProtoMessage()

func (*GetTrafficResponse) ProtoReflect

func (x *GetTrafficResponse) ProtoReflect() protoreflect.Message

func (*GetTrafficResponse) Reset

func (x *GetTrafficResponse) Reset()

func (*GetTrafficResponse) String

func (x *GetTrafficResponse) String() string

type GetUsersRequest

type GetUsersRequest struct {
	User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
	// contains filtered or unexported fields
}

func (*GetUsersRequest) Descriptor deprecated

func (*GetUsersRequest) Descriptor() ([]byte, []int)

Deprecated: Use GetUsersRequest.ProtoReflect.Descriptor instead.

func (*GetUsersRequest) GetUser

func (x *GetUsersRequest) GetUser() *User

func (*GetUsersRequest) ProtoMessage

func (*GetUsersRequest) ProtoMessage()

func (*GetUsersRequest) ProtoReflect

func (x *GetUsersRequest) ProtoReflect() protoreflect.Message

func (*GetUsersRequest) Reset

func (x *GetUsersRequest) Reset()

func (*GetUsersRequest) String

func (x *GetUsersRequest) String() string

type GetUsersResponse

type GetUsersResponse struct {
	Success bool        `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
	Info    string      `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"`
	Status  *UserStatus `protobuf:"bytes,3,opt,name=status,proto3" json:"status,omitempty"`
	// contains filtered or unexported fields
}

func (*GetUsersResponse) Descriptor deprecated

func (*GetUsersResponse) Descriptor() ([]byte, []int)

Deprecated: Use GetUsersResponse.ProtoReflect.Descriptor instead.

func (*GetUsersResponse) GetInfo

func (x *GetUsersResponse) GetInfo() string

func (*GetUsersResponse) GetStatus

func (x *GetUsersResponse) GetStatus() *UserStatus

func (*GetUsersResponse) GetSuccess

func (x *GetUsersResponse) GetSuccess() bool

func (*GetUsersResponse) ProtoMessage

func (*GetUsersResponse) ProtoMessage()

func (*GetUsersResponse) ProtoReflect

func (x *GetUsersResponse) ProtoReflect() protoreflect.Message

func (*GetUsersResponse) Reset

func (x *GetUsersResponse) Reset()

func (*GetUsersResponse) String

func (x *GetUsersResponse) String() string

type ListUsersRequest

type ListUsersRequest struct {
	// contains filtered or unexported fields
}

func (*ListUsersRequest) Descriptor deprecated

func (*ListUsersRequest) Descriptor() ([]byte, []int)

Deprecated: Use ListUsersRequest.ProtoReflect.Descriptor instead.

func (*ListUsersRequest) ProtoMessage

func (*ListUsersRequest) ProtoMessage()

func (*ListUsersRequest) ProtoReflect

func (x *ListUsersRequest) ProtoReflect() protoreflect.Message

func (*ListUsersRequest) Reset

func (x *ListUsersRequest) Reset()

func (*ListUsersRequest) String

func (x *ListUsersRequest) String() string

type ListUsersResponse

type ListUsersResponse struct {
	Status *UserStatus `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"`
	// contains filtered or unexported fields
}

func (*ListUsersResponse) Descriptor deprecated

func (*ListUsersResponse) Descriptor() ([]byte, []int)

Deprecated: Use ListUsersResponse.ProtoReflect.Descriptor instead.

func (*ListUsersResponse) GetStatus

func (x *ListUsersResponse) GetStatus() *UserStatus

func (*ListUsersResponse) ProtoMessage

func (*ListUsersResponse) ProtoMessage()

func (*ListUsersResponse) ProtoReflect

func (x *ListUsersResponse) ProtoReflect() protoreflect.Message

func (*ListUsersResponse) Reset

func (x *ListUsersResponse) Reset()

func (*ListUsersResponse) String

func (x *ListUsersResponse) String() string

type SSLConfig

type SSLConfig struct {
	Enabled        bool     `json:"enabled" yaml:"enabled"`
	CertPath       string   `json:"cert" yaml:"cert"`
	KeyPath        string   `json:"key" yaml:"key"`
	VerifyClient   bool     `json:"verify_client" yaml:"verify-client"`
	ClientCertPath []string `json:"client_cert" yaml:"client-cert"`
}

type ServerAPI

type ServerAPI struct {
	TrojanServerServiceServer
	// contains filtered or unexported fields
}

func (*ServerAPI) GetUsers

func (*ServerAPI) ListUsers

func (*ServerAPI) SetUsers

type SetUsersRequest

type SetUsersRequest struct {
	Status    *UserStatus               `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"`
	Operation SetUsersRequest_Operation `protobuf:"varint,2,opt,name=operation,proto3,enum=trojan.api.SetUsersRequest_Operation" json:"operation,omitempty"`
	// contains filtered or unexported fields
}

func (*SetUsersRequest) Descriptor deprecated

func (*SetUsersRequest) Descriptor() ([]byte, []int)

Deprecated: Use SetUsersRequest.ProtoReflect.Descriptor instead.

func (*SetUsersRequest) GetOperation

func (x *SetUsersRequest) GetOperation() SetUsersRequest_Operation

func (*SetUsersRequest) GetStatus

func (x *SetUsersRequest) GetStatus() *UserStatus

func (*SetUsersRequest) ProtoMessage

func (*SetUsersRequest) ProtoMessage()

func (*SetUsersRequest) ProtoReflect

func (x *SetUsersRequest) ProtoReflect() protoreflect.Message

func (*SetUsersRequest) Reset

func (x *SetUsersRequest) Reset()

func (*SetUsersRequest) String

func (x *SetUsersRequest) String() string

type SetUsersRequest_Operation

type SetUsersRequest_Operation int32
const (
	SetUsersRequest_Add    SetUsersRequest_Operation = 0
	SetUsersRequest_Delete SetUsersRequest_Operation = 1
	SetUsersRequest_Modify SetUsersRequest_Operation = 2
)

func (SetUsersRequest_Operation) Descriptor

func (SetUsersRequest_Operation) Enum

func (SetUsersRequest_Operation) EnumDescriptor deprecated

func (SetUsersRequest_Operation) EnumDescriptor() ([]byte, []int)

Deprecated: Use SetUsersRequest_Operation.Descriptor instead.

func (SetUsersRequest_Operation) Number

func (SetUsersRequest_Operation) String

func (x SetUsersRequest_Operation) String() string

func (SetUsersRequest_Operation) Type

type SetUsersResponse

type SetUsersResponse struct {
	Success bool   `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
	Info    string `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"`
	// contains filtered or unexported fields
}

func (*SetUsersResponse) Descriptor deprecated

func (*SetUsersResponse) Descriptor() ([]byte, []int)

Deprecated: Use SetUsersResponse.ProtoReflect.Descriptor instead.

func (*SetUsersResponse) GetInfo

func (x *SetUsersResponse) GetInfo() string

func (*SetUsersResponse) GetSuccess

func (x *SetUsersResponse) GetSuccess() bool

func (*SetUsersResponse) ProtoMessage

func (*SetUsersResponse) ProtoMessage()

func (*SetUsersResponse) ProtoReflect

func (x *SetUsersResponse) ProtoReflect() protoreflect.Message

func (*SetUsersResponse) Reset

func (x *SetUsersResponse) Reset()

func (*SetUsersResponse) String

func (x *SetUsersResponse) String() string

type Speed

type Speed struct {
	UploadSpeed   uint64 `protobuf:"varint,1,opt,name=upload_speed,json=uploadSpeed,proto3" json:"upload_speed,omitempty"`
	DownloadSpeed uint64 `protobuf:"varint,2,opt,name=download_speed,json=downloadSpeed,proto3" json:"download_speed,omitempty"`
	// contains filtered or unexported fields
}

func (*Speed) Descriptor deprecated

func (*Speed) Descriptor() ([]byte, []int)

Deprecated: Use Speed.ProtoReflect.Descriptor instead.

func (*Speed) GetDownloadSpeed

func (x *Speed) GetDownloadSpeed() uint64

func (*Speed) GetUploadSpeed

func (x *Speed) GetUploadSpeed() uint64

func (*Speed) ProtoMessage

func (*Speed) ProtoMessage()

func (*Speed) ProtoReflect

func (x *Speed) ProtoReflect() protoreflect.Message

func (*Speed) Reset

func (x *Speed) Reset()

func (*Speed) String

func (x *Speed) String() string

type Traffic

type Traffic struct {
	UploadTraffic   uint64 `protobuf:"varint,1,opt,name=upload_traffic,json=uploadTraffic,proto3" json:"upload_traffic,omitempty"`
	DownloadTraffic uint64 `protobuf:"varint,2,opt,name=download_traffic,json=downloadTraffic,proto3" json:"download_traffic,omitempty"`
	// contains filtered or unexported fields
}

func (*Traffic) Descriptor deprecated

func (*Traffic) Descriptor() ([]byte, []int)

Deprecated: Use Traffic.ProtoReflect.Descriptor instead.

func (*Traffic) GetDownloadTraffic

func (x *Traffic) GetDownloadTraffic() uint64

func (*Traffic) GetUploadTraffic

func (x *Traffic) GetUploadTraffic() uint64

func (*Traffic) ProtoMessage

func (*Traffic) ProtoMessage()

func (*Traffic) ProtoReflect

func (x *Traffic) ProtoReflect() protoreflect.Message

func (*Traffic) Reset

func (x *Traffic) Reset()

func (*Traffic) String

func (x *Traffic) String() string

type TrojanClientServiceClient

type TrojanClientServiceClient interface {
	GetTraffic(ctx context.Context, in *GetTrafficRequest, opts ...grpc.CallOption) (*GetTrafficResponse, error)
}

TrojanClientServiceClient is the client API for TrojanClientService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

type TrojanClientServiceServer

type TrojanClientServiceServer interface {
	GetTraffic(context.Context, *GetTrafficRequest) (*GetTrafficResponse, error)
	// contains filtered or unexported methods
}

TrojanClientServiceServer is the server API for TrojanClientService service. All implementations must embed UnimplementedTrojanClientServiceServer for forward compatibility

type TrojanServerServiceClient

type TrojanServerServiceClient interface {
	// list all users
	ListUsers(ctx context.Context, in *ListUsersRequest, opts ...grpc.CallOption) (TrojanServerService_ListUsersClient, error)
	// obtain specified user's info
	GetUsers(ctx context.Context, opts ...grpc.CallOption) (TrojanServerService_GetUsersClient, error)
	// setup existing users' config
	SetUsers(ctx context.Context, opts ...grpc.CallOption) (TrojanServerService_SetUsersClient, error)
}

TrojanServerServiceClient is the client API for TrojanServerService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

type TrojanServerServiceServer

type TrojanServerServiceServer interface {
	// list all users
	ListUsers(*ListUsersRequest, TrojanServerService_ListUsersServer) error
	// obtain specified user's info
	GetUsers(TrojanServerService_GetUsersServer) error
	// setup existing users' config
	SetUsers(TrojanServerService_SetUsersServer) error
	// contains filtered or unexported methods
}

TrojanServerServiceServer is the server API for TrojanServerService service. All implementations must embed UnimplementedTrojanServerServiceServer for forward compatibility

type TrojanServerService_GetUsersClient

type TrojanServerService_GetUsersClient interface {
	Send(*GetUsersRequest) error
	Recv() (*GetUsersResponse, error)
	grpc.ClientStream
}

type TrojanServerService_GetUsersServer

type TrojanServerService_GetUsersServer interface {
	Send(*GetUsersResponse) error
	Recv() (*GetUsersRequest, error)
	grpc.ServerStream
}

type TrojanServerService_ListUsersClient

type TrojanServerService_ListUsersClient interface {
	Recv() (*ListUsersResponse, error)
	grpc.ClientStream
}

type TrojanServerService_ListUsersServer

type TrojanServerService_ListUsersServer interface {
	Send(*ListUsersResponse) error
	grpc.ServerStream
}

type TrojanServerService_SetUsersClient

type TrojanServerService_SetUsersClient interface {
	Send(*SetUsersRequest) error
	Recv() (*SetUsersResponse, error)
	grpc.ClientStream
}

type TrojanServerService_SetUsersServer

type TrojanServerService_SetUsersServer interface {
	Send(*SetUsersResponse) error
	Recv() (*SetUsersRequest, error)
	grpc.ServerStream
}

type UnimplementedTrojanClientServiceServer

type UnimplementedTrojanClientServiceServer struct {
}

UnimplementedTrojanClientServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedTrojanClientServiceServer) GetTraffic

type UnimplementedTrojanServerServiceServer

type UnimplementedTrojanServerServiceServer struct {
}

UnimplementedTrojanServerServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedTrojanServerServiceServer) GetUsers

func (UnimplementedTrojanServerServiceServer) ListUsers

func (UnimplementedTrojanServerServiceServer) SetUsers

type UnsafeTrojanClientServiceServer

type UnsafeTrojanClientServiceServer interface {
	// contains filtered or unexported methods
}

UnsafeTrojanClientServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to TrojanClientServiceServer will result in compilation errors.

type UnsafeTrojanServerServiceServer

type UnsafeTrojanServerServiceServer interface {
	// contains filtered or unexported methods
}

UnsafeTrojanServerServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to TrojanServerServiceServer will result in compilation errors.

type User

type User struct {
	Password string `protobuf:"bytes,1,opt,name=password,proto3" json:"password,omitempty"`
	Hash     string `protobuf:"bytes,2,opt,name=hash,proto3" json:"hash,omitempty"`
	// contains filtered or unexported fields
}

func (*User) Descriptor deprecated

func (*User) Descriptor() ([]byte, []int)

Deprecated: Use User.ProtoReflect.Descriptor instead.

func (*User) GetHash

func (x *User) GetHash() string

func (*User) GetPassword

func (x *User) GetPassword() string

func (*User) ProtoMessage

func (*User) ProtoMessage()

func (*User) ProtoReflect

func (x *User) ProtoReflect() protoreflect.Message

func (*User) Reset

func (x *User) Reset()

func (*User) String

func (x *User) String() string

type UserStatus

type UserStatus struct {
	User         *User    `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
	TrafficTotal *Traffic `protobuf:"bytes,2,opt,name=traffic_total,json=trafficTotal,proto3" json:"traffic_total,omitempty"`
	SpeedCurrent *Speed   `protobuf:"bytes,3,opt,name=speed_current,json=speedCurrent,proto3" json:"speed_current,omitempty"`
	SpeedLimit   *Speed   `protobuf:"bytes,4,opt,name=speed_limit,json=speedLimit,proto3" json:"speed_limit,omitempty"`
	IpCurrent    int32    `protobuf:"varint,5,opt,name=ip_current,json=ipCurrent,proto3" json:"ip_current,omitempty"`
	IpLimit      int32    `protobuf:"varint,6,opt,name=ip_limit,json=ipLimit,proto3" json:"ip_limit,omitempty"`
	// contains filtered or unexported fields
}

func (*UserStatus) Descriptor deprecated

func (*UserStatus) Descriptor() ([]byte, []int)

Deprecated: Use UserStatus.ProtoReflect.Descriptor instead.

func (*UserStatus) GetIpCurrent

func (x *UserStatus) GetIpCurrent() int32

func (*UserStatus) GetIpLimit

func (x *UserStatus) GetIpLimit() int32

func (*UserStatus) GetSpeedCurrent

func (x *UserStatus) GetSpeedCurrent() *Speed

func (*UserStatus) GetSpeedLimit

func (x *UserStatus) GetSpeedLimit() *Speed

func (*UserStatus) GetTrafficTotal

func (x *UserStatus) GetTrafficTotal() *Traffic

func (*UserStatus) GetUser

func (x *UserStatus) GetUser() *User

func (*UserStatus) ProtoMessage

func (*UserStatus) ProtoMessage()

func (*UserStatus) ProtoReflect

func (x *UserStatus) ProtoReflect() protoreflect.Message

func (*UserStatus) Reset

func (x *UserStatus) Reset()

func (*UserStatus) String

func (x *UserStatus) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL