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

Add protobuf logging for DSL relay

Rod Hynes пре 4 месеци
родитељ
комит
fe56e1dfb0

+ 1 - 3
psiphon/common/dsl/relay.go

@@ -558,10 +558,8 @@ func (r *Relay) getCachedGetServerEntriesResponse(
 	}
 
 	logFields := r.config.APIParameterLogFieldFormatter("", clientGeoIPData, baseParams)
-	logFields["dsl_event"] = "get-server-entries"
-	logFields["host_id"] = r.config.HostID
 	logFields["server_entry_tags"] = serverEntryTags
-	r.config.Logger.LogMetric("dsl", logFields)
+	r.config.Logger.LogMetric("dsl_relay_get_server_entries", logFields)
 
 	return cborResponse, nil
 }

+ 137 - 0
psiphon/server/pb/psiphond/dsl_relay.pb.go

@@ -0,0 +1,137 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// versions:
+// 	protoc-gen-go v1.36.10
+// 	protoc        v6.33.0
+// source: ca.psiphon.psiphond/dsl_relay.proto
+
+package psiphond
+
+import (
+	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
+	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+	reflect "reflect"
+	sync "sync"
+	unsafe "unsafe"
+)
+
+const (
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
+)
+
+type DSLRelayGetServerEntries struct {
+	state           protoimpl.MessageState `protogen:"open.v1"`
+	BaseParams      *BaseParams            `protobuf:"bytes,1,opt,name=base_params,json=baseParams,proto3,oneof" json:"base_params,omitempty"`
+	ServerEntryTags []string               `protobuf:"bytes,100,rep,name=server_entry_tags,json=serverEntryTags,proto3" json:"server_entry_tags,omitempty"`
+	unknownFields   protoimpl.UnknownFields
+	sizeCache       protoimpl.SizeCache
+}
+
+func (x *DSLRelayGetServerEntries) Reset() {
+	*x = DSLRelayGetServerEntries{}
+	mi := &file_ca_psiphon_psiphond_dsl_relay_proto_msgTypes[0]
+	ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+	ms.StoreMessageInfo(mi)
+}
+
+func (x *DSLRelayGetServerEntries) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*DSLRelayGetServerEntries) ProtoMessage() {}
+
+func (x *DSLRelayGetServerEntries) ProtoReflect() protoreflect.Message {
+	mi := &file_ca_psiphon_psiphond_dsl_relay_proto_msgTypes[0]
+	if x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use DSLRelayGetServerEntries.ProtoReflect.Descriptor instead.
+func (*DSLRelayGetServerEntries) Descriptor() ([]byte, []int) {
+	return file_ca_psiphon_psiphond_dsl_relay_proto_rawDescGZIP(), []int{0}
+}
+
+func (x *DSLRelayGetServerEntries) GetBaseParams() *BaseParams {
+	if x != nil {
+		return x.BaseParams
+	}
+	return nil
+}
+
+func (x *DSLRelayGetServerEntries) GetServerEntryTags() []string {
+	if x != nil {
+		return x.ServerEntryTags
+	}
+	return nil
+}
+
+var File_ca_psiphon_psiphond_dsl_relay_proto protoreflect.FileDescriptor
+
+const file_ca_psiphon_psiphond_dsl_relay_proto_rawDesc = "" +
+	"\n" +
+	"#ca.psiphon.psiphond/dsl_relay.proto\x12\x13ca.psiphon.psiphond\x1a%ca.psiphon.psiphond/base_params.proto\"\x9d\x01\n" +
+	"\x18DSLRelayGetServerEntries\x12E\n" +
+	"\vbase_params\x18\x01 \x01(\v2\x1f.ca.psiphon.psiphond.BaseParamsH\x00R\n" +
+	"baseParams\x88\x01\x01\x12*\n" +
+	"\x11server_entry_tags\x18d \x03(\tR\x0fserverEntryTagsB\x0e\n" +
+	"\f_base_paramsBHZFgithub.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/server/pb/psiphondb\x06proto3"
+
+var (
+	file_ca_psiphon_psiphond_dsl_relay_proto_rawDescOnce sync.Once
+	file_ca_psiphon_psiphond_dsl_relay_proto_rawDescData []byte
+)
+
+func file_ca_psiphon_psiphond_dsl_relay_proto_rawDescGZIP() []byte {
+	file_ca_psiphon_psiphond_dsl_relay_proto_rawDescOnce.Do(func() {
+		file_ca_psiphon_psiphond_dsl_relay_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_ca_psiphon_psiphond_dsl_relay_proto_rawDesc), len(file_ca_psiphon_psiphond_dsl_relay_proto_rawDesc)))
+	})
+	return file_ca_psiphon_psiphond_dsl_relay_proto_rawDescData
+}
+
+var file_ca_psiphon_psiphond_dsl_relay_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
+var file_ca_psiphon_psiphond_dsl_relay_proto_goTypes = []any{
+	(*DSLRelayGetServerEntries)(nil), // 0: ca.psiphon.psiphond.DSLRelayGetServerEntries
+	(*BaseParams)(nil),               // 1: ca.psiphon.psiphond.BaseParams
+}
+var file_ca_psiphon_psiphond_dsl_relay_proto_depIdxs = []int32{
+	1, // 0: ca.psiphon.psiphond.DSLRelayGetServerEntries.base_params:type_name -> ca.psiphon.psiphond.BaseParams
+	1, // [1:1] is the sub-list for method output_type
+	1, // [1:1] is the sub-list for method input_type
+	1, // [1:1] is the sub-list for extension type_name
+	1, // [1:1] is the sub-list for extension extendee
+	0, // [0:1] is the sub-list for field type_name
+}
+
+func init() { file_ca_psiphon_psiphond_dsl_relay_proto_init() }
+func file_ca_psiphon_psiphond_dsl_relay_proto_init() {
+	if File_ca_psiphon_psiphond_dsl_relay_proto != nil {
+		return
+	}
+	file_ca_psiphon_psiphond_base_params_proto_init()
+	file_ca_psiphon_psiphond_dsl_relay_proto_msgTypes[0].OneofWrappers = []any{}
+	type x struct{}
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
+			RawDescriptor: unsafe.Slice(unsafe.StringData(file_ca_psiphon_psiphond_dsl_relay_proto_rawDesc), len(file_ca_psiphon_psiphond_dsl_relay_proto_rawDesc)),
+			NumEnums:      0,
+			NumMessages:   1,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_ca_psiphon_psiphond_dsl_relay_proto_goTypes,
+		DependencyIndexes: file_ca_psiphon_psiphond_dsl_relay_proto_depIdxs,
+		MessageInfos:      file_ca_psiphon_psiphond_dsl_relay_proto_msgTypes,
+	}.Build()
+	File_ca_psiphon_psiphond_dsl_relay_proto = out.File
+	file_ca_psiphon_psiphond_dsl_relay_proto_goTypes = nil
+	file_ca_psiphon_psiphond_dsl_relay_proto_depIdxs = nil
+}

+ 15 - 0
psiphon/server/proto/ca.psiphon.psiphond/dsl_relay.proto

@@ -0,0 +1,15 @@
+syntax = "proto3";
+
+package ca.psiphon.psiphond;
+
+import "ca.psiphon.psiphond/base_params.proto";
+
+option go_package = "github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/server/pb/psiphond";
+
+message DSLRelayGetServerEntries {
+    optional ca.psiphon.psiphond.BaseParams base_params = 1;
+
+    // Fields 1-99 are reserved for field groupings.
+
+    repeated string server_entry_tags = 100;
+}

+ 3 - 0
psiphon/server/protobufConverter.go

@@ -58,6 +58,9 @@ var messageFieldGroups = map[string]FieldGroupConfig{
 	"inproxy_broker": {
 		BaseParams: true,
 	},
+	"dsl_relay_get_server_entries": {
+		BaseParams: true,
+	},
 }
 
 // routedMsg returns a new pointer to a populated Router protobuf message.