CloudflareServer.go 884 B

123456789101112131415161718192021222324252627282930313233343536
  1. package main
  2. import (
  3. "cfTest/cloudflareApi/cache/purge"
  4. "cfTest/cloudflareApi/certificate"
  5. "cfTest/cloudflareApi/dns"
  6. "cfTest/cloudflareApi/logPush"
  7. "cfTest/cloudflareApi/zone"
  8. "cfTest/server"
  9. "google.golang.org/grpc"
  10. "log"
  11. "net"
  12. )
  13. const (
  14. port = ":50051"
  15. )
  16. func main() {
  17. lis, err := net.Listen("tcp", port)
  18. if err != nil {
  19. log.Fatalf("failed to listen: %v", err)
  20. }
  21. s := grpc.NewServer()
  22. purge.RegisterPurgeCloudflareServer(s, &server.PurgeServer{})
  23. certificate.RegisterCertificateCloudflareServer(s, &server.CertificateServer{})
  24. zone.RegisterZoneCloudflareServer(s, &server.ZoneServer{})
  25. dns.RegisterDnsCloudflareServer(s, &server.DnsServer{})
  26. logPush.RegisterLogPushCloudflareServer(s, &server.LogPushCloudflareServer{})
  27. log.Printf("server listening at %v", lis.Addr())
  28. if err := s.Serve(lis); err != nil {
  29. log.Fatalf("failed to serve: %v", err)
  30. }
  31. }