Tighten OSS detection, refresh TLS badge, plumb custom mempool URL

isOpenSource was matching things like Braiins OS, cgminer, bfgminer,
and a generic "esp32" — software that's open but runs on closed
hardware (Antminer, unknown rigs). public-pool's UI reserves the
star for open-source HARDWARE, with open firmware on top, and that's
the convention to match. New regex covers the family verbatim from
public-pool-ui's user-agent-link switch table:

  bitaxe, bitaxeHex, NerdMiner, NerdNOS, NerdAxe, NerdAxeGamma,
  NerdOCTAXE, NerdEKO, NerdQAxe+, NerdQAxe++, PiAxe, QAxe, QAxe+,
  0xAxe, LeafMiner

Also extend detectHardware so all those user-agents get a recognised
label instead of "esp32" / raw token.

Replace the squished "TLS" pill with an inline-flex badge: 0.78em
text, 5px corners, padlock SVG, generous left/right padding so it
reads at a glance instead of looking like a typo.

Custom block explorer: new optional union under StartOS Advanced
config ("Block Explorer" — defaults to "mempool.space"). Picking
"Custom URL" surfaces the value as MEMPOOL_BASE_URL on the
container env. config.Config picks it up, the aggregator copies
it into every Snapshot (mempool_base_url field), and the UI's
shared explorerBaseFor() helper trusts the custom URL verbatim
when present (no /testnet4 / /signet path appended — a self-hosted
instance is presumably single-network already). Falls back to the
public mempool.space mirrors per chain when unset, which is the
default behaviour.
This commit is contained in:
satoshi
2026-04-26 23:10:36 +03:00
parent 2f4ed4aa88
commit 81227cb90f
8 changed files with 112 additions and 43 deletions
+1
View File
@@ -60,6 +60,7 @@ func main() {
agg := state.New(ck, rpc, cfg.PollInterval, log)
agg.Store = blockStore
agg.MempoolBaseURL = cfg.MempoolBaseURL
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer stop()
+6
View File
@@ -34,6 +34,11 @@ type Config struct {
// Poll interval for refreshing ckpool stats
PollInterval time.Duration
// Optional mempool.space-compatible explorer base URL. Empty means
// the UI uses the public mempool.space; non-empty means the user
// has pointed Kamado at their own instance via the StartOS config.
MempoolBaseURL string
}
func FromEnv() (*Config, error) {
@@ -48,6 +53,7 @@ func FromEnv() (*Config, error) {
CKPoolLogFile: getenv("CKPOOL_LOGFILE", "/var/log/ckpool/ckpool.log"),
DBPath: getenv("DB_PATH", "/var/lib/kamado/kamado.db"),
PollInterval: getenvDuration("POLL_INTERVAL", 5*time.Second),
MempoolBaseURL: os.Getenv("MEMPOOL_BASE_URL"),
}
if cfg.BitcoinRPCURL == "" {
+10 -1
View File
@@ -68,6 +68,11 @@ type Snapshot struct {
// 24-hour hashrate history, sampled once per minute (max 1440 points).
HashrateHistory []HashratePoint `json:"hashrate_history,omitempty"`
// Optional override for explorer links in the UI. Empty means use
// mempool.space defaults. Set via MEMPOOL_BASE_URL env, surfaced by
// the StartOS config "Block Explorer" -> "Custom URL".
MempoolBaseURL string `json:"mempool_base_url,omitempty"`
// Health
CKPoolOK bool `json:"ckpool_ok"`
BitcoinOK bool `json:"bitcoin_ok"`
@@ -93,6 +98,10 @@ type Aggregator struct {
Interval time.Duration
Log *slog.Logger
// Static config that the UI consumes via the snapshot. Empty
// MempoolBaseURL leaves the UI on its mempool.space defaults.
MempoolBaseURL string
// OnRefresh, if set, is called (non-blocking) after each snapshot
// refresh. Used by the WebSocket hub to push updates to clients.
OnRefresh func(Snapshot)
@@ -187,7 +196,7 @@ func (a *Aggregator) refresh(ctx context.Context) {
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
next := Snapshot{GeneratedAt: time.Now()}
next := Snapshot{GeneratedAt: time.Now(), MempoolBaseURL: a.MempoolBaseURL}
// --- ckpool: poolstats, users, workers, clients, uptime ---
if ps, err := a.CK.PoolStats(ctx); err == nil {