Просмотр исходного кода

Fix: wire up dsl_relay_get_server_entries with protobufs

Rod Hynes 1 месяц назад
Родитель
Сommit
61a4869b38

+ 13 - 13
psiphon/server/pb/psiphond/dsl_relay.pb.go

@@ -21,7 +21,7 @@ const (
 	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
 )
 
-type DSLRelayGetServerEntries struct {
+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"`
@@ -29,20 +29,20 @@ type DSLRelayGetServerEntries struct {
 	sizeCache       protoimpl.SizeCache
 }
 
-func (x *DSLRelayGetServerEntries) Reset() {
-	*x = DSLRelayGetServerEntries{}
+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 {
+func (x *DslRelayGetServerEntries) String() string {
 	return protoimpl.X.MessageStringOf(x)
 }
 
-func (*DSLRelayGetServerEntries) ProtoMessage() {}
+func (*DslRelayGetServerEntries) ProtoMessage() {}
 
-func (x *DSLRelayGetServerEntries) ProtoReflect() protoreflect.Message {
+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))
@@ -54,19 +54,19 @@ func (x *DSLRelayGetServerEntries) ProtoReflect() protoreflect.Message {
 	return mi.MessageOf(x)
 }
 
-// Deprecated: Use DSLRelayGetServerEntries.ProtoReflect.Descriptor instead.
-func (*DSLRelayGetServerEntries) Descriptor() ([]byte, []int) {
+// 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 {
+func (x *DslRelayGetServerEntries) GetBaseParams() *BaseParams {
 	if x != nil {
 		return x.BaseParams
 	}
 	return nil
 }
 
-func (x *DSLRelayGetServerEntries) GetServerEntryTags() []string {
+func (x *DslRelayGetServerEntries) GetServerEntryTags() []string {
 	if x != nil {
 		return x.ServerEntryTags
 	}
@@ -78,7 +78,7 @@ 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" +
+	"\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" +
@@ -98,11 +98,11 @@ func file_ca_psiphon_psiphond_dsl_relay_proto_rawDescGZIP() []byte {
 
 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
+	(*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, // 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

+ 28 - 7
psiphon/server/pb/psiphond/psiphond.pb.go

@@ -48,6 +48,7 @@ type Psiphond struct {
 	//	*Psiphond_Tactics
 	//	*Psiphond_TacticsSpeedtest
 	//	*Psiphond_UniqueUser
+	//	*Psiphond_DslRelayGetServerEntries
 	Metric        isPsiphond_Metric `protobuf_oneof:"metric"`
 	unknownFields protoimpl.UnknownFields
 	sizeCache     protoimpl.SizeCache
@@ -278,6 +279,15 @@ func (x *Psiphond) GetUniqueUser() *UniqueUser {
 	return nil
 }
 
+func (x *Psiphond) GetDslRelayGetServerEntries() *DslRelayGetServerEntries {
+	if x != nil {
+		if x, ok := x.Metric.(*Psiphond_DslRelayGetServerEntries); ok {
+			return x.DslRelayGetServerEntries
+		}
+	}
+	return nil
+}
+
 type isPsiphond_Metric interface {
 	isPsiphond_Metric()
 }
@@ -350,6 +360,10 @@ type Psiphond_UniqueUser struct {
 	UniqueUser *UniqueUser `protobuf:"bytes,117,opt,name=unique_user,json=uniqueUser,proto3,oneof"`
 }
 
+type Psiphond_DslRelayGetServerEntries struct {
+	DslRelayGetServerEntries *DslRelayGetServerEntries `protobuf:"bytes,120,opt,name=dsl_relay_get_server_entries,json=dslRelayGetServerEntries,proto3,oneof"`
+}
+
 func (*Psiphond_DomainBytes) isPsiphond_Metric() {}
 
 func (*Psiphond_FailedTunnel) isPsiphond_Metric() {}
@@ -384,11 +398,13 @@ func (*Psiphond_TacticsSpeedtest) isPsiphond_Metric() {}
 
 func (*Psiphond_UniqueUser) isPsiphond_Metric() {}
 
+func (*Psiphond_DslRelayGetServerEntries) isPsiphond_Metric() {}
+
 var File_ca_psiphon_psiphond_psiphond_proto protoreflect.FileDescriptor
 
 const file_ca_psiphon_psiphond_psiphond_proto_rawDesc = "" +
 	"\n" +
-	"\"ca.psiphon.psiphond/psiphond.proto\x12\x13ca.psiphon.psiphond\x1a\x1fgoogle/protobuf/timestamp.proto\x1a&ca.psiphon.psiphond/domain_bytes.proto\x1a'ca.psiphon.psiphond/failed_tunnel.proto\x1a(ca.psiphon.psiphond/inproxy_broker.proto\x1a*ca.psiphon.psiphond/irregular_tunnel.proto\x1a'ca.psiphon.psiphond/orphan_packet.proto\x1a,ca.psiphon.psiphond/remote_server_list.proto\x1a*ca.psiphon.psiphond/server_blocklist.proto\x1a%ca.psiphon.psiphond/server_load.proto\x1a&ca.psiphon.psiphond/server_panic.proto\x1a'ca.psiphon.psiphond/server_packet.proto\x1a'ca.psiphon.psiphond/server_tunnel.proto\x1a!ca.psiphon.psiphond/tactics.proto\x1a%ca.psiphon.psiphond/unique_user.proto\"\xfd\v\n" +
+	"\"ca.psiphon.psiphond/psiphond.proto\x12\x13ca.psiphon.psiphond\x1a\x1fgoogle/protobuf/timestamp.proto\x1a&ca.psiphon.psiphond/domain_bytes.proto\x1a'ca.psiphon.psiphond/failed_tunnel.proto\x1a(ca.psiphon.psiphond/inproxy_broker.proto\x1a*ca.psiphon.psiphond/irregular_tunnel.proto\x1a'ca.psiphon.psiphond/orphan_packet.proto\x1a,ca.psiphon.psiphond/remote_server_list.proto\x1a*ca.psiphon.psiphond/server_blocklist.proto\x1a%ca.psiphon.psiphond/server_load.proto\x1a&ca.psiphon.psiphond/server_panic.proto\x1a'ca.psiphon.psiphond/server_packet.proto\x1a'ca.psiphon.psiphond/server_tunnel.proto\x1a!ca.psiphon.psiphond/tactics.proto\x1a%ca.psiphon.psiphond/unique_user.proto\x1a#ca.psiphon.psiphond/dsl_relay.proto\"\xee\f\n" +
 	"\bPsiphond\x128\n" +
 	"\ttimestamp\x18\x01 \x01(\v2\x1a.google.protobuf.TimestampR\ttimestamp\x12\x17\n" +
 	"\ahost_id\x18\x02 \x01(\tR\x06hostId\x12\x1b\n" +
@@ -413,7 +429,8 @@ const file_ca_psiphon_psiphond_psiphond_proto_rawDesc = "" +
 	"\atactics\x18s \x01(\v2\x1c.ca.psiphon.psiphond.TacticsH\x00R\atactics\x12T\n" +
 	"\x11tactics_speedtest\x18t \x01(\v2%.ca.psiphon.psiphond.TacticsSpeedTestH\x00R\x10tacticsSpeedtest\x12B\n" +
 	"\vunique_user\x18u \x01(\v2\x1f.ca.psiphon.psiphond.UniqueUserH\x00R\n" +
-	"uniqueUserB\b\n" +
+	"uniqueUser\x12o\n" +
+	"\x1cdsl_relay_get_server_entries\x18x \x01(\v2-.ca.psiphon.psiphond.DslRelayGetServerEntriesH\x00R\x18dslRelayGetServerEntriesB\b\n" +
 	"\x06metricBHZFgithub.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/server/pb/psiphondb\x06proto3"
 
 var (
@@ -449,6 +466,7 @@ var file_ca_psiphon_psiphond_psiphond_proto_goTypes = []any{
 	(*Tactics)(nil),                  // 16: ca.psiphon.psiphond.Tactics
 	(*TacticsSpeedTest)(nil),         // 17: ca.psiphon.psiphond.TacticsSpeedTest
 	(*UniqueUser)(nil),               // 18: ca.psiphon.psiphond.UniqueUser
+	(*DslRelayGetServerEntries)(nil), // 19: ca.psiphon.psiphond.DslRelayGetServerEntries
 }
 var file_ca_psiphon_psiphond_psiphond_proto_depIdxs = []int32{
 	1,  // 0: ca.psiphon.psiphond.Psiphond.timestamp:type_name -> google.protobuf.Timestamp
@@ -469,11 +487,12 @@ var file_ca_psiphon_psiphond_psiphond_proto_depIdxs = []int32{
 	16, // 15: ca.psiphon.psiphond.Psiphond.tactics:type_name -> ca.psiphon.psiphond.Tactics
 	17, // 16: ca.psiphon.psiphond.Psiphond.tactics_speedtest:type_name -> ca.psiphon.psiphond.TacticsSpeedTest
 	18, // 17: ca.psiphon.psiphond.Psiphond.unique_user:type_name -> ca.psiphon.psiphond.UniqueUser
-	18, // [18:18] is the sub-list for method output_type
-	18, // [18:18] is the sub-list for method input_type
-	18, // [18:18] is the sub-list for extension type_name
-	18, // [18:18] is the sub-list for extension extendee
-	0,  // [0:18] is the sub-list for field type_name
+	19, // 18: ca.psiphon.psiphond.Psiphond.dsl_relay_get_server_entries:type_name -> ca.psiphon.psiphond.DslRelayGetServerEntries
+	19, // [19:19] is the sub-list for method output_type
+	19, // [19:19] is the sub-list for method input_type
+	19, // [19:19] is the sub-list for extension type_name
+	19, // [19:19] is the sub-list for extension extendee
+	0,  // [0:19] is the sub-list for field type_name
 }
 
 func init() { file_ca_psiphon_psiphond_psiphond_proto_init() }
@@ -494,6 +513,7 @@ func file_ca_psiphon_psiphond_psiphond_proto_init() {
 	file_ca_psiphon_psiphond_server_tunnel_proto_init()
 	file_ca_psiphon_psiphond_tactics_proto_init()
 	file_ca_psiphon_psiphond_unique_user_proto_init()
+	file_ca_psiphon_psiphond_dsl_relay_proto_init()
 	file_ca_psiphon_psiphond_psiphond_proto_msgTypes[0].OneofWrappers = []any{
 		(*Psiphond_DomainBytes)(nil),
 		(*Psiphond_FailedTunnel)(nil),
@@ -512,6 +532,7 @@ func file_ca_psiphon_psiphond_psiphond_proto_init() {
 		(*Psiphond_Tactics)(nil),
 		(*Psiphond_TacticsSpeedtest)(nil),
 		(*Psiphond_UniqueUser)(nil),
+		(*Psiphond_DslRelayGetServerEntries)(nil),
 	}
 	type x struct{}
 	out := protoimpl.TypeBuilder{

+ 1 - 1
psiphon/server/proto/ca.psiphon.psiphond/dsl_relay.proto

@@ -6,7 +6,7 @@ import "ca.psiphon.psiphond/base_params.proto";
 
 option go_package = "github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/server/pb/psiphond";
 
-message DSLRelayGetServerEntries {
+message DslRelayGetServerEntries {
     optional ca.psiphon.psiphond.BaseParams base_params = 1;
 
     // Fields 1-99 are reserved for field groupings.

+ 2 - 0
psiphon/server/proto/ca.psiphon.psiphond/psiphond.proto

@@ -16,6 +16,7 @@ import "ca.psiphon.psiphond/server_packet.proto";
 import "ca.psiphon.psiphond/server_tunnel.proto";
 import "ca.psiphon.psiphond/tactics.proto";
 import "ca.psiphon.psiphond/unique_user.proto";
+import "ca.psiphon.psiphond/dsl_relay.proto";
 
 option go_package = "github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/server/pb/psiphond";
 
@@ -45,5 +46,6 @@ message Psiphond {
     ca.psiphon.psiphond.Tactics tactics = 115;
     ca.psiphon.psiphond.TacticsSpeedTest tactics_speedtest = 116;
     ca.psiphon.psiphond.UniqueUser unique_user = 117;
+    ca.psiphon.psiphond.DslRelayGetServerEntries dsl_relay_get_server_entries = 120;
   }
 }

+ 4 - 0
psiphon/server/protobufConverter.go

@@ -327,6 +327,10 @@ func logFieldsToProtobuf(logFields LogFields) []*pbr.Router {
 		msg := &pb.ServerBlocklistHit{}
 		protobufPopulateMessage(logFields, msg, eventName)
 		psiphondWrapped.Metric = &pb.Psiphond_ServerBlocklist{ServerBlocklist: msg}
+	case "dsl_relay_get_server_entries":
+		msg := &pb.DslRelayGetServerEntries{}
+		protobufPopulateMessage(logFields, msg, eventName)
+		psiphondWrapped.Metric = &pb.Psiphond_DslRelayGetServerEntries{DslRelayGetServerEntries: msg}
 	}
 
 	// Single append for all non-special cases.

+ 8 - 0
psiphon/server/server_test.go

@@ -2535,6 +2535,14 @@ func runServer(t *testing.T, runConfig *runServerConfig) {
 		}
 	}
 
+	// Emit a dummy DSL relay cached request log to check that the event is
+	// properly wired up in protobuf mode.
+	//
+	// Currently the DSL test here doesn't exercise relay cached requests; see
+	// common/dsl/dsl_test.go for unit test coverage.
+
+	CommonLogger(log).LogMetric("dsl_relay_get_server_entries", common.LogFields{})
+
 	// Check that datastore had retained/pruned server entries as expected.
 	checkPruneServerEntriesTest(t, runConfig, testDataDirName, pruneServerEntryTestCases)