docs(proxy): sharpen AX usage examples
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
be47d7afde
commit
30ff013158
3 changed files with 21 additions and 9 deletions
|
|
@ -282,7 +282,7 @@ func (cd *CustomDiff) OnLogin(e Event) {
|
||||||
if e.Miner.customDiffResolved {
|
if e.Miner.customDiffResolved {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
e.Miner.user, e.Miner.customDiff = parseLoginUser(e.Miner.user, cd.globalDiff.Load())
|
e.Miner.user, e.Miner.customDiff = resolveLoginCustomDiff(e.Miner.user, cd.globalDiff.Load())
|
||||||
e.Miner.customDiffResolved = true
|
e.Miner.customDiffResolved = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
20
log/impl.go
20
log/impl.go
|
|
@ -33,7 +33,10 @@ func (l *AccessLog) Close() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnLogin writes `2026-04-04T12:00:00Z CONNECT 10.0.0.1 WALLET XMRig/6.21.0`.
|
// OnLogin writes a connect line such as:
|
||||||
|
//
|
||||||
|
// al.OnLogin(proxy.Event{Miner: &proxy.Miner{}})
|
||||||
|
// // 2026-04-04T12:00:00Z CONNECT 10.0.0.1 WALLET XMRig/6.21.0
|
||||||
func (l *AccessLog) OnLogin(e proxy.Event) {
|
func (l *AccessLog) OnLogin(e proxy.Event) {
|
||||||
if l == nil || e.Miner == nil {
|
if l == nil || e.Miner == nil {
|
||||||
return
|
return
|
||||||
|
|
@ -41,7 +44,10 @@ func (l *AccessLog) OnLogin(e proxy.Event) {
|
||||||
l.writeConnectLine(e.Miner.IP(), e.Miner.User(), e.Miner.Agent())
|
l.writeConnectLine(e.Miner.IP(), e.Miner.User(), e.Miner.Agent())
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnClose writes `2026-04-04T12:00:00Z CLOSE 10.0.0.1 WALLET rx=512 tx=4096`.
|
// OnClose writes a close line such as:
|
||||||
|
//
|
||||||
|
// al.OnClose(proxy.Event{Miner: &proxy.Miner{}})
|
||||||
|
// // 2026-04-04T12:00:00Z CLOSE 10.0.0.1 WALLET rx=512 tx=4096
|
||||||
func (l *AccessLog) OnClose(e proxy.Event) {
|
func (l *AccessLog) OnClose(e proxy.Event) {
|
||||||
if l == nil || e.Miner == nil {
|
if l == nil || e.Miner == nil {
|
||||||
return
|
return
|
||||||
|
|
@ -73,7 +79,10 @@ func (l *ShareLog) Close() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnAccept writes `2026-04-04T12:00:00Z ACCEPT WALLET diff=100000 latency=82ms`.
|
// OnAccept writes an accept line such as:
|
||||||
|
//
|
||||||
|
// sl.OnAccept(proxy.Event{Miner: &proxy.Miner{}, Diff: 100000, Latency: 82})
|
||||||
|
// // 2026-04-04T12:00:00Z ACCEPT WALLET diff=100000 latency=82ms
|
||||||
func (l *ShareLog) OnAccept(e proxy.Event) {
|
func (l *ShareLog) OnAccept(e proxy.Event) {
|
||||||
if l == nil || e.Miner == nil {
|
if l == nil || e.Miner == nil {
|
||||||
return
|
return
|
||||||
|
|
@ -81,7 +90,10 @@ func (l *ShareLog) OnAccept(e proxy.Event) {
|
||||||
l.writeAcceptLine(e.Miner.User(), e.Diff, uint64(e.Latency))
|
l.writeAcceptLine(e.Miner.User(), e.Diff, uint64(e.Latency))
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnReject writes `2026-04-04T12:00:00Z REJECT WALLET reason="Invalid nonce"`.
|
// OnReject writes a reject line such as:
|
||||||
|
//
|
||||||
|
// sl.OnReject(proxy.Event{Miner: &proxy.Miner{}, Error: "Invalid nonce"})
|
||||||
|
// // 2026-04-04T12:00:00Z REJECT WALLET reason="Invalid nonce"
|
||||||
func (l *ShareLog) OnReject(e proxy.Event) {
|
func (l *ShareLog) OnReject(e proxy.Event) {
|
||||||
if l == nil || e.Miner == nil {
|
if l == nil || e.Miner == nil {
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -1002,7 +1002,7 @@ func (m *Miner) handleLogin(request stratumRequest) {
|
||||||
m.ReplyWithError(requestID(request.ID), "Invalid password")
|
m.ReplyWithError(requestID(request.ID), "Invalid password")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
m.user, m.customDiff = parseLoginUser(params.Login, m.globalDiff)
|
m.user, m.customDiff = resolveLoginCustomDiff(params.Login, m.globalDiff)
|
||||||
m.customDiffResolved = true
|
m.customDiffResolved = true
|
||||||
m.password = params.Pass
|
m.password = params.Pass
|
||||||
m.agent = params.Agent
|
m.agent = params.Agent
|
||||||
|
|
@ -1033,11 +1033,11 @@ func (m *Miner) handleLogin(request stratumRequest) {
|
||||||
m.replyLoginSuccess(requestID(request.ID))
|
m.replyLoginSuccess(requestID(request.ID))
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseLoginUser(login string, globalDiff uint64) (string, uint64) {
|
func resolveLoginCustomDiff(login string, globalDiff uint64) (string, uint64) {
|
||||||
plus := strings.LastIndex(login, "+")
|
plus := strings.LastIndex(login, "+")
|
||||||
if plus >= 0 && plus < len(login)-1 {
|
if plus >= 0 && plus < len(login)-1 {
|
||||||
suffix := login[plus+1:]
|
suffix := login[plus+1:]
|
||||||
if isDigits(suffix) {
|
if isDecimalDigits(suffix) {
|
||||||
if parsed, err := strconv.ParseUint(suffix, 10, 64); err == nil {
|
if parsed, err := strconv.ParseUint(suffix, 10, 64); err == nil {
|
||||||
return login[:plus], parsed
|
return login[:plus], parsed
|
||||||
}
|
}
|
||||||
|
|
@ -1050,7 +1050,7 @@ func parseLoginUser(login string, globalDiff uint64) (string, uint64) {
|
||||||
return login, 0
|
return login, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func isDigits(value string) bool {
|
func isDecimalDigits(value string) bool {
|
||||||
if value == "" {
|
if value == "" {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue