diff --git a/proxy/handlers.go b/proxy/handlers.go index 40be410..7efc91f 100644 --- a/proxy/handlers.go +++ b/proxy/handlers.go @@ -1,7 +1,6 @@ package proxy import ( - "fmt" "log" "regexp" "strings" @@ -174,10 +173,10 @@ func (s *ProxyServer) handleGetBlockByNumberRPC() *rpc.GetBlockReplyPart { return reply } -// handleUnknownRPC handles incoming requests with unknown methods -func (s *ProxyServer) handleUnknownRPC(cs *Session, method string) *ErrorReply { - // Implement your logic for handling unknown methods here - // For example, you can return a custom error indicating that the method is not supported - errMsg := fmt.Sprintf("Method %s not supported", method) - return &ErrorReply{Code: -32601, Message: errMsg} -} \ No newline at end of file +// handleUnknownRPC handles an unknown RPC request method. +// It logs an error and returns an error reply. +func (s *ProxyServer) handleUnknownRPC(cs *Session, m string) *ErrorReply { + log.Printf("Unknown request method %s from %s", m, cs.ip) + s.policy.ApplyMalformedPolicy(cs.ip) + return &ErrorReply{Code: -3, Message: "Method not found"} +} diff --git a/proxy/stratum.go b/proxy/stratum.go index a6f1e2e..d412867 100644 --- a/proxy/stratum.go +++ b/proxy/stratum.go @@ -5,7 +5,6 @@ import ( "crypto/tls" "encoding/json" "errors" - "fmt" "io" "log" "math/rand" @@ -393,12 +392,8 @@ func (cs *Session) handleTCPMessage(s *ProxyServer, req *StratumReq) error { return cs.sendTCPResult(req.Id, &reply) case "eth_submitHashrate": - // 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) + return cs.sendTCPResult(req.Id, true) default: - // Handle unknown methods errReply := s.handleUnknownRPC(cs, req.Method) return cs.sendTCPError(req.Id, errReply) }