service

package
v0.0.0-...-e0a6c43 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 48 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func BootPay

func BootPay(st *store.Store, up *payx.Client, cfg *config.Config)

BootPay 启动时装配上游凭据(若有)并触发商品自检。

func DbExportHandler

func DbExportHandler(st *store.Store, cfg *config.Config) fun.RouteHandler

DbExportHandler POST /dbm/export 表单字段:id, db, sql, format(json|csv|xlsx)

func DbImportHandler

func DbImportHandler(st *store.Store, cfg *config.Config) fun.RouteHandler

DbImportHandler POST /dbm/import multipart:file + 字段 id/db/table; 按扩展名解析 json(对象数组) / csv / xlsx(首行为表头),列名与表列交集后批量插入

func DiskDownloadHandler

func DiskDownloadHandler(st *store.Store, cfg *config.Config) fun.RouteHandler

DiskDownloadHandler GET /disk/download?id=&token= 属主下载

func DiskUploadHandler

func DiskUploadHandler(st *store.Store, cfg *config.Config) fun.RouteHandler

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

func PayMapiHandler(st *store.Store, up *payx.Client) fun.RouteHandler

payMapiHandler GET/POST /mapi.php:验签建单,JSON 返回 payurl/qrcode。

func PaySubmitHandler

func PaySubmitHandler(st *store.Store, up *payx.Client) fun.RouteHandler

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

func SftpDownloadHandler(st *store.Store, cfg *config.Config) fun.RouteHandler

SftpDownloadHandler GET /files/download?id=&path=&token= 流式回传文件

func SftpUploadHandler

func SftpUploadHandler(st *store.Store, cfg *config.Config) fun.RouteHandler

SftpUploadHandler POST /files/upload?id=&dir=&token= multipart 字段 file

func ShareDownloadHandler

func ShareDownloadHandler(st *store.Store, cfg *config.Config) fun.RouteHandler

ShareDownloadHandler GET /d/* 公开分享下载:code 即 wildcard 路径,过期返回 410

func StartProxyScheduler

func StartProxyScheduler(ctx context.Context, st *store.Store)

StartProxyScheduler 调度器:启动补一次同步(数据为空时)→ 每小时测活 → 每日 00:00 同步。

func TerminalHandler

func TerminalHandler(st *store.Store, cfg *config.Config) fun.RouteHandler

TerminalHandler GET /ws/terminal?id=&token= 升级 WebSocket → SSH PTY。 协议:客户端→服务端首字节 0x01 为 JSON 控制帧 {"cols":N,"rows":N}(resize), 其余原样写入 shell stdin;服务端→客户端全部原样回显。

Types

type AuthGuard

type AuthGuard struct {
	Store *store.Store
}

AuthGuard 唯一 RPC 鉴权边界:token 由前端请求拦截器写入 ctx.State["token"], SQLite 会话表校验有效性,命中后用户经 SetUserValue 传给服务层

func (*AuthGuard) Guard

func (g *AuthGuard) Guard(ctx fun.Ctx) error

type AuthSvc

type AuthSvc struct {
	fun.Ctx
	Store *store.Store
}

func (*AuthSvc) ChangePassword

func (s *AuthSvc) ChangePassword(d dto.ChangePasswordDto) (dto.OkView, error)

ChangePassword 校验旧密码 → 改密 → 吊销其他会话(当前会话保留)

func (*AuthSvc) Login

func (s *AuthSvc) Login(d dto.LoginDto) (dto.SessionView, error)

Login 用户名+密码 → 签发会话 token(前端存 localStorage,随 state 透传)

func (*AuthSvc) Logout

func (s *AuthSvc) Logout() (dto.OkView, error)

Logout 幂等:删掉当前会话即可

func (*AuthSvc) Me

func (s *AuthSvc) Me() (dto.SessionView, error)

Me 返回当前登录用户(不重复签发 token)

type BookmarkSvc

type BookmarkSvc struct {
	fun.Ctx
	Store *store.Store
}

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

type DashboardSvc

type DashboardSvc struct {
	fun.Ctx
	Store *store.Store
}

func (*DashboardSvc) Stats

func (s *DashboardSvc) Stats() (dto.StatsView, error)

Stats 仪表盘聚合:会话概况 + 各业务模块计数 + 收入趋势 + 最近动态

type DbMgrSvc

type DbMgrSvc struct {
	fun.Ctx
	Store *store.Store
	Cfg   *config.Config `fun:"auto"`
}

DbMgrSvc 通用数据库管理器:连接密码 AES-GCM 落库,全部端点仅管理员; 查询固定 20s 超时 + 行数封顶,防止一条烂 SQL 拖死进程

func (*DbMgrSvc) Databases

func (s *DbMgrSvc) Databases(d dto.DbScopeDto) (dto.DbDatabasesView, error)

func (*DbMgrSvc) Delete

func (s *DbMgrSvc) Delete(d dto.DbconnIdDto) (dto.OkView, error)

func (*DbMgrSvc) List

func (s *DbMgrSvc) List() ([]dto.DbconnView, 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)

func (*DbMgrSvc) Test

func (s *DbMgrSvc) Test(d dto.DbconnIdDto) (dto.OkView, error)

Test 连通性测试

type DiskSvc

type DiskSvc struct {
	fun.Ctx
	Store *store.Store
	Cfg   *config.Config
}

DiskSvc 网盘:文件列表/删除/分享链接管理(按用户隔离,属主校验)

func (*DiskSvc) CreateShare

func (s *DiskSvc) CreateShare(d dto.CreateShareDto) (dto.ShareView, error)

CreateShare ExpireMinutes=0 永久;>0 限时分享

func (*DiskSvc) DeleteFile

func (s *DiskSvc) DeleteFile(d dto.IdDto) (dto.OkView, error)

DeleteFile 删文件:库记录 + 磁盘文件 + 关联分享一起清

func (*DiskSvc) DeleteShare

func (s *DiskSvc) DeleteShare(d dto.IdDto) (dto.OkView, error)

func (*DiskSvc) List

func (s *DiskSvc) List() ([]dto.FileView, error)

func (*DiskSvc) ListShares

func (s *DiskSvc) ListShares() ([]dto.ShareView, error)

type LicenseSvc

type LicenseSvc struct {
	fun.Ctx
	Store *store.Store
}

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 (*LicenseSvc) SaveApp

SaveApp id=0 新建(自动生成 appid+secret);否则改名/开关/重置 secret。

func (*LicenseSvc) Stats

type MemorySvc

type MemorySvc struct {
	fun.Ctx
	Store *store.Store
}

MemorySvc 记忆库管理(仅管理员)。

func (*MemorySvc) Delete

func (s *MemorySvc) Delete(d dto.MemoryKeyDto) (dto.OkView, error)

func (*MemorySvc) Get

func (*MemorySvc) List

List query 非空走全文 AND 搜索;否则按 project/tag 过滤列元数据

func (*MemorySvc) McpInfo

func (s *MemorySvc) McpInfo() (dto.MemoryMcpView, error)

McpInfo 返回对外 MCP 端点与 Bearer 令牌(缺省懒生成一个)

func (*MemorySvc) Projects

func (s *MemorySvc) Projects() (dto.MemoryProjectsView, error)

func (*MemorySvc) ResetToken

func (s *MemorySvc) ResetToken() (dto.MemoryMcpView, error)

func (*MemorySvc) Save

type PayNotifier

type PayNotifier struct {
	Store *store.Store `fun:"auto"`
}

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 一扫)。

func (*PayPoller) New

func (p *PayPoller) New()

type PaySvc

type PaySvc struct {
	fun.Ctx
	Store *store.Store
	Up    *payx.Client
	Cfg   *config.Config
}

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

List 订单分页。

func (*PaySvc) SaveUpstream

func (s *PaySvc) SaveUpstream(d dto.PayUpstreamDto) (dto.PayUpstreamStatusView, error)

SaveUpstream 保存上游账号并登录验证;成功后异步触发分类/商品自检与库存补齐。

func (*PaySvc) Stats

func (s *PaySvc) Stats() (dto.PayStatsView, error)

Stats 今日与累计统计。

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

Watch 收银台状态流:服务端推送订单状态变化,终态(已支付/已关闭)自动关闭。

type ProxySvc

type ProxySvc struct {
	fun.Ctx
	Store *store.Store
}

ProxySvc 代理池:地区分组浏览 + 同步记录;抓取/测活由后台调度器跑

func (*ProxySvc) CheckNow

func (s *ProxySvc) CheckNow() (dto.OkView, error)

CheckNow 手动触发一轮测活(后台执行)

func (*ProxySvc) CreateKey

func (s *ProxySvc) CreateKey(d dto.ProxyKeySaveDto) (dto.ProxyKeyView, error)

CreateKey 生成一个提取密钥:绑定地区(0=全部),key 随机生成落库

func (*ProxySvc) DeleteKey

func (s *ProxySvc) DeleteKey(d dto.IdDto) (dto.OkView, error)

func (*ProxySvc) List

func (*ProxySvc) ListKeys

func (s *ProxySvc) ListKeys() ([]dto.ProxyKeyView, error)

func (*ProxySvc) Regions

func (s *ProxySvc) Regions() ([]dto.ProxyRegionView, error)

func (*ProxySvc) Stats

func (s *ProxySvc) Stats() (dto.ProxyStatsView, error)

func (*ProxySvc) SyncNow

func (s *ProxySvc) SyncNow() (dto.OkView, error)

SyncNow 手动触发一次同步(后台执行,不等结果)

func (*ProxySvc) Syncs

func (s *ProxySvc) Syncs() ([]dto.ProxySyncView, error)

type ServerSvc

type ServerSvc struct {
	fun.Ctx
	Store *store.Store
	Cfg   *config.Config `fun:"auto"`
}

ServerSvc 服务器管理:连接密钥加密落库,所有 SSH/SFTP 端点仅管理员。 指标采集与文件操作每次新拨号——管理场景连接低频,免去连接池维护成本。

func (*ServerSvc) Delete

func (s *ServerSvc) Delete(d dto.ServerIdDto) (dto.OkView, error)

func (*ServerSvc) List

func (s *ServerSvc) List() ([]dto.ServerView, error)

func (*ServerSvc) Metrics

Metrics SSH 拨号 + 采集;拨不通直接返回带因的错误,前端即「离线」

func (*ServerSvc) Save

func (*ServerSvc) SftpList

func (s *ServerSvc) SftpList(d dto.SftpPathDto) (dto.SftpListView, error)

func (*ServerSvc) SftpMkdir

func (s *ServerSvc) SftpMkdir(d dto.SftpPathDto) (dto.OkView, error)

func (*ServerSvc) SftpRemove

func (s *ServerSvc) SftpRemove(d dto.SftpPathDto) (dto.OkView, error)

SftpRemove 删文件或空目录;非空目录拒绝递归删除,避免误删整棵目录树

func (*ServerSvc) SftpRename

func (s *ServerSvc) SftpRename(d dto.SftpRenameDto) (dto.OkView, error)

type SettingSvc

type SettingSvc struct {
	fun.Ctx
	Store *store.Store
}

SettingSvc 站点级 KV 设置:读取对所有登录用户开放,写入仅管理员

func (*SettingSvc) Get

func (*SettingSvc) Set

func (s *SettingSvc) Set(d dto.SettingDto) (dto.OkView, error)

type ToolSvc

type ToolSvc struct {
	fun.Ctx
	Store *store.Store
}

ToolSvc 工具箱注册表:List 登录用户可见(驱动侧边导航),管理端点为 admin

func (*ToolSvc) AdminList

func (s *ToolSvc) AdminList() ([]dto.ToolView, error)

func (*ToolSvc) DeleteTool

func (s *ToolSvc) DeleteTool(d dto.DeleteToolDto) (dto.OkView, error)

func (*ToolSvc) List

func (s *ToolSvc) List() ([]dto.ToolView, error)

func (*ToolSvc) SaveTool

func (s *ToolSvc) SaveTool(d dto.SaveToolDto) (dto.ToolView, error)

type UserSvc

type UserSvc struct {
	fun.Ctx
	Store *store.Store
}

UserSvc 用户管理:全部 policyAdmin, Guard 已保证仅管理员可达

func (*UserSvc) DeleteUser

func (s *UserSvc) DeleteUser(d dto.DeleteUserDto) (dto.OkView, error)

func (*UserSvc) ListUsers

func (s *UserSvc) ListUsers(d dto.ListUsersDto) (dto.UserPageView, error)

func (*UserSvc) SaveUser

func (s *UserSvc) SaveUser(d dto.SaveUserDto) (dto.UserView, error)

SaveUser Id 为空创建(密码必填),非空更新(密码留空不变)

type VaultSvc

type VaultSvc struct {
	fun.Ctx
	Store *store.Store
	Cfg   *config.Config `fun:"auto"`
}

VaultSvc 密码箱:密文只在服务端出现;列表只回元数据, 密码经 Reveal 显式取回,2FA 只回当前验证码不回密钥。

func (*VaultSvc) Delete

func (s *VaultSvc) Delete(d dto.VaultIdDto) (dto.OkView, error)

func (*VaultSvc) List

func (s *VaultSvc) List() ([]dto.VaultItemView, error)

func (*VaultSvc) Reveal

func (s *VaultSvc) Reveal(d dto.VaultIdDto) (dto.SecretView, error)

Reveal 显式取回明文密码(前端点「查看」才调用,列表永不携带)

func (*VaultSvc) Save

func (*VaultSvc) Totp

func (s *VaultSvc) Totp(d dto.VaultIdDto) (dto.TotpView, error)

Totp 返回当前 6 位验证码与剩余秒数;密钥不出服务端

type WebSvc

type WebSvc struct {
	fun.Ctx
}

WebSvc HTTP 请求代理(Postman 工具):服务端代发以绕开浏览器 CORS。 只放行 http/https;headersJson 为 {"k":"v"} 对象。

func (*WebSvc) Fetch

func (s *WebSvc) Fetch(d dto.WebFetchDto) (dto.WebFetchView, error)

Jump to

Keyboard shortcuts

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