Dont duplicate interfaces on port change 3.0
This commit is contained in:
+33
-14
@@ -18,7 +18,9 @@ import {
|
||||
kamadoRoot,
|
||||
parseCookie,
|
||||
tlsDir,
|
||||
tlsInternalPort,
|
||||
ckpoolTlsLoopbackPort,
|
||||
stratumInternalPort,
|
||||
stratumTlsInternalPort,
|
||||
uiPort,
|
||||
} from './utils'
|
||||
|
||||
@@ -30,9 +32,25 @@ export const main = sdk.setupMain(async ({ effects }) => {
|
||||
*/
|
||||
console.info('Starting Kamado Pool!')
|
||||
|
||||
// Service settings; reactive, so any config-action change restarts the
|
||||
// daemons with a freshly rendered ckpool.conf.
|
||||
const store = await storeJson.read().const(effects)
|
||||
// Service settings; reactive, so a config-action change restarts the daemons
|
||||
// with a freshly rendered ckpool.conf. Deliberately a projection rather than
|
||||
// the whole file: stratumPort / stratumTlsPort are EXTERNAL ports owned by
|
||||
// interfaces.ts, and the in-container binds are fixed constants. Excluding
|
||||
// them here means changing a port is a pure rebind that leaves the pool
|
||||
// running instead of kicking every connected miner.
|
||||
const store = await storeJson
|
||||
.read((s) => ({
|
||||
coinbaseTag: s.coinbaseTag,
|
||||
startDiff: s.startDiff,
|
||||
minDiff: s.minDiff,
|
||||
maxDiff: s.maxDiff,
|
||||
dropIdle: s.dropIdle,
|
||||
logLevel: s.logLevel,
|
||||
zmqEnabled: s.zmqEnabled,
|
||||
tlsEnabled: s.tlsEnabled,
|
||||
mempoolExplorerUrl: s.mempoolExplorerUrl,
|
||||
}))
|
||||
.const(effects)
|
||||
if (!store) throw new Error('No store.json')
|
||||
|
||||
// bitcoind's RPC + ZMQ endpoints over the LXC bridge (see bitcoindBridge in
|
||||
@@ -122,8 +140,8 @@ export const main = sdk.setupMain(async ({ effects }) => {
|
||||
blockpoll: 100,
|
||||
update_interval: 30,
|
||||
serverurl: [
|
||||
`0.0.0.0:${store.stratumPort}`,
|
||||
`127.0.0.1:${tlsInternalPort}`,
|
||||
`0.0.0.0:${stratumInternalPort}`,
|
||||
`127.0.0.1:${ckpoolTlsLoopbackPort}`,
|
||||
],
|
||||
mindiff: store.minDiff,
|
||||
startdiff: store.startDiff,
|
||||
@@ -142,10 +160,11 @@ export const main = sdk.setupMain(async ({ effects }) => {
|
||||
ckpoolConfTemplate,
|
||||
)
|
||||
|
||||
// stunnel.conf is rendered here rather than shipped as a static asset,
|
||||
// because the accept port is user config now. `connect` stays on ckpool's
|
||||
// fixed loopback bind so TLS clients keep getting tagged server == 1 (the
|
||||
// dashboard's lock icon).
|
||||
// stunnel.conf is rendered here rather than shipped as a static asset so it
|
||||
// stays next to the ports it references. `connect` targets ckpool's loopback
|
||||
// bind so TLS clients keep getting tagged server == 1 (the dashboard's lock
|
||||
// icon); `accept` is the fixed in-container TLS port, which the OS forwards
|
||||
// the user's chosen external port to.
|
||||
if (store.tlsEnabled) {
|
||||
const stunnelConf = [
|
||||
'foreground = yes',
|
||||
@@ -166,8 +185,8 @@ export const main = sdk.setupMain(async ({ effects }) => {
|
||||
'options = NO_TLSv1_1',
|
||||
'',
|
||||
'[stratum]',
|
||||
`accept = 0.0.0.0:${store.stratumTlsPort}`,
|
||||
`connect = 127.0.0.1:${tlsInternalPort}`,
|
||||
`accept = 0.0.0.0:${stratumTlsInternalPort}`,
|
||||
`connect = 127.0.0.1:${ckpoolTlsLoopbackPort}`,
|
||||
`cert = ${tlsDir}/stratum.pem`,
|
||||
// No client-cert auth — stratum over TLS is opportunistic encryption;
|
||||
// the stratum protocol layer handles miner auth via username.
|
||||
@@ -253,7 +272,7 @@ export const main = sdk.setupMain(async ({ effects }) => {
|
||||
display: i18n('Stratum Server'),
|
||||
gracePeriod: 30_000,
|
||||
fn: () =>
|
||||
sdk.healthCheck.checkPortListening(effects, store.stratumPort, {
|
||||
sdk.healthCheck.checkPortListening(effects, stratumInternalPort, {
|
||||
successMessage: i18n('The stratum server is accepting connections'),
|
||||
errorMessage: i18n(
|
||||
'The stratum server is not accepting connections',
|
||||
@@ -372,7 +391,7 @@ export const main = sdk.setupMain(async ({ effects }) => {
|
||||
fn: () =>
|
||||
sdk.healthCheck.checkPortListening(
|
||||
effects,
|
||||
store.stratumTlsPort,
|
||||
stratumTlsInternalPort,
|
||||
{
|
||||
successMessage: i18n(
|
||||
'TLS stratum is accepting connections',
|
||||
|
||||
Reference in New Issue
Block a user