refactor(proxy): name miner timeouts and password mask
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
e1eadf705d
commit
b6b44b1f7b
2 changed files with 14 additions and 8 deletions
|
|
@ -34,7 +34,7 @@ var (
|
||||||
// WorkerRow{"rig-alpha", "10.0.0.1", 1, 10, 0, 0, 10000, 1712232000, 1.0, 1.0, 1.0, 1.0, 1.0}
|
// WorkerRow{"rig-alpha", "10.0.0.1", 1, 10, 0, 0, 10000, 1712232000, 1.0, 1.0, 1.0, 1.0, 1.0}
|
||||||
type WorkerRow [13]any
|
type WorkerRow [13]any
|
||||||
|
|
||||||
// MinerRow{1, "10.0.0.1:49152", 4096, 512, 2, 10000, "WALLET", "********", "rig-alpha", "XMRig/6.21.0"}
|
// MinerRow{1, "10.0.0.1:49152", 4096, 512, 2, 10000, "WALLET", maskedPassword, "rig-alpha", "XMRig/6.21.0"}
|
||||||
type MinerRow [10]any
|
type MinerRow [10]any
|
||||||
|
|
||||||
// doc := p.SummaryDocument()
|
// doc := p.SummaryDocument()
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,13 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const maxStratumLineLength = 16384
|
const (
|
||||||
|
maxStratumLineLength = 16384
|
||||||
|
minerLoginTimeout = 10 * time.Second
|
||||||
|
minerReadyTimeout = 600 * time.Second
|
||||||
|
submitDrainTimeout = 5 * time.Second
|
||||||
|
maskedPassword = "********"
|
||||||
|
)
|
||||||
|
|
||||||
// MinerSnapshot is a serialisable view of one miner connection.
|
// MinerSnapshot is a serialisable view of one miner connection.
|
||||||
type MinerSnapshot struct {
|
type MinerSnapshot struct {
|
||||||
|
|
@ -156,7 +162,7 @@ func (p *Proxy) MinerSnapshots() []MinerSnapshot {
|
||||||
State: miner.state,
|
State: miner.state,
|
||||||
Diff: miner.diff,
|
Diff: miner.diff,
|
||||||
User: miner.user,
|
User: miner.user,
|
||||||
Password: "********",
|
Password: maskedPassword,
|
||||||
RigID: miner.rigID,
|
RigID: miner.rigID,
|
||||||
Agent: miner.agent,
|
Agent: miner.agent,
|
||||||
})
|
})
|
||||||
|
|
@ -287,11 +293,11 @@ func (p *Proxy) Stop() {
|
||||||
p.watcher.Stop()
|
p.watcher.Stop()
|
||||||
}
|
}
|
||||||
if p.httpServer != nil {
|
if p.httpServer != nil {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), submitDrainTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
_ = p.httpServer.Shutdown(ctx)
|
_ = p.httpServer.Shutdown(ctx)
|
||||||
}
|
}
|
||||||
deadline := time.Now().Add(5 * time.Second)
|
deadline := time.Now().Add(submitDrainTimeout)
|
||||||
for p.submitCount.Load() > 0 && time.Now().Before(deadline) {
|
for p.submitCount.Load() > 0 && time.Now().Before(deadline) {
|
||||||
time.Sleep(10 * time.Millisecond)
|
time.Sleep(10 * time.Millisecond)
|
||||||
}
|
}
|
||||||
|
|
@ -956,9 +962,9 @@ func (m *Miner) readLoop() {
|
||||||
func (m *Miner) readTimeout() time.Duration {
|
func (m *Miner) readTimeout() time.Duration {
|
||||||
switch m.state {
|
switch m.state {
|
||||||
case MinerStateWaitLogin:
|
case MinerStateWaitLogin:
|
||||||
return 10 * time.Second
|
return minerLoginTimeout
|
||||||
case MinerStateWaitReady, MinerStateReady:
|
case MinerStateWaitReady, MinerStateReady:
|
||||||
return 600 * time.Second
|
return minerReadyTimeout
|
||||||
default:
|
default:
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
@ -1266,7 +1272,7 @@ func (m *Miner) touchActivity() {
|
||||||
}
|
}
|
||||||
m.lastActivityAt = time.Now().UTC()
|
m.lastActivityAt = time.Now().UTC()
|
||||||
if m.conn != nil {
|
if m.conn != nil {
|
||||||
_ = m.conn.SetReadDeadline(time.Now().Add(600 * time.Second))
|
_ = m.conn.SetReadDeadline(time.Now().Add(minerReadyTimeout))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue