server

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MigrationRepo

type MigrationRepo interface {
	HasMigrateServerNode(ctx context.Context) (bool, error)
	MigrateServerNode(ctx context.Context) (uint64, uint64, string, error)
}

type MigrationUsecase

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

MigrationUsecase is the migration use case

func NewMigrationUsecase

func NewMigrationUsecase(repo MigrationRepo, logger log.Logger) *MigrationUsecase

NewMigrationUsecase creates a new migration use case

func (*MigrationUsecase) HasMigrateServerNode

func (uc *MigrationUsecase) HasMigrateServerNode(ctx context.Context) (bool, error)

HasMigrateServerNode checks if there's data to migrate

func (*MigrationUsecase) MigrateServerNode

func (uc *MigrationUsecase) MigrateServerNode(ctx context.Context) (uint64, uint64, string, error)

MigrateServerNode migrates server and node data

type Node

type Node struct {
	ID           int64
	Name         string
	Tags         []string
	Port         uint16
	Address      string
	ServerID     int64
	Protocol     string
	Enabled      *bool
	NodeType     string
	IsHidden     *bool
	Sort         uint32
	NodeGroupID  int64
	NodeGroupIDs []int64
	CreatedAt    int64
	UpdatedAt    int64
}

type NodeRepo

type NodeRepo interface {
	CreateNode(ctx context.Context, node *Node) (*Node, error)
	UpdateNode(ctx context.Context, node *Node) (*Node, error)
	DeleteNode(ctx context.Context, id int) error
	FilterNodeList(ctx context.Context, page, size int32, search string, nodeGroupID *int64) (int32, []*Node, error)
	ToggleNodeStatus(ctx context.Context, id int, enable *bool) (*Node, error)
	QueryNodeTags(ctx context.Context) ([]string, error)
	ResetNodeSort(ctx context.Context, sortItems []*SortItem) error
	ClearNodeCache(ctx context.Context, serverIDs []int) error
	GetServerProtocols(ctx context.Context, id int) ([]*server.Protocol, error)
}

type NodeUsecase

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

func NewNodeUsecase

func NewNodeUsecase(repo NodeRepo, logger log.Logger) *NodeUsecase

func (*NodeUsecase) CreateNode

func (uc *NodeUsecase) CreateNode(ctx context.Context, name string, tags []string, port uint16, address string, serverID int64, protocol string, enabled *bool, nodeType string, isHidden *bool, nodeGroupIDs []int64) (*Node, error)

func (*NodeUsecase) DeleteNode

func (uc *NodeUsecase) DeleteNode(ctx context.Context, id int) error

func (*NodeUsecase) FilterNodeList

func (uc *NodeUsecase) FilterNodeList(ctx context.Context, page, size int32, search string, nodeGroupID *int64) (int32, []*Node, error)

func (*NodeUsecase) QueryNodeTags

func (uc *NodeUsecase) QueryNodeTags(ctx context.Context) ([]string, error)

func (*NodeUsecase) ResetNodeSort

func (uc *NodeUsecase) ResetNodeSort(ctx context.Context, sortItems []*SortItem) error

func (*NodeUsecase) ToggleNodeStatus

func (uc *NodeUsecase) ToggleNodeStatus(ctx context.Context, id int, enable *bool) (*Node, error)

func (*NodeUsecase) UpdateNode

func (uc *NodeUsecase) UpdateNode(ctx context.Context, id int, name string, tags []string, port uint16, address string, serverID int64, protocol string, enabled *bool, nodeType string, isHidden *bool, nodeGroupIDs []int64) (*Node, error)

type Server

type Server struct {
	ID             int64
	Name           string
	Country        string
	City           string
	Address        string
	Sort           int
	Protocols      []*server.Protocol
	LastReportedAt int64
	Status         *ServerStatus
	CreatedAt      int64
	UpdatedAt      int64
}

Server represents a proxy server

type ServerOnlineIP

type ServerOnlineIP struct {
	IP       string
	Protocol string
}

type ServerOnlineUser

type ServerOnlineUser struct {
	IP          []*ServerOnlineIP
	UserID      int64
	Subscribe   string
	SubscribeID int64
	Traffic     int64
	ExpiredAt   int64
}

type ServerRepo

type ServerRepo interface {
	CreateServer(ctx context.Context, server *Server) (*Server, error)
	UpdateServer(ctx context.Context, server *Server) (*Server, error)
	DeleteServer(ctx context.Context, id int) error
	GetServerByID(ctx context.Context, id int) (*Server, error)
	FilterServerList(ctx context.Context, page, size int32, search string) (int32, []*Server, error)
	GetServerProtocols(ctx context.Context, id int) ([]*server.Protocol, error)
	ResetServerSort(ctx context.Context, sortItems []*SortItem) error
	GetServerStatus(ctx context.Context, serverID int) (*ServerResourceStatus, error)
	GetOnlineUsers(ctx context.Context, serverID int64, protocol string, port uint16) (map[int64][]string, error)
	GetOnlineUsersByServer(ctx context.Context, serverID int64) (map[string]map[int64][]string, error)
	GetUserSubscribeInfo(ctx context.Context, subscribeID int) (*UserSubscribeInfo, error)
}

type ServerResourceStatus

type ServerResourceStatus struct {
	Cpu  float64
	Mem  float64
	Disk float64
}

type ServerStatus

type ServerStatus struct {
	Cpu      float64
	Mem      float64
	Disk     float64
	Protocol string
	Online   []*ServerOnlineUser
	Status   string
}

type ServerUsecase

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

func NewServerUsecase

func NewServerUsecase(repo ServerRepo, nodeRepo NodeRepo, logger log.Logger) *ServerUsecase

func (*ServerUsecase) CreateServer

func (uc *ServerUsecase) CreateServer(ctx context.Context, name, country, city, address string, sort int64, protocols []*server.Protocol) (*Server, error)

func (*ServerUsecase) DeleteServer

func (uc *ServerUsecase) DeleteServer(ctx context.Context, id int) error

func (*ServerUsecase) FilterServerList

func (uc *ServerUsecase) FilterServerList(ctx context.Context, page, size int32, search string) (int32, []*Server, error)

func (*ServerUsecase) GetServerProtocols

func (uc *ServerUsecase) GetServerProtocols(ctx context.Context, id int) ([]*server.Protocol, error)

func (*ServerUsecase) ResetServerSort

func (uc *ServerUsecase) ResetServerSort(ctx context.Context, sortItems []*SortItem) error

func (*ServerUsecase) UpdateServer

func (uc *ServerUsecase) UpdateServer(ctx context.Context, id int, name, country, city, address string, sort int64, protocols []*server.Protocol) (*Server, error)

type SortItem

type SortItem struct {
	ID   int64
	Sort int
}

type UserSubscribeInfo

type UserSubscribeInfo struct {
	UserID      int64
	SubscribeID int64
	Subscribe   string
	Download    int64
	Upload      int64
	ExpireTime  int64
}

Jump to

Keyboard shortcuts

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