Browse Source

Unknown request method eth_submitHashrate from ( ip)

master
yuriy0803 2 years ago
parent
commit
e339417335
  1. 13
      proxy/handlers.go
  2. 7
      proxy/stratum.go

13
proxy/handlers.go

@ -1,6 +1,7 @@
package proxy package proxy
import ( import (
"fmt"
"log" "log"
"regexp" "regexp"
"strings" "strings"
@ -173,10 +174,10 @@ func (s *ProxyServer) handleGetBlockByNumberRPC() *rpc.GetBlockReplyPart {
return reply return reply
} }
// handleUnknownRPC handles an unknown RPC request method. // handleUnknownRPC handles incoming requests with unknown methods
// It logs an error and returns an error reply. func (s *ProxyServer) handleUnknownRPC(cs *Session, method string) *ErrorReply {
func (s *ProxyServer) handleUnknownRPC(cs *Session, m string) *ErrorReply { // Implement your logic for handling unknown methods here
log.Printf("Unknown request method %s from %s", m, cs.ip) // For example, you can return a custom error indicating that the method is not supported
s.policy.ApplyMalformedPolicy(cs.ip) errMsg := fmt.Sprintf("Method %s not supported", method)
return &ErrorReply{Code: -3, Message: "Method not found"} return &ErrorReply{Code: -32601, Message: errMsg}
} }

7
proxy/stratum.go

@ -5,6 +5,7 @@ import (
"crypto/tls" "crypto/tls"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt"
"io" "io"
"log" "log"
"math/rand" "math/rand"
@ -392,8 +393,12 @@ func (cs *Session) handleTCPMessage(s *ProxyServer, req *StratumReq) error {
return cs.sendTCPResult(req.Id, &reply) return cs.sendTCPResult(req.Id, &reply)
case "eth_submitHashrate": case "eth_submitHashrate":
return cs.sendTCPResult(req.Id, true) // Return an error indicating that the method is not supported
errMsg := fmt.Sprintf("Method %s not supported", req.Method)
errReply := &ErrorReply{Code: -32601, Message: errMsg}
return cs.sendTCPError(req.Id, errReply)
default: default:
// Handle unknown methods
errReply := s.handleUnknownRPC(cs, req.Method) errReply := s.handleUnknownRPC(cs, req.Method)
return cs.sendTCPError(req.Id, errReply) return cs.sendTCPError(req.Id, errReply)
} }

Loading…
Cancel
Save