clients

package
v1.6.13 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateClient

func CreateClient() (clientUUID, token string, err error)

CreateClient 创建新客户端

func CreateClientWithName

func CreateClientWithName(name string) (clientUUID, token string, err error)

func DeleteClient

func DeleteClient(clientUuid string) error

func GetAllClientBasicInfo

func GetAllClientBasicInfo() (clients []models.Client, err error)

func GetClientByUUID

func GetClientByUUID(uuid string) (client models.Client, err error)

// GetAllClients 获取所有客户端配置

func getAllClients() (clients []models.Client, err error) {
	db := dbcore.GetDBInstance()
	err = db.Find(&clients).Error
	if err != nil {
		return nil, err
	}
	return clients, nil
}

func GetClientTokenByUUID

func GetClientTokenByUUID(uuid string) (token string, err error)

func GetClientUUIDByToken

func GetClientUUIDByToken(token string) (clientUUID string, err error)

func HiddenClients added in v0.1.13

func HiddenClients() (map[string]bool, error)

HiddenClients returns the uuid/hidden map for every client. Successful client writes invalidate the cache immediately; only uuid/hidden are loaded, never tokens or hardware details.

The result is a copy the caller owns. It used to hand back the cached map itself, so the "immutable snapshot" in the old comment was a convention rather than a property: one caller deleting or assigning an entry silently changed what every later caller saw, until the next client write refreshed the cache.

func ReportVerify

func ReportVerify(report v2.Report) error

检查数据防止异常数据导致数据库损坏

func SaveClient

func SaveClient(updates map[string]interface{}) error

func SaveClientInfo

func SaveClientInfo(update map[string]interface{}) error

Types

type ClientInfoApplier added in v0.1.36

type ClientInfoApplier struct{}

ClientInfoApplier adapts SaveClient to internal/bulk's Applier.

It exists so bulk edits run through the *same* validation as a single-node edit rather than a second implementation of the rules, which is the whole reason `internal/bulk` takes an interface instead of a database handle. Two things about SaveClient make the adapter worth being explicit about rather than inlining a call:

  • It **writes into the map it is given** — `updated_at` is set on it, and `expired_at` is normalised in place. `bulk.Apply` hands each node its own copy for that reason, so one node's timestamp cannot land on the next node's request.
  • It returns the applier's own error text, which is what the per-node report shows. A generic "failed" would make the operator re-derive the reason by hand.

func (ClientInfoApplier) SaveClientInfo added in v0.1.36

func (ClientInfoApplier) SaveClientInfo(update map[string]interface{}) error

SaveClientInfo applies one partial update. Named for the operation, not the receiver, so it satisfies bulk.Applier without the caller importing this package's shape.

Jump to

Keyboard shortcuts

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