mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-11 04:00:05 +00:00
Faucet: Use client IP in captcha requests (#4196)
* Use client IP in captcha requests
This commit is contained in:
parent
23dd951e59
commit
544e5309ad
@ -19,7 +19,7 @@ import (
|
||||
recaptcha "github.com/prestonvanloon/go-recaptcha"
|
||||
faucetpb "github.com/prysmaticlabs/prysm/proto/faucet"
|
||||
"github.com/prysmaticlabs/prysm/shared/roughtime"
|
||||
"google.golang.org/grpc/peer"
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
var fundingAmount = big.NewInt(3.5 * params.Ether)
|
||||
@ -70,13 +70,15 @@ func newFaucetServer(
|
||||
}
|
||||
|
||||
func (s *faucetServer) verifyRecaptcha(ctx context.Context, req *faucetpb.FundingRequest) error {
|
||||
p, ok := peer.FromContext(ctx)
|
||||
if !ok {
|
||||
return errors.New("peer from ctx not ok")
|
||||
md, ok := metadata.FromIncomingContext(ctx)
|
||||
if !ok || len(md.Get("x-forwarded-for")) < 1 {
|
||||
return errors.New("metadata not ok")
|
||||
}
|
||||
fmt.Printf("Sending captcha request for peer %s\n", p.Addr.String())
|
||||
|
||||
peer := md.Get("x-forwarded-for")[0]
|
||||
fmt.Printf("Sending captcha request for peer %s\n", peer)
|
||||
|
||||
rr, err := s.r.Check(p.Addr.String(), req.RecaptchaResponse)
|
||||
rr, err := s.r.Check(peer, req.RecaptchaResponse)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user