fix(proxy): preserve miner remote address in API

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-04 20:59:02 +00:00
parent 8faac7eee6
commit d9c59c668d
2 changed files with 14 additions and 2 deletions

View file

@ -33,6 +33,7 @@ type Miner struct {
extNH bool // NiceHash mode active (fixed byte splitting)
algoEnabled bool // proxy is configured to negotiate the algo extension
ip string // remote IP (without port, for logging)
remoteAddr string
localPort uint16
user string // login params.login (wallet address), custom diff suffix stripped
password string // login params.pass

View file

@ -134,9 +134,13 @@ func (p *Proxy) MinerSnapshots() []MinerSnapshot {
defer p.minersMu.RUnlock()
rows := make([]MinerSnapshot, 0, len(p.miners))
for _, miner := range p.miners {
ip := miner.RemoteAddr()
if ip == "" {
ip = miner.IP()
}
rows = append(rows, MinerSnapshot{
ID: miner.id,
IP: miner.ip,
IP: ip,
TX: miner.tx,
RX: miner.rx,
State: miner.state,
@ -721,7 +725,8 @@ func NewMiner(conn net.Conn, localPort uint16, tlsCfg *tls.Config) *Miner {
miner.tlsConn = tlsConn
}
if remote := conn.RemoteAddr(); remote != nil {
miner.ip = hostOnly(remote.String())
miner.remoteAddr = remote.String()
miner.ip = hostOnly(miner.remoteAddr)
}
return miner
}
@ -767,6 +772,12 @@ func (m *Miner) SetFixedByte(value uint8) {
func (m *Miner) IP() string {
return m.ip
}
func (m *Miner) RemoteAddr() string {
if m == nil {
return ""
}
return m.remoteAddr
}
func (m *Miner) User() string {
return m.user
}