Captcha Gateway

This commit is contained in:
2025-03-22 19:48:19 +08:00
parent ba1d96b118
commit 62dcbbf424
14 changed files with 474 additions and 5 deletions

View File

@ -0,0 +1,14 @@
package grpc
import (
"context"
"git.solsynth.dev/hypernet/nexus/pkg/internal/captcha"
"git.solsynth.dev/hypernet/nexus/pkg/proto"
)
func (v *Server) CheckCaptcha(_ context.Context, req *proto.CheckCaptchaRequest) (*proto.CheckCaptchaResponse, error) {
return &proto.CheckCaptchaResponse{
IsValid: captcha.Validate(req.Token, req.RemoteIp),
}, nil
}

View File

@ -19,6 +19,7 @@ type Server struct {
proto.UnimplementedDatabaseServiceServer
proto.UnimplementedStreamServiceServer
proto.UnimplementedAllocatorServiceServer
proto.UnimplementedCaptchaServiceServer
health.UnimplementedHealthServer
srv *grpc.Server
@ -33,6 +34,7 @@ func NewServer() *Server {
proto.RegisterDatabaseServiceServer(server.srv, server)
proto.RegisterStreamServiceServer(server.srv, server)
proto.RegisterAllocatorServiceServer(server.srv, server)
proto.RegisterCaptchaServiceServer(server.srv, server)
health.RegisterHealthServer(server.srv, server)
reflection.Register(server.srv)