Expose config options for cleartext stratum port
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
import { storeJson } from './fileModels/store.json'
|
||||
import { i18n } from './i18n'
|
||||
import { sdk } from './sdk'
|
||||
import {
|
||||
defaultStratumPort,
|
||||
defaultStratumTlsPort,
|
||||
stratumHostId,
|
||||
stratumTlsHostId,
|
||||
uiHostId,
|
||||
uiPort,
|
||||
} from './utils'
|
||||
|
||||
export const setInterfaces = sdk.setupInterfaces(async ({ effects }) => {
|
||||
// Stratum ports are user config. Read reactively so changing them in the
|
||||
// Configure action re-runs this and rebinds the interfaces — the same
|
||||
// mechanism that adds/removes the TLS interface when TLS is toggled.
|
||||
const ports = await storeJson
|
||||
.read((s) => ({
|
||||
stratum: s.stratumPort,
|
||||
stratumTls: s.stratumTlsPort,
|
||||
tlsEnabled: s.tlsEnabled,
|
||||
}))
|
||||
.const(effects)
|
||||
|
||||
const stratumPort = ports?.stratum ?? defaultStratumPort
|
||||
const stratumTlsPort = ports?.stratumTls ?? defaultStratumTlsPort
|
||||
|
||||
// Web dashboard
|
||||
const uiMulti = sdk.MultiHost.of(effects, uiHostId)
|
||||
const uiMultiOrigin = await uiMulti.bindPort(uiPort, {
|
||||
protocol: 'http',
|
||||
})
|
||||
const ui = sdk.createInterface(effects, {
|
||||
name: i18n('Web Dashboard'),
|
||||
id: 'ui',
|
||||
description: i18n(
|
||||
'Real-time Kamado Pool dashboard (hashrate, miners, blocks, best shares)',
|
||||
),
|
||||
type: 'ui',
|
||||
masked: false,
|
||||
schemeOverride: null,
|
||||
username: null,
|
||||
path: '',
|
||||
query: {},
|
||||
})
|
||||
const uiReceipt = await uiMultiOrigin.export([ui])
|
||||
const receipts = [uiReceipt]
|
||||
|
||||
// Plaintext stratum — a raw TCP interface. Unlike StartOS 0.3.x, 0.4.0
|
||||
// forwards raw TCP on the LAN, so miners connect directly to the host at
|
||||
// the assigned external port; no router forward or simpleproxy needed.
|
||||
const stratumMulti = sdk.MultiHost.of(effects, stratumHostId)
|
||||
const stratumOrigin = await stratumMulti.bindPort(stratumPort, {
|
||||
protocol: null,
|
||||
preferredExternalPort: stratumPort,
|
||||
addSsl: null,
|
||||
secure: { ssl: false },
|
||||
})
|
||||
const stratum = sdk.createInterface(effects, {
|
||||
name: i18n('Stratum'),
|
||||
id: 'stratum',
|
||||
description: i18n(
|
||||
'Plaintext stratum endpoint. Point miners here with their Bitcoin payout address as the username',
|
||||
),
|
||||
type: 'api',
|
||||
masked: false,
|
||||
schemeOverride: { ssl: 'stratum+ssl', noSsl: 'stratum+tcp' },
|
||||
username: null,
|
||||
path: '',
|
||||
query: {},
|
||||
})
|
||||
receipts.push(await stratumOrigin.export([stratum]))
|
||||
|
||||
// TLS stratum (conditional) — stunnel terminates TLS with the persisted
|
||||
// package-managed certificate and forwards to ckpool's loopback-only
|
||||
// second bind. The OS sees a raw TCP port; TLS lives at the app layer, so
|
||||
// the noSsl scheme is deliberately stratum+ssl.
|
||||
if (ports?.tlsEnabled) {
|
||||
const tlsMulti = sdk.MultiHost.of(effects, stratumTlsHostId)
|
||||
const tlsOrigin = await tlsMulti.bindPort(stratumTlsPort, {
|
||||
protocol: null,
|
||||
preferredExternalPort: stratumTlsPort,
|
||||
addSsl: null,
|
||||
secure: { ssl: false },
|
||||
})
|
||||
const stratumTls = sdk.createInterface(effects, {
|
||||
name: i18n('Stratum (TLS)'),
|
||||
id: 'stratum-tls',
|
||||
description: i18n(
|
||||
'TLS-encrypted stratum endpoint (self-signed certificate — see the Stratum TLS Certificate action)',
|
||||
),
|
||||
type: 'api',
|
||||
masked: false,
|
||||
schemeOverride: { ssl: 'stratum+ssl', noSsl: 'stratum+ssl' },
|
||||
username: null,
|
||||
path: '',
|
||||
query: {},
|
||||
})
|
||||
receipts.push(await tlsOrigin.export([stratumTls]))
|
||||
}
|
||||
|
||||
return receipts
|
||||
})
|
||||
Reference in New Issue
Block a user