Documentation
¶
Overview ¶
cashier_page.go submit.php 直出的自包含收银台页(不 302、不依赖前端 SPA), 二维码由服务端生成 PNG data URL;状态经 /cashier-status 轮询。
license.go 授权系统管理:项目(appid/secret)+ 激活卡密(绑域名、按时长计时)。 对外校验走 /v1/license,仅供其他项目客户端调用。
license_routes.go 卡密公开校验端点:GET/POST /v1/license?appid=xx&card=xx&domain=xx 首次调用激活并绑定域名(开始计时),之后仅限同域名校验;供其他项目做网络验证。
memory.go 共享记忆库管理(仅管理员):项目分组、搜索、读写删除、MCP 接入信息。 对外协议端点见 memory_routes.go(POST /mcp + GET /m/<key>)。
memory_routes.go 记忆库对外协议端点:
POST /mcp Streamable HTTP MCP(Bearer 令牌鉴权,令牌见 MemorySvc.McpInfo) GET /m 阅读链接索引(Bearer 鉴权——key 可枚举,不能裸奔) GET /m/* 记忆阅读链接(?sig= 签名鉴权,HMAC(key, 令牌) 签发,令牌重置即吊销)
pay.go 支付核心:上游 catfk 账号托管、分类/商品自检、卡密库存保障(全程带锁)、 订单 RPC、支付轮询与商户异步通知。易支付协议端点在 pay_routes.go。
pay_routes.go 易支付兼容协议端点:/submit.php(验签建单+直出收银台页)、/mapi.php(JSON下单)、/api.php(查单)。
Index ¶
- func BootPay(st *store.Store, up *payx.Client, cfg *config.Config)
- func DbExportHandler(st *store.Store, cfg *config.Config) fun.RouteHandler
- func DbImportHandler(st *store.Store, cfg *config.Config) fun.RouteHandler
- func DiskDownloadHandler(st *store.Store, cfg *config.Config) fun.RouteHandler
- func DiskUploadHandler(st *store.Store, cfg *config.Config) fun.RouteHandler
- func LicenseVerifyHandler(st *store.Store) fun.RouteHandler
- func McpHandler(st *store.Store) fun.RouteHandler
- func MemoryReadHandler(st *store.Store) fun.RouteHandler
- func PayApiHandler(st *store.Store) fun.RouteHandler
- func PayCashierPageHandler(st *store.Store) fun.RouteHandler
- func PayCashierStatusHandler(st *store.Store) fun.RouteHandler
- func PayMapiHandler(st *store.Store, up *payx.Client) fun.RouteHandler
- func PaySubmitHandler(st *store.Store, up *payx.Client) fun.RouteHandler
- func ProxyExtractHandler(st *store.Store) fun.RouteHandler
- func SftpDownloadHandler(st *store.Store, cfg *config.Config) fun.RouteHandler
- func SftpUploadHandler(st *store.Store, cfg *config.Config) fun.RouteHandler
- func ShareDownloadHandler(st *store.Store, cfg *config.Config) fun.RouteHandler
- func StartProxyScheduler(ctx context.Context, st *store.Store)
- func TerminalHandler(st *store.Store, cfg *config.Config) fun.RouteHandler
- type AuthGuard
- type AuthSvc
- type BookmarkSvc
- type DashboardSvc
- type DbMgrSvc
- func (s *DbMgrSvc) Databases(d dto.DbScopeDto) (dto.DbDatabasesView, error)
- func (s *DbMgrSvc) Delete(d dto.DbconnIdDto) (dto.OkView, error)
- func (s *DbMgrSvc) List() ([]dto.DbconnView, error)
- func (s *DbMgrSvc) Query(d dto.DbQueryDto) (dto.DbQueryView, error)
- func (s *DbMgrSvc) Save(d dto.SaveDbconnDto) (dto.DbconnView, error)
- func (s *DbMgrSvc) Tables(d dto.DbScopeDto) (dto.DbTablesView, error)
- func (s *DbMgrSvc) Test(d dto.DbconnIdDto) (dto.OkView, error)
- type DiskSvc
- func (s *DiskSvc) CreateShare(d dto.CreateShareDto) (dto.ShareView, error)
- func (s *DiskSvc) DeleteFile(d dto.IdDto) (dto.OkView, error)
- func (s *DiskSvc) DeleteShare(d dto.IdDto) (dto.OkView, error)
- func (s *DiskSvc) List() ([]dto.FileView, error)
- func (s *DiskSvc) ListShares() ([]dto.ShareView, error)
- type LicenseSvc
- func (s *LicenseSvc) Apps() (dto.LicenseAppsView, error)
- func (s *LicenseSvc) Delete(d dto.LicenseIdDto) (dto.OkView, error)
- func (s *LicenseSvc) DeleteApp(d dto.LicenseIdDto) (dto.OkView, error)
- func (s *LicenseSvc) Generate(d dto.LicenseGenDto) (dto.LicenseGenView, error)
- func (s *LicenseSvc) List(d dto.LicenseListDto) (dto.LicensePageView, error)
- func (s *LicenseSvc) SaveApp(d dto.LicenseAppSaveDto) (dto.LicenseAppView, error)
- func (s *LicenseSvc) Stats(d dto.LicenseStatsDto) (dto.LicenseStatsView, error)
- type MemorySvc
- func (s *MemorySvc) Delete(d dto.MemoryKeyDto) (dto.OkView, error)
- func (s *MemorySvc) Get(d dto.MemoryKeyDto) (dto.MemoryView, error)
- func (s *MemorySvc) List(d dto.MemoryListDto) (dto.MemoryListView, error)
- func (s *MemorySvc) McpInfo() (dto.MemoryMcpView, error)
- func (s *MemorySvc) Projects() (dto.MemoryProjectsView, error)
- func (s *MemorySvc) ResetToken() (dto.MemoryMcpView, error)
- func (s *MemorySvc) Save(d dto.MemorySaveDto) (dto.MemorySaveView, error)
- type PayNotifier
- type PayPoller
- type PaySvc
- func (s *PaySvc) CashierInfo(d dto.PayCashierDto) (dto.PayCashierView, error)
- func (s *PaySvc) CashierStatus(d dto.PayCashierDto) (dto.PayCashierStatusView, error)
- func (s *PaySvc) List(d dto.PayOrderListDto) (dto.PayOrderPageView, error)
- func (s *PaySvc) SaveUpstream(d dto.PayUpstreamDto) (dto.PayUpstreamStatusView, error)
- func (s *PaySvc) Stats() (dto.PayStatsView, error)
- func (s *PaySvc) TestPay(d dto.PayTestPayDto) (dto.PayTestPayView, error)
- func (s *PaySvc) UpstreamStatus() (dto.PayUpstreamStatusView, error)
- func (s *PaySvc) Watch(d dto.PayCashierDto) (*fun.Stream[dto.PayCashierStatusView], error)
- type ProxySvc
- func (s *ProxySvc) CheckNow() (dto.OkView, error)
- func (s *ProxySvc) CreateKey(d dto.ProxyKeySaveDto) (dto.ProxyKeyView, error)
- func (s *ProxySvc) DeleteKey(d dto.IdDto) (dto.OkView, error)
- func (s *ProxySvc) List(d dto.ProxyListDto) (dto.ProxyListView, error)
- func (s *ProxySvc) ListKeys() ([]dto.ProxyKeyView, error)
- func (s *ProxySvc) Regions() ([]dto.ProxyRegionView, error)
- func (s *ProxySvc) Stats() (dto.ProxyStatsView, error)
- func (s *ProxySvc) SyncNow() (dto.OkView, error)
- func (s *ProxySvc) Syncs() ([]dto.ProxySyncView, error)
- type ServerSvc
- func (s *ServerSvc) Delete(d dto.ServerIdDto) (dto.OkView, error)
- func (s *ServerSvc) List() ([]dto.ServerView, error)
- func (s *ServerSvc) Metrics(d dto.ServerIdDto) (dto.ServerMetricsView, error)
- func (s *ServerSvc) Save(d dto.SaveServerDto) (dto.ServerView, error)
- func (s *ServerSvc) SftpList(d dto.SftpPathDto) (dto.SftpListView, error)
- func (s *ServerSvc) SftpMkdir(d dto.SftpPathDto) (dto.OkView, error)
- func (s *ServerSvc) SftpRemove(d dto.SftpPathDto) (dto.OkView, error)
- func (s *ServerSvc) SftpRename(d dto.SftpRenameDto) (dto.OkView, error)
- type SettingSvc
- type ToolSvc
- type UserSvc
- type VaultSvc
- func (s *VaultSvc) Delete(d dto.VaultIdDto) (dto.OkView, error)
- func (s *VaultSvc) List() ([]dto.VaultItemView, error)
- func (s *VaultSvc) Reveal(d dto.VaultIdDto) (dto.SecretView, error)
- func (s *VaultSvc) Save(d dto.SaveVaultDto) (dto.VaultItemView, error)
- func (s *VaultSvc) Totp(d dto.VaultIdDto) (dto.TotpView, error)
- type WebSvc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DbExportHandler ¶
DbExportHandler POST /dbm/export 表单字段:id, db, sql, format(json|csv|xlsx)
func DbImportHandler ¶
DbImportHandler POST /dbm/import multipart:file + 字段 id/db/table; 按扩展名解析 json(对象数组) / csv / xlsx(首行为表头),列名与表列交集后批量插入
func DiskDownloadHandler ¶
DiskDownloadHandler GET /disk/download?id=&token= 属主下载
func DiskUploadHandler ¶
DiskUploadHandler POST /disk/upload?token= multipart 字段 file
func LicenseVerifyHandler ¶
func LicenseVerifyHandler(st *store.Store) fun.RouteHandler
func McpHandler ¶
func McpHandler(st *store.Store) fun.RouteHandler
McpHandler POST /mcp:Authorization Bearer 校验后交给 Streamable HTTP 服务。 令牌存 settings(mcp.token),首次访问懒生成。
func MemoryReadHandler ¶
func MemoryReadHandler(st *store.Store) fun.RouteHandler
MemoryReadHandler GET /m/*:输出 markdown 原文;裸 /m/ 列出全部阅读链接。
func PayApiHandler ¶
func PayApiHandler(st *store.Store) fun.RouteHandler
PayApiHandler GET/POST /api.php:act=order 查单(pid+key 验签)。
func PayCashierPageHandler ¶
func PayCashierPageHandler(st *store.Store) fun.RouteHandler
PayCashierPageHandler GET /cashier.php?trade_no=:收银台页渲染 (submit.php 302 落点,trade_no 不可枚举即凭证;重复访问按订单当前状态渲染)。
func PayCashierStatusHandler ¶
func PayCashierStatusHandler(st *store.Store) fun.RouteHandler
PayCashierStatusHandler GET /cashier-status?trade_no=:收银台页轮询 (公开接口,trade_no 不可枚举即凭证;前端经 /api 前缀代理访问)。
func PayMapiHandler ¶
payMapiHandler GET/POST /mapi.php:验签建单,JSON 返回 payurl/qrcode。
func PaySubmitHandler ¶
paySubmitHandler GET/POST /submit.php:验签建单后 302 到收银台页(PRG,刷新安全)。
func ProxyExtractHandler ¶
func ProxyExtractHandler(st *store.Store) fun.RouteHandler
ProxyExtractHandler GET /v1/proxy?key=xxx[&fmt=url][&host=example.com] 公开提取接口:key 落库校验,地区绑在 key 上(0=全部)。 并行探测一批候选,谁先探活返回谁;返回带握手实测协议的 "scheme://ip:port"(socks5h/http/socks4)。 两批全死返回 503。host 可选:探测目标改为主机名(CONNECT+TLS 验证到该站, 默认 gstatic)——消费方传真实目标,拿到的才是"对这个站可用"的代理。
func SftpDownloadHandler ¶
SftpDownloadHandler GET /files/download?id=&path=&token= 流式回传文件
func SftpUploadHandler ¶
SftpUploadHandler POST /files/upload?id=&dir=&token= multipart 字段 file
func ShareDownloadHandler ¶
ShareDownloadHandler GET /d/* 公开分享下载:code 即 wildcard 路径,过期返回 410
func StartProxyScheduler ¶
StartProxyScheduler 调度器:启动补一次同步(数据为空时)→ 每小时测活 → 每日 00:00 同步。
func TerminalHandler ¶
TerminalHandler GET /ws/terminal?id=&token= 升级 WebSocket → SSH PTY。 协议:客户端→服务端首字节 0x01 为 JSON 控制帧 {"cols":N,"rows":N}(resize), 其余原样写入 shell stdin;服务端→客户端全部原样回显。
Types ¶
type AuthGuard ¶
AuthGuard 唯一 RPC 鉴权边界:token 由前端请求拦截器写入 ctx.State["token"], SQLite 会话表校验有效性,命中后用户经 SetUserValue 传给服务层
type AuthSvc ¶
func (*AuthSvc) ChangePassword ¶
ChangePassword 校验旧密码 → 改密 → 吊销其他会话(当前会话保留)
type BookmarkSvc ¶
BookmarkSvc 个人书签:列表驱动侧边栏快捷入口与书签页
func (*BookmarkSvc) Delete ¶
func (s *BookmarkSvc) Delete(d dto.BookmarkIdDto) (dto.OkView, error)
func (*BookmarkSvc) List ¶
func (s *BookmarkSvc) List() ([]dto.BookmarkView, error)
func (*BookmarkSvc) Save ¶
func (s *BookmarkSvc) Save(d dto.SaveBookmarkDto) (dto.BookmarkView, error)
type DashboardSvc ¶
type DbMgrSvc ¶
DbMgrSvc 通用数据库管理器:连接密码 AES-GCM 落库,全部端点仅管理员; 查询固定 20s 超时 + 行数封顶,防止一条烂 SQL 拖死进程
func (*DbMgrSvc) Databases ¶
func (s *DbMgrSvc) Databases(d dto.DbScopeDto) (dto.DbDatabasesView, error)
func (*DbMgrSvc) Query ¶
func (s *DbMgrSvc) Query(d dto.DbQueryDto) (dto.DbQueryView, error)
Query 执行单条 SQL:SELECT 回结果集(JSON 行串),其余回 affected rows
func (*DbMgrSvc) Save ¶
func (s *DbMgrSvc) Save(d dto.SaveDbconnDto) (dto.DbconnView, error)
func (*DbMgrSvc) Tables ¶
func (s *DbMgrSvc) Tables(d dto.DbScopeDto) (dto.DbTablesView, error)
type DiskSvc ¶
DiskSvc 网盘:文件列表/删除/分享链接管理(按用户隔离,属主校验)
func (*DiskSvc) CreateShare ¶
CreateShare ExpireMinutes=0 永久;>0 限时分享
func (*DiskSvc) DeleteFile ¶
DeleteFile 删文件:库记录 + 磁盘文件 + 关联分享一起清
type LicenseSvc ¶
LicenseSvc 授权管理(仅管理员)。
func (*LicenseSvc) Apps ¶
func (s *LicenseSvc) Apps() (dto.LicenseAppsView, error)
func (*LicenseSvc) Delete ¶
func (s *LicenseSvc) Delete(d dto.LicenseIdDto) (dto.OkView, error)
func (*LicenseSvc) DeleteApp ¶
func (s *LicenseSvc) DeleteApp(d dto.LicenseIdDto) (dto.OkView, error)
func (*LicenseSvc) Generate ¶
func (s *LicenseSvc) Generate(d dto.LicenseGenDto) (dto.LicenseGenView, error)
Generate 批量生成卡密:大写分组格式(XXXX-XXXX-XXXX-XXXX),一次最多 500。
func (*LicenseSvc) List ¶
func (s *LicenseSvc) List(d dto.LicenseListDto) (dto.LicensePageView, error)
func (*LicenseSvc) SaveApp ¶
func (s *LicenseSvc) SaveApp(d dto.LicenseAppSaveDto) (dto.LicenseAppView, error)
SaveApp id=0 新建(自动生成 appid+secret);否则改名/开关/重置 secret。
func (*LicenseSvc) Stats ¶
func (s *LicenseSvc) Stats(d dto.LicenseStatsDto) (dto.LicenseStatsView, error)
type MemorySvc ¶
MemorySvc 记忆库管理(仅管理员)。
func (*MemorySvc) Get ¶
func (s *MemorySvc) Get(d dto.MemoryKeyDto) (dto.MemoryView, error)
func (*MemorySvc) List ¶
func (s *MemorySvc) List(d dto.MemoryListDto) (dto.MemoryListView, error)
List query 非空走全文 AND 搜索;否则按 project/tag 过滤列元数据
func (*MemorySvc) McpInfo ¶
func (s *MemorySvc) McpInfo() (dto.MemoryMcpView, error)
McpInfo 返回对外 MCP 端点与 Bearer 令牌(缺省懒生成一个)
func (*MemorySvc) ResetToken ¶
func (s *MemorySvc) ResetToken() (dto.MemoryMcpView, error)
func (*MemorySvc) Save ¶
func (s *MemorySvc) Save(d dto.MemorySaveDto) (dto.MemorySaveView, error)
type PayNotifier ¶
PayNotifier 商户异步通知器(fun.Wired 单例)。
func (*PayNotifier) OnPaid ¶
func (n *PayNotifier) OnPaid(tradeNo string)
OnPaid 异步投递商户 notify_url(退避:立即/15s/1m/5m/15m)。
type PayPoller ¶
type PayPoller struct {
Store *store.Store `fun:"auto"`
Up *payx.Client `fun:"auto"`
Notify *PayNotifier `fun:"auto"`
}
PayPoller 待支付订单轮询器(fun.Wired 单例,5s 一扫)。
type PaySvc ¶
func (*PaySvc) CashierInfo ¶
func (s *PaySvc) CashierInfo(d dto.PayCashierDto) (dto.PayCashierView, error)
CashierInfo 收银台公开信息(trade_no 不可枚举即凭证)。
func (*PaySvc) CashierStatus ¶
func (s *PaySvc) CashierStatus(d dto.PayCashierDto) (dto.PayCashierStatusView, error)
CashierStatus 收银台轮询:已支付且配置了 return_url 时返回签名回跳地址。
func (*PaySvc) List ¶
func (s *PaySvc) List(d dto.PayOrderListDto) (dto.PayOrderPageView, error)
List 订单分页。
func (*PaySvc) SaveUpstream ¶
func (s *PaySvc) SaveUpstream(d dto.PayUpstreamDto) (dto.PayUpstreamStatusView, error)
SaveUpstream 保存上游账号并登录验证;成功后异步触发分类/商品自检与库存补齐。
func (*PaySvc) TestPay ¶
func (s *PaySvc) TestPay(d dto.PayTestPayDto) (dto.PayTestPayView, error)
TestPay 创建一笔真实订单走完整上游流程(收银台二维码 + 轮询结算)。
func (*PaySvc) UpstreamStatus ¶
func (s *PaySvc) UpstreamStatus() (dto.PayUpstreamStatusView, error)
UpstreamStatus 上游账号与商品状态(管理页展示)。
func (*PaySvc) Watch ¶
func (s *PaySvc) Watch(d dto.PayCashierDto) (*fun.Stream[dto.PayCashierStatusView], error)
Watch 收银台状态流:服务端推送订单状态变化,终态(已支付/已关闭)自动关闭。
type ProxySvc ¶
ProxySvc 代理池:地区分组浏览 + 同步记录;抓取/测活由后台调度器跑
func (*ProxySvc) CreateKey ¶
func (s *ProxySvc) CreateKey(d dto.ProxyKeySaveDto) (dto.ProxyKeyView, error)
CreateKey 生成一个提取密钥:绑定地区(0=全部),key 随机生成落库
func (*ProxySvc) List ¶
func (s *ProxySvc) List(d dto.ProxyListDto) (dto.ProxyListView, error)
type ServerSvc ¶
ServerSvc 服务器管理:连接密钥加密落库,所有 SSH/SFTP 端点仅管理员。 指标采集与文件操作每次新拨号——管理场景连接低频,免去连接池维护成本。
func (*ServerSvc) Metrics ¶
func (s *ServerSvc) Metrics(d dto.ServerIdDto) (dto.ServerMetricsView, error)
Metrics SSH 拨号 + 采集;拨不通直接返回带因的错误,前端即「离线」
func (*ServerSvc) Save ¶
func (s *ServerSvc) Save(d dto.SaveServerDto) (dto.ServerView, error)
func (*ServerSvc) SftpList ¶
func (s *ServerSvc) SftpList(d dto.SftpPathDto) (dto.SftpListView, error)
func (*ServerSvc) SftpRemove ¶
SftpRemove 删文件或空目录;非空目录拒绝递归删除,避免误删整棵目录树
func (*ServerSvc) SftpRename ¶
type SettingSvc ¶
SettingSvc 站点级 KV 设置:读取对所有登录用户开放,写入仅管理员
func (*SettingSvc) Get ¶
func (s *SettingSvc) Get(d dto.SettingDto) (dto.SettingView, error)
func (*SettingSvc) Set ¶
func (s *SettingSvc) Set(d dto.SettingDto) (dto.OkView, error)
type UserSvc ¶
UserSvc 用户管理:全部 policyAdmin, Guard 已保证仅管理员可达
func (*UserSvc) DeleteUser ¶
func (*UserSvc) ListUsers ¶
func (s *UserSvc) ListUsers(d dto.ListUsersDto) (dto.UserPageView, error)
type VaultSvc ¶
VaultSvc 密码箱:密文只在服务端出现;列表只回元数据, 密码经 Reveal 显式取回,2FA 只回当前验证码不回密钥。
func (*VaultSvc) Reveal ¶
func (s *VaultSvc) Reveal(d dto.VaultIdDto) (dto.SecretView, error)
Reveal 显式取回明文密码(前端点「查看」才调用,列表永不携带)
func (*VaultSvc) Save ¶
func (s *VaultSvc) Save(d dto.SaveVaultDto) (dto.VaultItemView, error)