Browse Source

return

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

13
proxy/handlers.go

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

7
proxy/stratum.go

@ -5,7 +5,6 @@ import (
"crypto/tls" "crypto/tls"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt"
"io" "io"
"log" "log"
"math/rand" "math/rand"
@ -393,12 +392,8 @@ 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 an error indicating that the method is not supported return cs.sendTCPResult(req.Id, true)
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