diff --git a/api/grpc/scanner/scanner.pb.go b/api/grpc/scanner/scanner.pb.go index bb70c71009..60ef27f751 100644 --- a/api/grpc/scanner/scanner.pb.go +++ b/api/grpc/scanner/scanner.pb.go @@ -211,20 +211,20 @@ var file_scanner_scanner_proto_rawDesc = []byte{ 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x32, - 0xa5, 0x01, 0x0a, 0x13, 0x52, 0x65, 0x61, 0x63, 0x68, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x44, 0x0a, 0x09, 0x50, 0x6f, 0x72, 0x74, 0x43, - 0x68, 0x65, 0x63, 0x6b, 0x12, 0x19, 0x2e, 0x73, 0x63, 0x61, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x50, - 0x6f, 0x72, 0x74, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x1a, 0x2e, 0x73, 0x63, 0x61, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x43, 0x68, - 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x48, 0x0a, - 0x0d, 0x48, 0x6f, 0x73, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x19, - 0x2e, 0x73, 0x63, 0x61, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x43, 0x68, 0x65, - 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x73, 0x63, 0x61, 0x6e, - 0x6e, 0x65, 0x72, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x2f, 0x5a, 0x2d, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4c, 0x61, 0x79, 0x72, 0x2d, 0x4c, 0x61, 0x62, 0x73, 0x2f, - 0x65, 0x69, 0x67, 0x65, 0x6e, 0x64, 0x61, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, 0x70, 0x63, - 0x2f, 0x73, 0x63, 0x61, 0x6e, 0x6e, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0xa2, 0x01, 0x0a, 0x0c, 0x52, 0x65, 0x61, 0x63, 0x68, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, + 0x12, 0x44, 0x0a, 0x09, 0x50, 0x6f, 0x72, 0x74, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x19, 0x2e, + 0x73, 0x63, 0x61, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x43, 0x68, 0x65, 0x63, + 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x73, 0x63, 0x61, 0x6e, 0x6e, + 0x65, 0x72, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4c, 0x0a, 0x0d, 0x48, 0x6f, 0x73, 0x74, 0x50, 0x6f, + 0x72, 0x74, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x1d, 0x2e, 0x73, 0x63, 0x61, 0x6e, 0x6e, 0x65, + 0x72, 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x73, 0x63, 0x61, 0x6e, 0x6e, 0x65, 0x72, + 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x42, 0x2f, 0x5a, 0x2d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x4c, 0x61, 0x79, 0x72, 0x2d, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x65, 0x69, 0x67, + 0x65, 0x6e, 0x64, 0x61, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x73, 0x63, + 0x61, 0x6e, 0x6e, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -246,10 +246,10 @@ var file_scanner_scanner_proto_goTypes = []interface{}{ (*PortCheckResponse)(nil), // 2: scanner.PortCheckResponse } var file_scanner_scanner_proto_depIdxs = []int32{ - 0, // 0: scanner.ReachabilityService.PortCheck:input_type -> scanner.PortCheckRequest - 0, // 1: scanner.ReachabilityService.HostPortCheck:input_type -> scanner.PortCheckRequest - 2, // 2: scanner.ReachabilityService.PortCheck:output_type -> scanner.PortCheckResponse - 2, // 3: scanner.ReachabilityService.HostPortCheck:output_type -> scanner.PortCheckResponse + 0, // 0: scanner.Reachability.PortCheck:input_type -> scanner.PortCheckRequest + 1, // 1: scanner.Reachability.HostPortCheck:input_type -> scanner.HostPortCheckRequest + 2, // 2: scanner.Reachability.PortCheck:output_type -> scanner.PortCheckResponse + 2, // 3: scanner.Reachability.HostPortCheck:output_type -> scanner.PortCheckResponse 2, // [2:4] is the sub-list for method output_type 0, // [0:2] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name diff --git a/api/grpc/scanner/scanner_grpc.pb.go b/api/grpc/scanner/scanner_grpc.pb.go index 92db69286c..17fbac6c03 100644 --- a/api/grpc/scanner/scanner_grpc.pb.go +++ b/api/grpc/scanner/scanner_grpc.pb.go @@ -14,122 +14,122 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 -// ReachabilityServiceClient is the client API for ReachabilityService service. +// ReachabilityClient is the client API for Reachability service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type ReachabilityServiceClient interface { +type ReachabilityClient interface { PortCheck(ctx context.Context, in *PortCheckRequest, opts ...grpc.CallOption) (*PortCheckResponse, error) - HostPortCheck(ctx context.Context, in *PortCheckRequest, opts ...grpc.CallOption) (*PortCheckResponse, error) + HostPortCheck(ctx context.Context, in *HostPortCheckRequest, opts ...grpc.CallOption) (*PortCheckResponse, error) } -type reachabilityServiceClient struct { +type reachabilityClient struct { cc grpc.ClientConnInterface } -func NewReachabilityServiceClient(cc grpc.ClientConnInterface) ReachabilityServiceClient { - return &reachabilityServiceClient{cc} +func NewReachabilityClient(cc grpc.ClientConnInterface) ReachabilityClient { + return &reachabilityClient{cc} } -func (c *reachabilityServiceClient) PortCheck(ctx context.Context, in *PortCheckRequest, opts ...grpc.CallOption) (*PortCheckResponse, error) { +func (c *reachabilityClient) PortCheck(ctx context.Context, in *PortCheckRequest, opts ...grpc.CallOption) (*PortCheckResponse, error) { out := new(PortCheckResponse) - err := c.cc.Invoke(ctx, "/scanner.ReachabilityService/PortCheck", in, out, opts...) + err := c.cc.Invoke(ctx, "/scanner.Reachability/PortCheck", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *reachabilityServiceClient) HostPortCheck(ctx context.Context, in *PortCheckRequest, opts ...grpc.CallOption) (*PortCheckResponse, error) { +func (c *reachabilityClient) HostPortCheck(ctx context.Context, in *HostPortCheckRequest, opts ...grpc.CallOption) (*PortCheckResponse, error) { out := new(PortCheckResponse) - err := c.cc.Invoke(ctx, "/scanner.ReachabilityService/HostPortCheck", in, out, opts...) + err := c.cc.Invoke(ctx, "/scanner.Reachability/HostPortCheck", in, out, opts...) if err != nil { return nil, err } return out, nil } -// ReachabilityServiceServer is the server API for ReachabilityService service. -// All implementations must embed UnimplementedReachabilityServiceServer +// ReachabilityServer is the server API for Reachability service. +// All implementations must embed UnimplementedReachabilityServer // for forward compatibility -type ReachabilityServiceServer interface { +type ReachabilityServer interface { PortCheck(context.Context, *PortCheckRequest) (*PortCheckResponse, error) - HostPortCheck(context.Context, *PortCheckRequest) (*PortCheckResponse, error) - mustEmbedUnimplementedReachabilityServiceServer() + HostPortCheck(context.Context, *HostPortCheckRequest) (*PortCheckResponse, error) + mustEmbedUnimplementedReachabilityServer() } -// UnimplementedReachabilityServiceServer must be embedded to have forward compatible implementations. -type UnimplementedReachabilityServiceServer struct { +// UnimplementedReachabilityServer must be embedded to have forward compatible implementations. +type UnimplementedReachabilityServer struct { } -func (UnimplementedReachabilityServiceServer) PortCheck(context.Context, *PortCheckRequest) (*PortCheckResponse, error) { +func (UnimplementedReachabilityServer) PortCheck(context.Context, *PortCheckRequest) (*PortCheckResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method PortCheck not implemented") } -func (UnimplementedReachabilityServiceServer) HostPortCheck(context.Context, *PortCheckRequest) (*PortCheckResponse, error) { +func (UnimplementedReachabilityServer) HostPortCheck(context.Context, *HostPortCheckRequest) (*PortCheckResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method HostPortCheck not implemented") } -func (UnimplementedReachabilityServiceServer) mustEmbedUnimplementedReachabilityServiceServer() {} +func (UnimplementedReachabilityServer) mustEmbedUnimplementedReachabilityServer() {} -// UnsafeReachabilityServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to ReachabilityServiceServer will +// UnsafeReachabilityServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ReachabilityServer will // result in compilation errors. -type UnsafeReachabilityServiceServer interface { - mustEmbedUnimplementedReachabilityServiceServer() +type UnsafeReachabilityServer interface { + mustEmbedUnimplementedReachabilityServer() } -func RegisterReachabilityServiceServer(s grpc.ServiceRegistrar, srv ReachabilityServiceServer) { - s.RegisterService(&ReachabilityService_ServiceDesc, srv) +func RegisterReachabilityServer(s grpc.ServiceRegistrar, srv ReachabilityServer) { + s.RegisterService(&Reachability_ServiceDesc, srv) } -func _ReachabilityService_PortCheck_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Reachability_PortCheck_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(PortCheckRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ReachabilityServiceServer).PortCheck(ctx, in) + return srv.(ReachabilityServer).PortCheck(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/scanner.ReachabilityService/PortCheck", + FullMethod: "/scanner.Reachability/PortCheck", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ReachabilityServiceServer).PortCheck(ctx, req.(*PortCheckRequest)) + return srv.(ReachabilityServer).PortCheck(ctx, req.(*PortCheckRequest)) } return interceptor(ctx, in, info, handler) } -func _ReachabilityService_HostPortCheck_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(PortCheckRequest) +func _Reachability_HostPortCheck_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(HostPortCheckRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ReachabilityServiceServer).HostPortCheck(ctx, in) + return srv.(ReachabilityServer).HostPortCheck(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/scanner.ReachabilityService/HostPortCheck", + FullMethod: "/scanner.Reachability/HostPortCheck", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ReachabilityServiceServer).HostPortCheck(ctx, req.(*PortCheckRequest)) + return srv.(ReachabilityServer).HostPortCheck(ctx, req.(*HostPortCheckRequest)) } return interceptor(ctx, in, info, handler) } -// ReachabilityService_ServiceDesc is the grpc.ServiceDesc for ReachabilityService service. +// Reachability_ServiceDesc is the grpc.ServiceDesc for Reachability service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) -var ReachabilityService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "scanner.ReachabilityService", - HandlerType: (*ReachabilityServiceServer)(nil), +var Reachability_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "scanner.Reachability", + HandlerType: (*ReachabilityServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "PortCheck", - Handler: _ReachabilityService_PortCheck_Handler, + Handler: _Reachability_PortCheck_Handler, }, { MethodName: "HostPortCheck", - Handler: _ReachabilityService_HostPortCheck_Handler, + Handler: _Reachability_HostPortCheck_Handler, }, }, Streams: []grpc.StreamDesc{}, diff --git a/api/proto/scanner/scanner.proto b/api/proto/scanner/scanner.proto index 62686b42e9..5630eaf3d7 100644 --- a/api/proto/scanner/scanner.proto +++ b/api/proto/scanner/scanner.proto @@ -20,7 +20,7 @@ message PortCheckResponse { string msg = 4; } -service ReachabilityService { +service Reachability { rpc PortCheck (PortCheckRequest) returns (PortCheckResponse) {} - rpc HostPortCheck (PortCheckRequest) returns (PortCheckResponse) {} + rpc HostPortCheck (HostPortCheckRequest) returns (PortCheckResponse) {} } diff --git a/go.mod b/go.mod index 113d0917c6..b071a97f69 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ toolchain go1.21.1 require ( github.com/Layr-Labs/eigenda/api v0.0.0 github.com/Layr-Labs/eigensdk-go v0.1.6-0.20240409054704-47c41ef999a9 - github.com/Ullaakut/nmap/v3 v3.0.3 + github.com/Ullaakut/nmap v2.0.2+incompatible github.com/aws/aws-sdk-go-v2 v1.26.0 github.com/aws/aws-sdk-go-v2/credentials v1.17.9 github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.13.12 diff --git a/scanner/cmd/main.go b/scanner/cmd/main.go index eebf476fd7..f46f713fd8 100644 --- a/scanner/cmd/main.go +++ b/scanner/cmd/main.go @@ -56,10 +56,8 @@ func ScannerMain(ctx *cli.Context) error { return err } - //ratelimiter := ratelimit.NewRateLimiter(globalParams, bucketStore, logger) - // Creates the GRPC server. - server := grpc.NewServer(config, scanner, logger) //, ratelimiter) + server := grpc.NewServer(config, scanner, logger) if err := server.Start(); err != nil { log.Fatalf("Failed to start server: %v", err) } diff --git a/scanner/grpc/server.go b/scanner/grpc/server.go index 357f9450e2..639e946921 100644 --- a/scanner/grpc/server.go +++ b/scanner/grpc/server.go @@ -8,7 +8,6 @@ import ( "time" pb "github.com/Layr-Labs/eigenda/api/grpc/scanner" - "github.com/Layr-Labs/eigenda/common" "github.com/Layr-Labs/eigenda/scanner" "github.com/Layr-Labs/eigensdk-go/logging" "github.com/Ullaakut/nmap" @@ -27,17 +26,14 @@ type Server struct { scanner *scanner.Scanner config *scanner.Config logger logging.Logger - - ratelimiter common.RateLimiter } // NewServer func func NewServer(config *scanner.Config, scanner *scanner.Scanner, logger logging.Logger) *Server { return &Server{ - config: config, - logger: logger, - scanner: scanner, - ratelimiter: nil, + config: config, + logger: logger, + scanner: scanner, } } @@ -50,8 +46,6 @@ func (s *Server) Start() error { log.Fatalf("failed to start tcp listener: %v", err) } - s.logger.Info("registering service") - //opt := grpc.MaxRecvMsgSize(128) gs := grpc.NewServer() reflection.Register(gs) pb.RegisterReachabilityServer(gs, s) @@ -107,7 +101,7 @@ func (s *Server) PortCheck(ctx context.Context, in *pb.PortCheckRequest) (*pb.Po } port := host.Ports[0] - fmt.Printf("\tPort %d %s\n", port.ID, port.State) + s.logger.Info("Port Check", ip, port.ID, port.State) fmt.Printf("Host scanned in %.2f seconds\n", result.Stats.Finished.Elapsed) return &pb.PortCheckResponse{Status: port.State.String(), Msg: "", Port: in.Port, Host: ip}, nil } diff --git a/scanner/scanner.go b/scanner/scanner.go index 8ad38df532..d6f94d0f7e 100644 --- a/scanner/scanner.go +++ b/scanner/scanner.go @@ -5,7 +5,6 @@ import ( "github.com/prometheus/client_golang/prometheus" - //"github.com/Layr-Labs/eigenda/api/grpc/scanner" "github.com/Layr-Labs/eigensdk-go/logging" "github.com/Layr-Labs/eigensdk-go/metrics" )