Преглед изворни кода

opt: 修改curl日志文件命名形式为MM-DD-YYYY

kuanglingwei пре 1 година
родитељ
комит
a586227429

+ 1 - 1
Curl.go

@@ -2,7 +2,7 @@ package main
 
 import (
 	"cfTest/curlServer"
-	"cfTest/curlServer/pb"
+	pb "cfTest/curlServer/pb"
 	"google.golang.org/grpc"
 	"net"
 )

+ 8 - 8
curlServer/CurlServer.go

@@ -21,15 +21,15 @@ type CurlServer struct {
 func (s *CurlServer) CurlWithResolveParam(ctx context.Context, requestCurlObject *curl2.CurlRequest) (*curl2.CurlReply, error) {
 	logger.Println("url Received: ", requestCurlObject.GetUrl())
 	logger.Println("ip Received: ", requestCurlObject.GetIp())
-	logger.Println("UA Received: ", requestCurlObject.GetUA())
+	logger.Println("ua Received: ", requestCurlObject.GetUa())
 	logger.Println("UseHeadMethod Received: ", requestCurlObject.GetUseHeadMethod())
 
-	// UA
-	var UA = ""
-	if len(requestCurlObject.GetUA()) == 0 {
-		UA = generateDefaultUserAgent()
+	// ua
+	var ua = ""
+	if len(requestCurlObject.GetUa()) == 0 {
+		ua = generateDefaultUserAgent()
 	} else {
-		UA = requestCurlObject.GetUA()
+		ua = requestCurlObject.GetUa()
 	}
 
 	// Server
@@ -55,7 +55,7 @@ func (s *CurlServer) CurlWithResolveParam(ctx context.Context, requestCurlObject
 			},
 		},
 		// 指定UA
-		UserAgent:     UA,
+		UserAgent:     ua,
 		UseHeadMethod: requestCurlObject.GetUseHeadMethod(),
 	}
 
@@ -145,7 +145,7 @@ func setupLogger() {
 }
 
 func generateLogFileName() string {
-	currentDate := time.Now().Format("2006-01-02")
+	currentDate := time.Now().Format("01-02-2006")
 	return "curl_" + currentDate + ".log"
 }
 

+ 12 - 12
curlServer/pb/curl.pb.go

@@ -4,7 +4,7 @@
 // 	protoc        v4.23.3
 // source: curl.proto
 
-package pb
+package curl
 
 import (
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
@@ -28,8 +28,8 @@ type CurlRequest struct {
 
 	Url           string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"`
 	Ip            string `protobuf:"bytes,2,opt,name=ip,proto3" json:"ip,omitempty"`
-	UA            string `protobuf:"bytes,3,opt,name=UA,proto3" json:"UA,omitempty"`
-	UseHeadMethod bool   `protobuf:"varint,4,opt,name=UseHeadMethod,proto3" json:"UseHeadMethod,omitempty"`
+	Ua            string `protobuf:"bytes,3,opt,name=ua,proto3" json:"ua,omitempty"`
+	UseHeadMethod bool   `protobuf:"varint,4,opt,name=useHeadMethod,proto3" json:"useHeadMethod,omitempty"`
 }
 
 func (x *CurlRequest) Reset() {
@@ -78,9 +78,9 @@ func (x *CurlRequest) GetIp() string {
 	return ""
 }
 
-func (x *CurlRequest) GetUA() string {
+func (x *CurlRequest) GetUa() string {
 	if x != nil {
-		return x.UA
+		return x.Ua
 	}
 	return ""
 }
@@ -163,9 +163,9 @@ var file_curl_proto_rawDesc = []byte{
 	0x72, 0x6c, 0x22, 0x65, 0x0a, 0x0b, 0x43, 0x75, 0x72, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
 	0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03,
 	0x75, 0x72, 0x6c, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
-	0x02, 0x69, 0x70, 0x12, 0x0e, 0x0a, 0x02, 0x55, 0x41, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,
-	0x02, 0x55, 0x41, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x48, 0x65, 0x61, 0x64, 0x4d, 0x65,
-	0x74, 0x68, 0x6f, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x48,
+	0x02, 0x69, 0x70, 0x12, 0x0e, 0x0a, 0x02, 0x75, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,
+	0x02, 0x75, 0x61, 0x12, 0x24, 0x0a, 0x0d, 0x75, 0x73, 0x65, 0x48, 0x65, 0x61, 0x64, 0x4d, 0x65,
+	0x74, 0x68, 0x6f, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x75, 0x73, 0x65, 0x48,
 	0x65, 0x61, 0x64, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x22, 0x5b, 0x0a, 0x09, 0x43, 0x75, 0x72,
 	0x6c, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01,
 	0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x63, 0x6f,
@@ -177,10 +177,10 @@ var file_curl_proto_rawDesc = []byte{
 	0x6c, 0x57, 0x69, 0x74, 0x68, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x50, 0x61, 0x72, 0x61,
 	0x6d, 0x12, 0x11, 0x2e, 0x63, 0x75, 0x72, 0x6c, 0x2e, 0x43, 0x75, 0x72, 0x6c, 0x52, 0x65, 0x71,
 	0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x63, 0x75, 0x72, 0x6c, 0x2e, 0x43, 0x75, 0x72, 0x6c,
-	0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, 0x25, 0x0a, 0x0a, 0x69, 0x6f, 0x2e, 0x67, 0x72,
-	0x70, 0x63, 0x2e, 0x70, 0x62, 0x42, 0x0f, 0x63, 0x75, 0x72, 0x6c, 0x57, 0x69, 0x74, 0x68, 0x52,
-	0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x50, 0x01, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06,
-	0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, 0x29, 0x0a, 0x0c, 0x69, 0x6f, 0x2e, 0x67, 0x72,
+	0x70, 0x63, 0x2e, 0x63, 0x75, 0x72, 0x6c, 0x42, 0x0f, 0x63, 0x75, 0x72, 0x6c, 0x57, 0x69, 0x74,
+	0x68, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x50, 0x01, 0x5a, 0x06, 0x2e, 0x2f, 0x63, 0x75,
+	0x72, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (

+ 1 - 1
curlServer/pb/curl_grpc.pb.go

@@ -4,7 +4,7 @@
 // - protoc             v4.23.3
 // source: curl.proto
 
-package pb
+package curl
 
 import (
 	context "context"

+ 0 - 30
curlServer/proto/curl.proto

@@ -1,30 +0,0 @@
-syntax = "proto3";
-
-package curl;
-
-option go_package = "./pb";
-option java_multiple_files = true;
-option java_package = "io.grpc.pb";
-option java_outer_classname = "curlWithResolve";
-
-service CurlWithResolve {
-  // Sends a greeting
-  rpc CurlWithResolveParam (CurlRequest) returns  (CurlReply) {}
-}
-
-// request
-message CurlRequest {
-  string url = 1;
-  string ip = 2;
-  string UA = 3;
-  bool UseHeadMethod = 4;
-}
-
-// response
-message CurlReply {
-  int32 code = 1;
-  int64 contentLength = 2;
-  string error = 3;
-}
-
-

+ 1 - 1
proto

@@ -1 +1 @@
-Subproject commit e1cbc80711aa7c3259731a3642944221e6de6f4f
+Subproject commit 78a3d2d8900e5e74f6f89b429fe9812a330b64da

shell/curlServer/curl-server/curlServer.sh → shell/curlServer/curlServer.sh


+ 2 - 2
shell/curlServer/package/packageCurlServer.sh

@@ -5,11 +5,11 @@ ROOT=$(cd `dirname $0`/../../../; pwd)
 mkdir -p $ROOT/release/tmpE
 rm -rf $ROOT/release/tmpE/*
 mkdir -p $ROOT/release/tmpE/curl-server/lib
-mkdir -p $ROOT/release/tmpE/curl-server/shell
+mkdir -p $ROOT/release/tmpE/curl-server/shell/curlServer
 
 cp $ROOT/lib/CurlServer $ROOT/release/tmpE/curl-server/lib
 
-cp -rf $ROOT/shell/curlServer/curl-server $ROOT/release/tmpE/curl-server/shell
+cp -rf $ROOT/shell/curlServer/*.sh $ROOT/release/tmpE/curl-server/shell/curlServer
 
 mkdir -p $ROOT/release/tmpE/curl-server/logs/CurlServer
 mkdir -p $ROOT/release/tmpE/curl-server/pid

shell/curlServer/curl-server/restart.sh → shell/curlServer/restart.sh


shell/curlServer/curl-server/start.sh → shell/curlServer/start.sh


shell/curlServer/curl-server/status.sh → shell/curlServer/status.sh


shell/curlServer/curl-server/stop.sh → shell/curlServer/stop.sh