common

package
v0.1.37 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: AGPL-3.0 Imports: 12 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrResp

func ErrResp[T RespType](c *gin.Context, origin *T, err string)

func ErrUnAuthorized

func ErrUnAuthorized(c *gin.Context, err string)

func GetProtoRequest

func GetProtoRequest[T ReqType](c *gin.Context) (r *T, err error)

func GetServerMessageRequest

func GetServerMessageRequest[T ReqType](b []byte, r *T, trans func(b []byte, m protoreflect.ProtoMessage) error) (err error)

func GetTokenPermission added in v0.1.12

func GetTokenPermission(c context.Context) ([]defs.APIPermission, error)

func GetTokenString added in v0.1.12

func GetTokenString(c context.Context) string

func GetUserInfo

func GetUserInfo(c context.Context) models.UserInfo

func OKResp

func OKResp[T RespType](c *gin.Context, origin *T)

func ProtoResp

func ProtoResp[T RespType](origin *T) (*pb.ClientMessage, error)

Types

type ReqType

type ReqType interface {
	pb.UpdateFRPCRequest | pb.RemoveFRPCRequest |
		pb.UpdateFRPSRequest | pb.RemoveFRPSRequest |
		pb.CommonRequest | pb.RegisterRequest | pb.LoginRequest |
		pb.InitClientRequest | pb.ListClientsRequest | pb.GetClientRequest |
		pb.DeleteClientRequest |
		pb.InitServerRequest | pb.ListServersRequest | pb.GetServerRequest |
		pb.DeleteServerRequest |
		pb.GetUserInfoRequest | pb.UpdateUserInfoRequest |
		pb.GetPlatformInfoRequest | pb.GetClientsStatusRequest |
		pb.GetClientCertRequest |
		pb.StartFRPCRequest | pb.StopFRPCRequest | pb.StartFRPSRequest | pb.StopFRPSRequest |
		pb.GetProxyStatsByClientIDRequest | pb.GetProxyStatsByServerIDRequest |
		pb.CreateProxyConfigRequest | pb.ListProxyConfigsRequest | pb.UpdateProxyConfigRequest |
		pb.DeleteProxyConfigRequest | pb.GetProxyConfigRequest | pb.SignTokenRequest |
		pb.StartProxyRequest | pb.StopProxyRequest |
		pb.CreateWorkerRequest | pb.RemoveWorkerRequest | pb.RunWorkerRequest | pb.StopWorkerRequest | pb.UpdateWorkerRequest | pb.GetWorkerRequest |
		pb.ListWorkersRequest | pb.CreateWorkerIngressRequest | pb.GetWorkerIngressRequest |
		pb.GetWorkerStatusRequest | pb.InstallWorkerdRequest | pb.RedeployWorkerRequest | pb.UpgradeFrppRequest |
		pb.StartSteamLogRequest |

		pb.CreateNetworkRequest | pb.DeleteNetworkRequest | pb.UpdateNetworkRequest | pb.GetNetworkRequest | pb.ListNetworksRequest | pb.RestartWireGuardRequest |
		pb.CreateEndpointRequest | pb.DeleteEndpointRequest | pb.UpdateEndpointRequest | pb.GetEndpointRequest | pb.ListEndpointsRequest |
		pb.CreateWireGuardRequest | pb.DeleteWireGuardRequest | pb.UpdateWireGuardRequest | pb.GetWireGuardRequest | pb.ListWireGuardsRequest |
		pb.CreateWireGuardLinkRequest | pb.DeleteWireGuardLinkRequest | pb.UpdateWireGuardLinkRequest | pb.GetWireGuardLinkRequest | pb.ListWireGuardLinksRequest |
		pb.GetWireGuardRuntimeInfoRequest | pb.GetNetworkTopologyRequest
}

type RespType

type RespType interface {
	pb.UpdateFRPCResponse | pb.RemoveFRPCResponse |
		pb.UpdateFRPSResponse | pb.RemoveFRPSResponse |
		pb.CommonResponse | pb.RegisterResponse | pb.LoginResponse |
		pb.InitClientResponse | pb.ListClientsResponse | pb.GetClientResponse |
		pb.DeleteClientResponse |
		pb.InitServerResponse | pb.ListServersResponse | pb.GetServerResponse |
		pb.DeleteServerResponse |
		pb.GetUserInfoResponse | pb.UpdateUserInfoResponse |
		pb.GetPlatformInfoResponse | pb.GetClientsStatusResponse |
		pb.GetClientCertResponse |
		pb.StartFRPCResponse | pb.StopFRPCResponse | pb.StartFRPSResponse | pb.StopFRPSResponse |
		pb.GetProxyStatsByClientIDResponse | pb.GetProxyStatsByServerIDResponse |
		pb.CreateProxyConfigResponse | pb.ListProxyConfigsResponse | pb.UpdateProxyConfigResponse |
		pb.DeleteProxyConfigResponse | pb.GetProxyConfigResponse | pb.SignTokenResponse |
		pb.StartProxyResponse | pb.StopProxyResponse |
		pb.CreateWorkerResponse | pb.RemoveWorkerResponse | pb.RunWorkerResponse | pb.StopWorkerResponse | pb.UpdateWorkerResponse | pb.GetWorkerResponse |
		pb.ListWorkersResponse | pb.CreateWorkerIngressResponse | pb.GetWorkerIngressResponse |
		pb.GetWorkerStatusResponse | pb.InstallWorkerdResponse | pb.RedeployWorkerResponse | pb.UpgradeFrppResponse |
		pb.StartSteamLogResponse |

		pb.CreateNetworkResponse | pb.DeleteNetworkResponse | pb.UpdateNetworkResponse | pb.GetNetworkResponse | pb.ListNetworksResponse | pb.RestartWireGuardResponse |
		pb.CreateEndpointResponse | pb.DeleteEndpointResponse | pb.UpdateEndpointResponse | pb.GetEndpointResponse | pb.ListEndpointsResponse |
		pb.CreateWireGuardResponse | pb.DeleteWireGuardResponse | pb.UpdateWireGuardResponse | pb.GetWireGuardResponse | pb.ListWireGuardsResponse |
		pb.CreateWireGuardLinkResponse | pb.DeleteWireGuardLinkResponse | pb.UpdateWireGuardLinkResponse | pb.GetWireGuardLinkResponse | pb.ListWireGuardLinksResponse |
		pb.GetWireGuardRuntimeInfoResponse | pb.GetNetworkTopologyResponse
}

type Result

type Result struct {
	Code int         `json:"code,omitempty"`
	Msg  string      `json:"msg,omitempty"`
	Data gin.H       `json:"data,omitempty"`
	Body interface{} `json:"body,omitempty"`
}

func Err

func Err(msg string) *Result

func OK

func OK(msg string) *Result

func UnAuth

func UnAuth(msg string) *Result

func (*Result) WithBody

func (r *Result) WithBody(body interface{}) *Result

func (*Result) WithData

func (r *Result) WithData(data gin.H) *Result

func (*Result) WithKeyValue

func (r *Result) WithKeyValue(key string, value interface{}) *Result

func (*Result) WithMsg

func (r *Result) WithMsg(message string) *Result

Jump to

Keyboard shortcuts

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