diff --git a/assets/ClientConf2.dev b/assets/ClientConf2.dev new file mode 100644 index 00000000..e13d9f44 Binary files /dev/null and b/assets/ClientConf2.dev differ diff --git a/protobuf/Makefile b/protobuf/Makefile index ce96b121..a2b87b46 100644 --- a/protobuf/Makefile +++ b/protobuf/Makefile @@ -26,3 +26,10 @@ all: protoc --go_out=./ --go_opt=M"signalling.proto=./;tdproto" signalling.proto +client2: + protoc --go_out=./ \ + --go_opt=M"clientconf.proto=./;tdproto" \ + --go_opt=M"signalling.proto=./;tdproto" \ + clientconf.proto signalling.proto +clean: + rm clientconf.pb.go signalling.pb.go \ No newline at end of file diff --git a/protobuf/clientconf.pb.go b/protobuf/clientconf.pb.go new file mode 100644 index 00000000..bbe9b415 --- /dev/null +++ b/protobuf/clientconf.pb.go @@ -0,0 +1,827 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.21.2 +// source: clientconf.proto + +package tdproto + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +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 RegistrarType int32 + +const ( + RegistrarType_REGISTRAR_TYPE_UNKNOWN RegistrarType = 0 + RegistrarType_REGISTRAR_TYPE_API RegistrarType = 1 + RegistrarType_REGISTRAR_TYPE_DECOY RegistrarType = 2 + RegistrarType_REGISTRAR_TYPE_DNS RegistrarType = 3 +) + +// Enum value maps for RegistrarType. +var ( + RegistrarType_name = map[int32]string{ + 0: "REGISTRAR_TYPE_UNKNOWN", + 1: "REGISTRAR_TYPE_API", + 2: "REGISTRAR_TYPE_DECOY", + 3: "REGISTRAR_TYPE_DNS", + } + RegistrarType_value = map[string]int32{ + "REGISTRAR_TYPE_UNKNOWN": 0, + "REGISTRAR_TYPE_API": 1, + "REGISTRAR_TYPE_DECOY": 2, + "REGISTRAR_TYPE_DNS": 3, + } +) + +func (x RegistrarType) Enum() *RegistrarType { + p := new(RegistrarType) + *p = x + return p +} + +func (x RegistrarType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (RegistrarType) Descriptor() protoreflect.EnumDescriptor { + return file_clientconf_proto_enumTypes[0].Descriptor() +} + +func (RegistrarType) Type() protoreflect.EnumType { + return &file_clientconf_proto_enumTypes[0] +} + +func (x RegistrarType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Do not use. +func (x *RegistrarType) UnmarshalJSON(b []byte) error { + num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) + if err != nil { + return err + } + *x = RegistrarType(num) + return nil +} + +// Deprecated: Use RegistrarType.Descriptor instead. +func (RegistrarType) EnumDescriptor() ([]byte, []int) { + return file_clientconf_proto_rawDescGZIP(), []int{0} +} + +type RegistrarDNSProtocol int32 + +const ( + RegistrarDNSProtocol_REGISTRAR_DNS_PROTOCOL_UNKNOWN RegistrarDNSProtocol = 0 + RegistrarDNSProtocol_REGISTRAR_DNS_PROTOCOL_UDP RegistrarDNSProtocol = 1 + RegistrarDNSProtocol_REGISTRAR_DNS_PROTOCOL_DOH RegistrarDNSProtocol = 2 + RegistrarDNSProtocol_REGISTRAR_DNS_PROTOCOL_DOT RegistrarDNSProtocol = 3 +) + +// Enum value maps for RegistrarDNSProtocol. +var ( + RegistrarDNSProtocol_name = map[int32]string{ + 0: "REGISTRAR_DNS_PROTOCOL_UNKNOWN", + 1: "REGISTRAR_DNS_PROTOCOL_UDP", + 2: "REGISTRAR_DNS_PROTOCOL_DOH", + 3: "REGISTRAR_DNS_PROTOCOL_DOT", + } + RegistrarDNSProtocol_value = map[string]int32{ + "REGISTRAR_DNS_PROTOCOL_UNKNOWN": 0, + "REGISTRAR_DNS_PROTOCOL_UDP": 1, + "REGISTRAR_DNS_PROTOCOL_DOH": 2, + "REGISTRAR_DNS_PROTOCOL_DOT": 3, + } +) + +func (x RegistrarDNSProtocol) Enum() *RegistrarDNSProtocol { + p := new(RegistrarDNSProtocol) + *p = x + return p +} + +func (x RegistrarDNSProtocol) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (RegistrarDNSProtocol) Descriptor() protoreflect.EnumDescriptor { + return file_clientconf_proto_enumTypes[1].Descriptor() +} + +func (RegistrarDNSProtocol) Type() protoreflect.EnumType { + return &file_clientconf_proto_enumTypes[1] +} + +func (x RegistrarDNSProtocol) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Do not use. +func (x *RegistrarDNSProtocol) UnmarshalJSON(b []byte) error { + num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) + if err != nil { + return err + } + *x = RegistrarDNSProtocol(num) + return nil +} + +// Deprecated: Use RegistrarDNSProtocol.Descriptor instead. +func (RegistrarDNSProtocol) EnumDescriptor() ([]byte, []int) { + return file_clientconf_proto_rawDescGZIP(), []int{1} +} + +// Represents an individual config +type DeploymentConfig struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + DecoyList *DecoyList `protobuf:"bytes,1,opt,name=decoy_list,json=decoyList" json:"decoy_list,omitempty"` + Generation *uint32 `protobuf:"varint,2,opt,name=generation" json:"generation,omitempty"` + DefaultPubkey *PubKey `protobuf:"bytes,3,opt,name=default_pubkey,json=defaultPubkey" json:"default_pubkey,omitempty"` + PhantomSubnetsList *PhantomSubnetsList `protobuf:"bytes,4,opt,name=phantom_subnets_list,json=phantomSubnetsList" json:"phantom_subnets_list,omitempty"` + ConjurePubkey *PubKey `protobuf:"bytes,5,opt,name=conjure_pubkey,json=conjurePubkey" json:"conjure_pubkey,omitempty"` + VersionNumber *uint32 `protobuf:"varint,6,opt,name=version_number,json=versionNumber" json:"version_number,omitempty"` + SuportedTransports []TransportType `protobuf:"varint,7,rep,name=suported_transports,json=suportedTransports,enum=tapdance.TransportType" json:"suported_transports,omitempty"` + Registrars []*Registrar `protobuf:"bytes,8,rep,name=registrars" json:"registrars,omitempty"` +} + +func (x *DeploymentConfig) Reset() { + *x = DeploymentConfig{} + if protoimpl.UnsafeEnabled { + mi := &file_clientconf_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeploymentConfig) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeploymentConfig) ProtoMessage() {} + +func (x *DeploymentConfig) ProtoReflect() protoreflect.Message { + mi := &file_clientconf_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeploymentConfig.ProtoReflect.Descriptor instead. +func (*DeploymentConfig) Descriptor() ([]byte, []int) { + return file_clientconf_proto_rawDescGZIP(), []int{0} +} + +func (x *DeploymentConfig) GetDecoyList() *DecoyList { + if x != nil { + return x.DecoyList + } + return nil +} + +func (x *DeploymentConfig) GetGeneration() uint32 { + if x != nil && x.Generation != nil { + return *x.Generation + } + return 0 +} + +func (x *DeploymentConfig) GetDefaultPubkey() *PubKey { + if x != nil { + return x.DefaultPubkey + } + return nil +} + +func (x *DeploymentConfig) GetPhantomSubnetsList() *PhantomSubnetsList { + if x != nil { + return x.PhantomSubnetsList + } + return nil +} + +func (x *DeploymentConfig) GetConjurePubkey() *PubKey { + if x != nil { + return x.ConjurePubkey + } + return nil +} + +func (x *DeploymentConfig) GetVersionNumber() uint32 { + if x != nil && x.VersionNumber != nil { + return *x.VersionNumber + } + return 0 +} + +func (x *DeploymentConfig) GetSuportedTransports() []TransportType { + if x != nil { + return x.SuportedTransports + } + return nil +} + +func (x *DeploymentConfig) GetRegistrars() []*Registrar { + if x != nil { + return x.Registrars + } + return nil +} + +// Houses multiple deployment configs +type ClientConfig2 struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + VersionNumber *uint32 `protobuf:"varint,1,opt,name=version_number,json=versionNumber" json:"version_number,omitempty"` + DeploymentConfigs []*DeploymentConfig `protobuf:"bytes,2,rep,name=deployment_configs,json=deploymentConfigs" json:"deployment_configs,omitempty"` +} + +func (x *ClientConfig2) Reset() { + *x = ClientConfig2{} + if protoimpl.UnsafeEnabled { + mi := &file_clientconf_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ClientConfig2) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ClientConfig2) ProtoMessage() {} + +func (x *ClientConfig2) ProtoReflect() protoreflect.Message { + mi := &file_clientconf_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ClientConfig2.ProtoReflect.Descriptor instead. +func (*ClientConfig2) Descriptor() ([]byte, []int) { + return file_clientconf_proto_rawDescGZIP(), []int{1} +} + +func (x *ClientConfig2) GetVersionNumber() uint32 { + if x != nil && x.VersionNumber != nil { + return *x.VersionNumber + } + return 0 +} + +func (x *ClientConfig2) GetDeploymentConfigs() []*DeploymentConfig { + if x != nil { + return x.DeploymentConfigs + } + return nil +} + +type Registrar struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RegistrarType *RegistrarType `protobuf:"varint,1,opt,name=registrar_type,json=registrarType,enum=tapdance.RegistrarType" json:"registrar_type,omitempty"` + Bidirectional *bool `protobuf:"varint,2,opt,name=bidirectional" json:"bidirectional,omitempty"` // Expect response from registrar or not + DnsRegConfParams *DNSRegConf `protobuf:"bytes,10,opt,name=dns_reg_conf_params,json=dnsRegConfParams" json:"dns_reg_conf_params,omitempty"` + ApiRegConfParams *APIRegConf `protobuf:"bytes,20,opt,name=api_reg_conf_params,json=apiRegConfParams" json:"api_reg_conf_params,omitempty"` + DecoyRegConfParams *DecoyRegConf `protobuf:"bytes,30,opt,name=decoy_reg_conf_params,json=decoyRegConfParams" json:"decoy_reg_conf_params,omitempty"` +} + +func (x *Registrar) Reset() { + *x = Registrar{} + if protoimpl.UnsafeEnabled { + mi := &file_clientconf_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Registrar) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Registrar) ProtoMessage() {} + +func (x *Registrar) ProtoReflect() protoreflect.Message { + mi := &file_clientconf_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Registrar.ProtoReflect.Descriptor instead. +func (*Registrar) Descriptor() ([]byte, []int) { + return file_clientconf_proto_rawDescGZIP(), []int{2} +} + +func (x *Registrar) GetRegistrarType() RegistrarType { + if x != nil && x.RegistrarType != nil { + return *x.RegistrarType + } + return RegistrarType_REGISTRAR_TYPE_UNKNOWN +} + +func (x *Registrar) GetBidirectional() bool { + if x != nil && x.Bidirectional != nil { + return *x.Bidirectional + } + return false +} + +func (x *Registrar) GetDnsRegConfParams() *DNSRegConf { + if x != nil { + return x.DnsRegConfParams + } + return nil +} + +func (x *Registrar) GetApiRegConfParams() *APIRegConf { + if x != nil { + return x.ApiRegConfParams + } + return nil +} + +func (x *Registrar) GetDecoyRegConfParams() *DecoyRegConf { + if x != nil { + return x.DecoyRegConfParams + } + return nil +} + +type DNSRegConf struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + DnsRegMethod *RegistrarDNSProtocol `protobuf:"varint,1,req,name=dns_reg_method,json=dnsRegMethod,enum=tapdance.RegistrarDNSProtocol" json:"dns_reg_method,omitempty"` + UdpAddr *string `protobuf:"bytes,2,opt,name=udp_addr,json=udpAddr" json:"udp_addr,omitempty"` + DotAddr *string `protobuf:"bytes,3,opt,name=dot_addr,json=dotAddr" json:"dot_addr,omitempty"` + DohUrl *string `protobuf:"bytes,4,opt,name=doh_url,json=dohUrl" json:"doh_url,omitempty"` + Domain *string `protobuf:"bytes,5,req,name=domain" json:"domain,omitempty"` + Pubkey []byte `protobuf:"bytes,6,req,name=pubkey" json:"pubkey,omitempty"` + UtlsDistribution *string `protobuf:"bytes,7,opt,name=utls_distribution,json=utlsDistribution" json:"utls_distribution,omitempty"` + StunServer *string `protobuf:"bytes,8,opt,name=stun_server,json=stunServer" json:"stun_server,omitempty"` +} + +func (x *DNSRegConf) Reset() { + *x = DNSRegConf{} + if protoimpl.UnsafeEnabled { + mi := &file_clientconf_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DNSRegConf) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DNSRegConf) ProtoMessage() {} + +func (x *DNSRegConf) ProtoReflect() protoreflect.Message { + mi := &file_clientconf_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DNSRegConf.ProtoReflect.Descriptor instead. +func (*DNSRegConf) Descriptor() ([]byte, []int) { + return file_clientconf_proto_rawDescGZIP(), []int{3} +} + +func (x *DNSRegConf) GetDnsRegMethod() RegistrarDNSProtocol { + if x != nil && x.DnsRegMethod != nil { + return *x.DnsRegMethod + } + return RegistrarDNSProtocol_REGISTRAR_DNS_PROTOCOL_UNKNOWN +} + +func (x *DNSRegConf) GetUdpAddr() string { + if x != nil && x.UdpAddr != nil { + return *x.UdpAddr + } + return "" +} + +func (x *DNSRegConf) GetDotAddr() string { + if x != nil && x.DotAddr != nil { + return *x.DotAddr + } + return "" +} + +func (x *DNSRegConf) GetDohUrl() string { + if x != nil && x.DohUrl != nil { + return *x.DohUrl + } + return "" +} + +func (x *DNSRegConf) GetDomain() string { + if x != nil && x.Domain != nil { + return *x.Domain + } + return "" +} + +func (x *DNSRegConf) GetPubkey() []byte { + if x != nil { + return x.Pubkey + } + return nil +} + +func (x *DNSRegConf) GetUtlsDistribution() string { + if x != nil && x.UtlsDistribution != nil { + return *x.UtlsDistribution + } + return "" +} + +func (x *DNSRegConf) GetStunServer() string { + if x != nil && x.StunServer != nil { + return *x.StunServer + } + return "" +} + +type APIRegConf struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ApiUrl *string `protobuf:"bytes,1,opt,name=api_url,json=apiUrl" json:"api_url,omitempty"` +} + +func (x *APIRegConf) Reset() { + *x = APIRegConf{} + if protoimpl.UnsafeEnabled { + mi := &file_clientconf_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *APIRegConf) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*APIRegConf) ProtoMessage() {} + +func (x *APIRegConf) ProtoReflect() protoreflect.Message { + mi := &file_clientconf_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use APIRegConf.ProtoReflect.Descriptor instead. +func (*APIRegConf) Descriptor() ([]byte, []int) { + return file_clientconf_proto_rawDescGZIP(), []int{4} +} + +func (x *APIRegConf) GetApiUrl() string { + if x != nil && x.ApiUrl != nil { + return *x.ApiUrl + } + return "" +} + +type DecoyRegConf struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *DecoyRegConf) Reset() { + *x = DecoyRegConf{} + if protoimpl.UnsafeEnabled { + mi := &file_clientconf_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DecoyRegConf) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DecoyRegConf) ProtoMessage() {} + +func (x *DecoyRegConf) ProtoReflect() protoreflect.Message { + mi := &file_clientconf_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DecoyRegConf.ProtoReflect.Descriptor instead. +func (*DecoyRegConf) Descriptor() ([]byte, []int) { + return file_clientconf_proto_rawDescGZIP(), []int{5} +} + +var File_clientconf_proto protoreflect.FileDescriptor + +var file_clientconf_proto_rawDesc = []byte{ + 0x0a, 0x10, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x08, 0x74, 0x61, 0x70, 0x64, 0x61, 0x6e, 0x63, 0x65, 0x1a, 0x10, 0x73, 0x69, + 0x67, 0x6e, 0x61, 0x6c, 0x6c, 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xce, + 0x03, 0x0a, 0x10, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x12, 0x32, 0x0a, 0x0a, 0x64, 0x65, 0x63, 0x6f, 0x79, 0x5f, 0x6c, 0x69, 0x73, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x74, 0x61, 0x70, 0x64, 0x61, 0x6e, + 0x63, 0x65, 0x2e, 0x44, 0x65, 0x63, 0x6f, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x09, 0x64, 0x65, + 0x63, 0x6f, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x67, 0x65, 0x6e, 0x65, 0x72, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x67, 0x65, 0x6e, + 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x37, 0x0a, 0x0e, 0x64, 0x65, 0x66, 0x61, 0x75, + 0x6c, 0x74, 0x5f, 0x70, 0x75, 0x62, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x10, 0x2e, 0x74, 0x61, 0x70, 0x64, 0x61, 0x6e, 0x63, 0x65, 0x2e, 0x50, 0x75, 0x62, 0x4b, 0x65, + 0x79, 0x52, 0x0d, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x50, 0x75, 0x62, 0x6b, 0x65, 0x79, + 0x12, 0x4e, 0x0a, 0x14, 0x70, 0x68, 0x61, 0x6e, 0x74, 0x6f, 0x6d, 0x5f, 0x73, 0x75, 0x62, 0x6e, + 0x65, 0x74, 0x73, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, + 0x2e, 0x74, 0x61, 0x70, 0x64, 0x61, 0x6e, 0x63, 0x65, 0x2e, 0x50, 0x68, 0x61, 0x6e, 0x74, 0x6f, + 0x6d, 0x53, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x12, 0x70, 0x68, + 0x61, 0x6e, 0x74, 0x6f, 0x6d, 0x53, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x73, 0x4c, 0x69, 0x73, 0x74, + 0x12, 0x37, 0x0a, 0x0e, 0x63, 0x6f, 0x6e, 0x6a, 0x75, 0x72, 0x65, 0x5f, 0x70, 0x75, 0x62, 0x6b, + 0x65, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x74, 0x61, 0x70, 0x64, 0x61, + 0x6e, 0x63, 0x65, 0x2e, 0x50, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x52, 0x0d, 0x63, 0x6f, 0x6e, 0x6a, + 0x75, 0x72, 0x65, 0x50, 0x75, 0x62, 0x6b, 0x65, 0x79, 0x12, 0x25, 0x0a, 0x0e, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x0d, 0x52, 0x0d, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, + 0x12, 0x48, 0x0a, 0x13, 0x73, 0x75, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x72, 0x61, + 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x17, 0x2e, + 0x74, 0x61, 0x70, 0x64, 0x61, 0x6e, 0x63, 0x65, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, + 0x72, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x12, 0x73, 0x75, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64, + 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x12, 0x33, 0x0a, 0x0a, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x72, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, + 0x2e, 0x74, 0x61, 0x70, 0x64, 0x61, 0x6e, 0x63, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x72, 0x61, 0x72, 0x52, 0x0a, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x72, 0x73, 0x22, + 0x81, 0x01, 0x0a, 0x0d, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x32, 0x12, 0x25, 0x0a, 0x0e, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x75, 0x6d, + 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x49, 0x0a, 0x12, 0x64, 0x65, 0x70, 0x6c, + 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x18, 0x02, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x74, 0x61, 0x70, 0x64, 0x61, 0x6e, 0x63, 0x65, 0x2e, + 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x52, 0x11, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x73, 0x22, 0xc6, 0x02, 0x0a, 0x09, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, + 0x72, 0x12, 0x3e, 0x0a, 0x0e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x72, 0x5f, 0x74, + 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x74, 0x61, 0x70, 0x64, + 0x61, 0x6e, 0x63, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x72, 0x54, 0x79, + 0x70, 0x65, 0x52, 0x0d, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x72, 0x54, 0x79, 0x70, + 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x62, 0x69, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x62, 0x69, 0x64, 0x69, 0x72, 0x65, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x12, 0x43, 0x0a, 0x13, 0x64, 0x6e, 0x73, 0x5f, 0x72, + 0x65, 0x67, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x0a, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x74, 0x61, 0x70, 0x64, 0x61, 0x6e, 0x63, 0x65, 0x2e, + 0x44, 0x4e, 0x53, 0x52, 0x65, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x52, 0x10, 0x64, 0x6e, 0x73, 0x52, + 0x65, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x43, 0x0a, 0x13, + 0x61, 0x70, 0x69, 0x5f, 0x72, 0x65, 0x67, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x5f, 0x70, 0x61, 0x72, + 0x61, 0x6d, 0x73, 0x18, 0x14, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x74, 0x61, 0x70, 0x64, + 0x61, 0x6e, 0x63, 0x65, 0x2e, 0x41, 0x50, 0x49, 0x52, 0x65, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x52, + 0x10, 0x61, 0x70, 0x69, 0x52, 0x65, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x50, 0x61, 0x72, 0x61, 0x6d, + 0x73, 0x12, 0x49, 0x0a, 0x15, 0x64, 0x65, 0x63, 0x6f, 0x79, 0x5f, 0x72, 0x65, 0x67, 0x5f, 0x63, + 0x6f, 0x6e, 0x66, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x16, 0x2e, 0x74, 0x61, 0x70, 0x64, 0x61, 0x6e, 0x63, 0x65, 0x2e, 0x44, 0x65, 0x63, 0x6f, + 0x79, 0x52, 0x65, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x52, 0x12, 0x64, 0x65, 0x63, 0x6f, 0x79, 0x52, + 0x65, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x9f, 0x02, 0x0a, + 0x0a, 0x44, 0x4e, 0x53, 0x52, 0x65, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x12, 0x44, 0x0a, 0x0e, 0x64, + 0x6e, 0x73, 0x5f, 0x72, 0x65, 0x67, 0x5f, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, + 0x02, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x74, 0x61, 0x70, 0x64, 0x61, 0x6e, 0x63, 0x65, 0x2e, 0x52, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x72, 0x44, 0x4e, 0x53, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x63, 0x6f, 0x6c, 0x52, 0x0c, 0x64, 0x6e, 0x73, 0x52, 0x65, 0x67, 0x4d, 0x65, 0x74, 0x68, 0x6f, + 0x64, 0x12, 0x19, 0x0a, 0x08, 0x75, 0x64, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x75, 0x64, 0x70, 0x41, 0x64, 0x64, 0x72, 0x12, 0x19, 0x0a, 0x08, + 0x64, 0x6f, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x64, 0x6f, 0x74, 0x41, 0x64, 0x64, 0x72, 0x12, 0x17, 0x0a, 0x07, 0x64, 0x6f, 0x68, 0x5f, 0x75, + 0x72, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, 0x68, 0x55, 0x72, 0x6c, + 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x05, 0x20, 0x02, 0x28, 0x09, + 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x75, 0x62, 0x6b, + 0x65, 0x79, 0x18, 0x06, 0x20, 0x02, 0x28, 0x0c, 0x52, 0x06, 0x70, 0x75, 0x62, 0x6b, 0x65, 0x79, + 0x12, 0x2b, 0x0a, 0x11, 0x75, 0x74, 0x6c, 0x73, 0x5f, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, + 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x75, 0x74, 0x6c, + 0x73, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, + 0x0b, 0x73, 0x74, 0x75, 0x6e, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x08, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0a, 0x73, 0x74, 0x75, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x22, 0x25, + 0x0a, 0x0a, 0x41, 0x50, 0x49, 0x52, 0x65, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x12, 0x17, 0x0a, 0x07, + 0x61, 0x70, 0x69, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, + 0x70, 0x69, 0x55, 0x72, 0x6c, 0x22, 0x0e, 0x0a, 0x0c, 0x44, 0x65, 0x63, 0x6f, 0x79, 0x52, 0x65, + 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x2a, 0x75, 0x0a, 0x0d, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x61, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x16, 0x52, 0x45, 0x47, 0x49, 0x53, 0x54, + 0x52, 0x41, 0x52, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, + 0x10, 0x00, 0x12, 0x16, 0x0a, 0x12, 0x52, 0x45, 0x47, 0x49, 0x53, 0x54, 0x52, 0x41, 0x52, 0x5f, + 0x54, 0x59, 0x50, 0x45, 0x5f, 0x41, 0x50, 0x49, 0x10, 0x01, 0x12, 0x18, 0x0a, 0x14, 0x52, 0x45, + 0x47, 0x49, 0x53, 0x54, 0x52, 0x41, 0x52, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x44, 0x45, 0x43, + 0x4f, 0x59, 0x10, 0x02, 0x12, 0x16, 0x0a, 0x12, 0x52, 0x45, 0x47, 0x49, 0x53, 0x54, 0x52, 0x41, + 0x52, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x44, 0x4e, 0x53, 0x10, 0x03, 0x2a, 0x9a, 0x01, 0x0a, + 0x14, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x72, 0x44, 0x4e, 0x53, 0x50, 0x72, 0x6f, + 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x22, 0x0a, 0x1e, 0x52, 0x45, 0x47, 0x49, 0x53, 0x54, 0x52, + 0x41, 0x52, 0x5f, 0x44, 0x4e, 0x53, 0x5f, 0x50, 0x52, 0x4f, 0x54, 0x4f, 0x43, 0x4f, 0x4c, 0x5f, + 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x1e, 0x0a, 0x1a, 0x52, 0x45, 0x47, + 0x49, 0x53, 0x54, 0x52, 0x41, 0x52, 0x5f, 0x44, 0x4e, 0x53, 0x5f, 0x50, 0x52, 0x4f, 0x54, 0x4f, + 0x43, 0x4f, 0x4c, 0x5f, 0x55, 0x44, 0x50, 0x10, 0x01, 0x12, 0x1e, 0x0a, 0x1a, 0x52, 0x45, 0x47, + 0x49, 0x53, 0x54, 0x52, 0x41, 0x52, 0x5f, 0x44, 0x4e, 0x53, 0x5f, 0x50, 0x52, 0x4f, 0x54, 0x4f, + 0x43, 0x4f, 0x4c, 0x5f, 0x44, 0x4f, 0x48, 0x10, 0x02, 0x12, 0x1e, 0x0a, 0x1a, 0x52, 0x45, 0x47, + 0x49, 0x53, 0x54, 0x52, 0x41, 0x52, 0x5f, 0x44, 0x4e, 0x53, 0x5f, 0x50, 0x52, 0x4f, 0x54, 0x4f, + 0x43, 0x4f, 0x4c, 0x5f, 0x44, 0x4f, 0x54, 0x10, 0x03, 0x42, 0x09, 0x5a, 0x07, 0x74, 0x64, 0x70, + 0x72, 0x6f, 0x74, 0x6f, +} + +var ( + file_clientconf_proto_rawDescOnce sync.Once + file_clientconf_proto_rawDescData = file_clientconf_proto_rawDesc +) + +func file_clientconf_proto_rawDescGZIP() []byte { + file_clientconf_proto_rawDescOnce.Do(func() { + file_clientconf_proto_rawDescData = protoimpl.X.CompressGZIP(file_clientconf_proto_rawDescData) + }) + return file_clientconf_proto_rawDescData +} + +var file_clientconf_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_clientconf_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_clientconf_proto_goTypes = []interface{}{ + (RegistrarType)(0), // 0: tapdance.RegistrarType + (RegistrarDNSProtocol)(0), // 1: tapdance.RegistrarDNSProtocol + (*DeploymentConfig)(nil), // 2: tapdance.DeploymentConfig + (*ClientConfig2)(nil), // 3: tapdance.ClientConfig2 + (*Registrar)(nil), // 4: tapdance.Registrar + (*DNSRegConf)(nil), // 5: tapdance.DNSRegConf + (*APIRegConf)(nil), // 6: tapdance.APIRegConf + (*DecoyRegConf)(nil), // 7: tapdance.DecoyRegConf + (*DecoyList)(nil), // 8: tapdance.DecoyList + (*PubKey)(nil), // 9: tapdance.PubKey + (*PhantomSubnetsList)(nil), // 10: tapdance.PhantomSubnetsList + (TransportType)(0), // 11: tapdance.TransportType +} +var file_clientconf_proto_depIdxs = []int32{ + 8, // 0: tapdance.DeploymentConfig.decoy_list:type_name -> tapdance.DecoyList + 9, // 1: tapdance.DeploymentConfig.default_pubkey:type_name -> tapdance.PubKey + 10, // 2: tapdance.DeploymentConfig.phantom_subnets_list:type_name -> tapdance.PhantomSubnetsList + 9, // 3: tapdance.DeploymentConfig.conjure_pubkey:type_name -> tapdance.PubKey + 11, // 4: tapdance.DeploymentConfig.suported_transports:type_name -> tapdance.TransportType + 4, // 5: tapdance.DeploymentConfig.registrars:type_name -> tapdance.Registrar + 2, // 6: tapdance.ClientConfig2.deployment_configs:type_name -> tapdance.DeploymentConfig + 0, // 7: tapdance.Registrar.registrar_type:type_name -> tapdance.RegistrarType + 5, // 8: tapdance.Registrar.dns_reg_conf_params:type_name -> tapdance.DNSRegConf + 6, // 9: tapdance.Registrar.api_reg_conf_params:type_name -> tapdance.APIRegConf + 7, // 10: tapdance.Registrar.decoy_reg_conf_params:type_name -> tapdance.DecoyRegConf + 1, // 11: tapdance.DNSRegConf.dns_reg_method:type_name -> tapdance.RegistrarDNSProtocol + 12, // [12:12] is the sub-list for method output_type + 12, // [12:12] is the sub-list for method input_type + 12, // [12:12] is the sub-list for extension type_name + 12, // [12:12] is the sub-list for extension extendee + 0, // [0:12] is the sub-list for field type_name +} + +func init() { file_clientconf_proto_init() } +func file_clientconf_proto_init() { + if File_clientconf_proto != nil { + return + } + file_signalling_proto_init() + if !protoimpl.UnsafeEnabled { + file_clientconf_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeploymentConfig); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_clientconf_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ClientConfig2); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_clientconf_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Registrar); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_clientconf_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DNSRegConf); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_clientconf_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*APIRegConf); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_clientconf_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DecoyRegConf); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_clientconf_proto_rawDesc, + NumEnums: 2, + NumMessages: 6, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_clientconf_proto_goTypes, + DependencyIndexes: file_clientconf_proto_depIdxs, + EnumInfos: file_clientconf_proto_enumTypes, + MessageInfos: file_clientconf_proto_msgTypes, + }.Build() + File_clientconf_proto = out.File + file_clientconf_proto_rawDesc = nil + file_clientconf_proto_goTypes = nil + file_clientconf_proto_depIdxs = nil +} diff --git a/protobuf/clientconf.proto b/protobuf/clientconf.proto new file mode 100644 index 00000000..4399f285 --- /dev/null +++ b/protobuf/clientconf.proto @@ -0,0 +1,67 @@ +syntax = "proto2"; + +package tapdance; + +import "signalling.proto"; + +option go_package = "tdproto"; + +// Represents an individual config +message DeploymentConfig { + optional DecoyList decoy_list = 1; + optional uint32 generation = 2; + optional PubKey default_pubkey = 3; + optional PhantomSubnetsList phantom_subnets_list = 4; + optional PubKey conjure_pubkey = 5; + optional uint32 version_number = 6; + repeated TransportType suported_transports = 7; + repeated Registrar registrars = 8; +} + +// Houses multiple deployment configs +message ClientConfig2 { + optional uint32 version_number = 1; + repeated DeploymentConfig deployment_configs = 2; +} + +message Registrar { + optional RegistrarType registrar_type = 1; + optional bool bidirectional = 2; // Expect response from registrar or not + + optional DNSRegConf dns_reg_conf_params = 10; + + optional APIRegConf api_reg_conf_params = 20; + + optional DecoyRegConf decoy_reg_conf_params = 30; +} + +enum RegistrarType { + REGISTRAR_TYPE_UNKNOWN = 0; + REGISTRAR_TYPE_API = 1; + REGISTRAR_TYPE_DECOY = 2; + REGISTRAR_TYPE_DNS = 3; +} + +enum RegistrarDNSProtocol { + REGISTRAR_DNS_PROTOCOL_UNKNOWN = 0; + REGISTRAR_DNS_PROTOCOL_UDP = 1; + REGISTRAR_DNS_PROTOCOL_DOH = 2; + REGISTRAR_DNS_PROTOCOL_DOT = 3; +} + +message DNSRegConf { + required RegistrarDNSProtocol dns_reg_method = 1; + optional string udp_addr = 2; + optional string dot_addr = 3; + optional string doh_url = 4; + required string domain = 5; + required bytes pubkey = 6; + optional string utls_distribution = 7; + optional string stun_server = 8; +} + +message APIRegConf { + optional string api_url = 1; +} + +message DecoyRegConf {} diff --git a/tools/clientconf/clientconf.go b/tools/clientconf/clientconf.go index 84c6372c..0bcda8c3 100644 --- a/tools/clientconf/clientconf.go +++ b/tools/clientconf/clientconf.go @@ -101,6 +101,9 @@ func updateDecoy(decoy *pb.TLSDecoySpec, host string, ip string, pubkey string, } } if pubkey != "" { + if decoy.Pubkey == nil { + decoy.Pubkey = &pb.PubKey{} + } decoy.Pubkey.Key = parsePubkey(pubkey) } if delpubkey { @@ -114,6 +117,7 @@ func updateDecoy(decoy *pb.TLSDecoySpec, host string, ip string, pubkey string, t := uint32(tcpwin) decoy.Tcpwin = &t } + } func addSubnets(subnets []string, weight *uint, clientConf *pb.ClientConf) { @@ -127,7 +131,7 @@ func addSubnets(subnets []string, weight *uint, clientConf *pb.ClientConf) { } } var weight32 = uint32(*weight) - + // add new item to PhantomSubnetsList.WeightedSubnets var newPhantomSubnet = pb.PhantomSubnets{ Weight: &weight32, diff --git a/tools/clientconf2/clientconf2.go b/tools/clientconf2/clientconf2.go new file mode 100644 index 00000000..0fecdf90 --- /dev/null +++ b/tools/clientconf2/clientconf2.go @@ -0,0 +1,619 @@ +package main + +import ( + "encoding/binary" + "encoding/hex" + "flag" + "fmt" + "io/ioutil" + "log" + "net" + "strings" + + "github.com/golang/protobuf/proto" + toml "github.com/pelletier/go-toml" + pb "github.com/refraction-networking/gotapdance/protobuf" +) + +// Track all cmdline parameters in struct +type flagValues struct { + fname, out_fname, pubkey, cjPubkey, host, ip, add_subnets, subnet_file, registrar_type, registrar_host, registrar_file string + generation, del_decoy, update_decoy, update_config, del_config, timeout, tcpwin, delete_subnet, update_registrar, del_registrar int + delpubkey, add_decoy, add_config, all_decoys, add_registrar, reg_bidir, noout bool + weight uint +} + +func parseCmdLineFlags() *flagValues { + var fname = flag.String("f", "", "`ClientConf2` file to parse") + var out_fname = flag.String("o", "", "`output` file name to write new/modified config") + var generation = flag.Int("generation", 0, "New/modified generation") + var pubkey = flag.String("pubkey", "", "New/modified (decoy) pubkey. If -add or -update, applies to specific decoy. If -all applies to all decoys. Otherwise, applies to default pubkey.") + var cjPubkey = flag.String("cjpubkey", "", "New/modified (decoy) conjure pubkey. If -add or -update, applies to specific decoy. If -all applies to all decoys. Otherwise, applies to default pubkey.") + var delpubkey = flag.Bool("delpubkey", false, "Delete pubkey from decoy with `index` specified in -update (or from all decoys if -all)") + + var add_decoy = flag.Bool("add-decoy", false, "If set, modify fields of all decoys in list with provided pubkey/timeout/tcpwin/host/ip") + var del_decoy = flag.Int("del-decoy", -1, "Specifies `index` of decoy to delete") + var update_decoy = flag.Int("update-decoy", -1, "Specifies `index` of decoy to update") + var update_config = flag.Int("update-config", -1, "Specifies `index` of deployment config to update") + var add_config = flag.Bool("add-config", false, "If set, creates new decoy and appends to decoy list. Can 'initialize' values by setting -pubkey, -generation, etc. flags.") + var del_config = flag.Int("del-config", -1, "Specifies `index` of deployment config to delete") + + var host = flag.String("host", "", "New/modified decoy host") + var ip = flag.String("ip", "", "New/modified IP address") + var timeout = flag.Int("timeout", 0, "New/modified timeout") + var tcpwin = flag.Int("tcpwin", 0, "New/modified tcpwin") + + var add_subnets = flag.String("add-subnets", "", "Add a subnet or list of space-separated subnets between double quotes (\"127.0.0.1/24 2001::/32\" etc.), requires additional weight flag") + var delete_subnet = flag.Int("delete-subnet", -1, "Specifies the `index` of a subnet to delete") + var weight = flag.Uint("weight", 0, "Subnet weight when add-subnets is used") + var subnet_file = flag.String("subnet-file", "", "Path to TOML file containing lists of subnets to use in config. TOML should be formatted like: \n"+ + "[[WeightedSubnets]] \n\tWeight = 9 \n\tSubnets = [\"192.122.190.0/24\", \"2001:48a8:687f:1::/64\"] \n"+ + "[[WeightedSubnets]] \n\tWeight = 1 \n\tSubnets = [\"141.219.0.0/16\", \"35.8.0.0/16\"]", + ) + var all_decoys = flag.Bool("all-decoys", false, "If set, replace all pubkeys/timeouts/tcpwins in decoy list with pubkey/timeout/tcpwin if provided") + + var add_registrar = flag.Bool("add-registrar", false, "If set, adds a registrar, requires -registrar-type and -registrar-host") + var update_registrar = flag.Int("update-registrar", -1, "Specifies `index` of registrar to update") + var del_registrar = flag.Int("del-registrar", -1, "Specifies `index` of registrar to remove") + var registrar_type = flag.String("registrar-type", "", "Set registrar type ``") + var reg_bidir = flag.Bool("registrar-bidir", false, "Specifies whether registrar is bidirectional") + var registrar_file = flag.String("registrar-file", "", "Path to TOML file containing DNS/API/Decoy parameters") + + var noout = flag.Bool("noout", false, "Don't print ClientConf") + + flag.Parse() + + return &flagValues{ + fname: *fname, + out_fname: *out_fname, + pubkey: *pubkey, + cjPubkey: *cjPubkey, + host: *host, + ip: *ip, + add_subnets: *add_subnets, + subnet_file: *subnet_file, + generation: *generation, + del_decoy: *del_decoy, + update_decoy: *update_decoy, + update_config: *update_config, + add_config: *add_config, + del_config: *del_config, + timeout: *timeout, + tcpwin: *tcpwin, + delete_subnet: *delete_subnet, + delpubkey: *delpubkey, + add_decoy: *add_decoy, + all_decoys: *all_decoys, + noout: *noout, + weight: *weight, + add_registrar: *add_registrar, + update_registrar: *update_registrar, + del_registrar: *del_registrar, + registrar_type: *registrar_type, + reg_bidir: *reg_bidir, + registrar_file: *registrar_file, + } +} + +func printClientConf(clientConf *pb.ClientConfig2) { + // ClientConfig2 wrapper info + fmt.Println("ClientConfig2") + fmt.Println("Version number:", clientConf.GetVersionNumber()) + for i, conf := range clientConf.DeploymentConfigs { + fmt.Println() + decoyHeader := fmt.Sprintf("Deployment Config %d", i) + fmt.Println(decoyHeader) + fmt.Println(strings.Repeat("=", 80)) // 80 = std terminal width + fmt.Println() + printDeployConf(conf) + } +} + +func printDeployConf(deployConf *pb.DeploymentConfig) { + fmt.Printf("Generation: %d\n", deployConf.GetGeneration()) + if deployConf.GetDefaultPubkey() != nil { + fmt.Printf("Default Pubkey: %s\n", hex.EncodeToString(deployConf.GetDefaultPubkey().Key[:])) + } + if deployConf.GetConjurePubkey() != nil { + fmt.Printf("Conjure Pubkey: %s\n", hex.EncodeToString(deployConf.GetConjurePubkey().Key[:])) + } + if deployConf.DecoyList == nil { + return + } + decoys := deployConf.DecoyList.TlsDecoys + fmt.Printf("Decoy List: %d decoys\n", len(decoys)) + for i, decoy := range decoys { + ip := make(net.IP, 4) + binary.BigEndian.PutUint32(ip, decoy.GetIpv4Addr()) + ip6 := net.IP(decoy.GetIpv6Addr()) + fmt.Printf("%d:\n %s (%s / [%s])\n", i, decoy.GetHostname(), ip.To4().String(), ip6.To16().String()) + if decoy.GetPubkey() != nil { + fmt.Printf(" pubkey: %s\n", hex.EncodeToString(decoy.GetPubkey().Key[:])) + } + if decoy.GetTimeout() != 0 { + fmt.Printf(" timeout: %d ms\n", decoy.GetTimeout()) + } + if decoy.GetTcpwin() != 0 { + fmt.Printf(" tcpwin: %d bytes\n", decoy.GetTcpwin()) + } + } + + phantoms := deployConf.GetPhantomSubnetsList() + if phantoms != nil { + fmt.Printf("\nPhantom Subnets List:\n") + var index uint = 0 + for _, block := range phantoms.GetWeightedSubnets() { + fmt.Printf("\nweight: %d, subnets:\n", block.GetWeight()) + for _, subnet := range block.GetSubnets() { + fmt.Printf(" %d: %s\n", index, subnet) + index++ + } + } + } + + registrars := deployConf.GetRegistrars() + if registrars != nil { + fmt.Printf("\nRegistrars:\n") + for i, reg := range registrars { + fmt.Printf("%d:\n", i) + fmt.Printf(" Bidirectional: %t\n", reg.GetBidirectional()) + + var reg_type string + switch reg.GetRegistrarType() { + case pb.RegistrarType_REGISTRAR_TYPE_UNKNOWN: + reg_type = "unknown" + case pb.RegistrarType_REGISTRAR_TYPE_API: + reg_type = "api" + case pb.RegistrarType_REGISTRAR_TYPE_DECOY: + reg_type = "decoy" + case pb.RegistrarType_REGISTRAR_TYPE_DNS: + reg_type = "dns" + default: + log.Fatalf("unknown DNS protocol type %s", reg_type) + } + fmt.Printf(" Type: %s\n", reg_type) + + api_params := reg.GetApiRegConfParams() + if api_params != nil && api_params.GetApiUrl() != "" { + fmt.Printf(" %s params:\n", reg_type) + fmt.Printf(" API URL: %s\n", api_params.GetApiUrl()) + } + + // Decoy message empty, nothing to do + //decoy_params := reg.GetDecoyRegConfParams() + //if decoy_params != nil { + // // pass + //} + + dns_params := reg.GetDnsRegConfParams() + if dns_params != nil { + fmt.Printf(" %s params:\n", reg_type) + var dns_reg_method string + switch dns_params.GetDnsRegMethod() { + case pb.RegistrarDNSProtocol_REGISTRAR_DNS_PROTOCOL_UNKNOWN: + dns_reg_method = "unknown" + case pb.RegistrarDNSProtocol_REGISTRAR_DNS_PROTOCOL_UDP: + dns_reg_method = "udp" + case pb.RegistrarDNSProtocol_REGISTRAR_DNS_PROTOCOL_DOH: + dns_reg_method = "doh" + case pb.RegistrarDNSProtocol_REGISTRAR_DNS_PROTOCOL_DOT: + dns_reg_method = "dot" + } + fmt.Printf(" DnsRegMethod: %s\n", dns_reg_method) + if dns_params.GetUdpAddr() != "" { + fmt.Printf(" UDP Addr: %s\n", dns_params.GetUdpAddr()) + } + if dns_params.GetDotAddr() != "" { + fmt.Printf(" DoT Addr: %s\n", dns_params.GetDotAddr()) + } + if dns_params.GetDohUrl() != "" { + fmt.Printf(" DoH URL: %s\n", dns_params.GetDohUrl()) + } + fmt.Printf(" Domain: %s\n", dns_params.GetDomain()) + fmt.Printf(" Pubkey: %s\n", hex.EncodeToString(dns_params.GetPubkey())) + if dns_params.GetUtlsDistribution() != "" { + fmt.Printf(" Utls Distribution: %s\n", dns_params.GetUtlsDistribution()) + } + if dns_params.GetStunServer() != "" { + fmt.Printf(" STUN Server: %s\n", dns_params.GetStunServer()) + } + } + + decoy_params := reg.GetDecoyRegConfParams() + if decoy_params != nil { + // pass + } + } + } +} + +func parseClientConf(fname string) *pb.ClientConfig2 { + clientConf := &pb.ClientConfig2{} + buf, err := ioutil.ReadFile(fname) + if err != nil { + log.Fatal("Error reading file:", err) + } + + err = proto.Unmarshal(buf, clientConf) + if err != nil { + log.Fatal("Error parsing ClientConfig2", err) + } + + return clientConf +} + +func updateDeployConf(deployConf *pb.DeploymentConfig, params *flagValues) { + // Use subnet-file + if params.subnet_file != "" { + tree, err := toml.LoadFile(params.subnet_file) + if err != nil { + log.Fatalf("error opening configuration file: %v", err) + } + subnets := pb.PhantomSubnetsList{} + tree.Unmarshal(&subnets) + deployConf.PhantomSubnetsList = &subnets + } + + // Delete a subnet + if params.delete_subnet != -1 { + deleteSubnet(params.delete_subnet, deployConf) + } + + // Add a subnet + if params.add_subnets != "" { + subnets := strings.Split(params.add_subnets, " ") + addSubnets(subnets, params.weight, deployConf) + } + + // Update generation + if params.generation != 0 { + gen := uint32(params.generation) + deployConf.Generation = &gen + } + + // Update pubkey + if params.pubkey != "" { + if params.add_decoy || params.update_decoy != -1 { + // Skip. -add-decoy or -delete will use pubkey + + } else { + // Update default public key + if deployConf.DefaultPubkey == nil { + k := pb.PubKey{} + key_type := pb.KeyType_AES_GCM_128 + k.Type = &key_type + deployConf.DefaultPubkey = &k + } + deployConf.DefaultPubkey.Key = parsePubkey(params.pubkey) + } + } + + // Update Conjure Pubkey. + if params.cjPubkey != "" { + if params.add_decoy || params.update_decoy != -1 { + // Skip. -add or -delete will use pubkey + + } else { + // Update default public key + if deployConf.ConjurePubkey == nil { + k := pb.PubKey{} + key_type := pb.KeyType_AES_GCM_128 + k.Type = &key_type + deployConf.ConjurePubkey = &k + } + deployConf.ConjurePubkey.Key = parsePubkey(params.cjPubkey) + } + } + + // Update registrar + if params.update_registrar != -1 { + if params.update_registrar < 0 || params.update_registrar >= len(deployConf.GetRegistrars()) { + log.Fatalf("Error: Index %d provided to -update-registrar is out of range", params.update_registrar) + } else if params.registrar_host == "" || params.registrar_type == "" { + log.Fatalf("Error: -update-registrar requires -registrar-host and -registrar-type") + } + // TODO + } + + // Delete registrar + if params.del_registrar != -1 { + idx := params.del_registrar + if idx >= len(deployConf.GetRegistrars()) { + log.Fatalf("Error: Index %d provided to -del-registrar is out of range", idx) + } + registrars := deployConf.GetRegistrars() + deployConf.Registrars = append(registrars[:idx], registrars[idx+1:]...) + } + + // Add registrar + if params.add_registrar { + var reg_type_val pb.RegistrarType + switch strings.ToLower(params.registrar_type) { + case "unknown": + reg_type_val = pb.RegistrarType_REGISTRAR_TYPE_UNKNOWN + case "api": + reg_type_val = pb.RegistrarType_REGISTRAR_TYPE_API + case "decoy": + reg_type_val = pb.RegistrarType_REGISTRAR_TYPE_DECOY + case "dns": + reg_type_val = pb.RegistrarType_REGISTRAR_TYPE_DNS + default: + log.Fatalf("error: invalid/empty input %s passed to -registrar-type", params.registrar_type) + } + new_reg := &pb.Registrar{ + RegistrarType: ®_type_val, + Bidirectional: ¶ms.reg_bidir, + } + if params.registrar_file != "" { + parseRegistrarConf(params.registrar_file, new_reg) + } + deployConf.Registrars = append(deployConf.Registrars, new_reg) + } + + // Update all decoys + if params.all_decoys { + for _, decoy := range deployConf.DecoyList.TlsDecoys { + updateDecoy(decoy, params.host, params.ip, params.pubkey, params.delpubkey, params.timeout, params.tcpwin) + } + } + + // Update a single decoy from the list + if params.update_decoy != -1 { + decoy := deployConf.DecoyList.TlsDecoys[params.update_decoy] + updateDecoy(decoy, params.host, params.ip, params.pubkey, params.delpubkey, params.timeout, params.tcpwin) + } + + // Delete a decoy + if params.del_decoy != -1 { + idx := params.del_decoy + decoys := deployConf.DecoyList.TlsDecoys + deployConf.DecoyList.TlsDecoys = append(decoys[:idx], decoys[idx+1:]...) + } + + // Add a decoy + if params.add_decoy { + if params.host == "" || params.ip == "" { + log.Fatal("Error: -add-decoy requires -host and -ip") + } + if params.update_decoy != -1 { + log.Fatal("Error: -add-decoy cannot be used with -update-decoy") + } + + decoy := pb.TLSDecoySpec{} + updateDecoy(&decoy, params.host, params.ip, params.pubkey, params.delpubkey, params.timeout, params.tcpwin) + + if deployConf.DecoyList == nil { + tls_spec := pb.DecoyList{} + deployConf.DecoyList = &tls_spec + } + deployConf.DecoyList.TlsDecoys = append(deployConf.DecoyList.TlsDecoys, &decoy) + } +} + +func parsePubkey(pubkey string) []byte { + pubkey_bin, err := hex.DecodeString(pubkey) + if err != nil { + log.Fatal("Error parsing pubkey:", err) + } + if len(pubkey_bin) != 32 { + log.Fatal("Error: pubkey length: expected 32, got ", len(pubkey_bin)) + } + return pubkey_bin +} + +func updateDecoy(decoy *pb.TLSDecoySpec, host string, ip string, pubkey string, delpubkey bool, timeout int, tcpwin int) { + + if host != "" { + decoy.Hostname = &host + } + if ip != "" { + ip4 := net.ParseIP(ip).To4() + if ip4 != nil { + uintIp4 := binary.BigEndian.Uint32(ip4) + decoy.Ipv4Addr = &uintIp4 + } else { + ip6 := net.ParseIP(ip).To16() + fmt.Printf("%v", ip6.String()) + decoy.Ipv6Addr = []byte(ip6) + } + } + if pubkey != "" { + if decoy.Pubkey == nil { + decoy.Pubkey = &pb.PubKey{} + } + decoy.Pubkey.Key = parsePubkey(pubkey) + } + if delpubkey { + decoy.Pubkey = nil + } + if timeout != 0 { + t := uint32(timeout) + decoy.Timeout = &t + } + if tcpwin != 0 { + t := uint32(tcpwin) + decoy.Tcpwin = &t + } + +} + +func addSubnets(subnets []string, weight uint, deployConf *pb.DeploymentConfig) { + if weight == 0 { + log.Fatal("Error: -add-subnets requires the weight flag to be set to a non-zero 32-bit unsinged integer") + } + for _, s := range subnets { + _, _, err := net.ParseCIDR(s) + if err != nil { + log.Fatal("Error: " + s + " is not a valid CIDR block") + } + } + var weight32 = uint32(weight) + + // add new item to PhantomSubnetsList.WeightedSubnets + var newPhantomSubnet = pb.PhantomSubnets{ + Weight: &weight32, + Subnets: subnets, + } + if deployConf.PhantomSubnetsList == nil { + deployConf.PhantomSubnetsList = &pb.PhantomSubnetsList{} + } + deployConf.PhantomSubnetsList.WeightedSubnets = append(deployConf.PhantomSubnetsList.WeightedSubnets, &newPhantomSubnet) +} + +func deleteSubnet(index int, deployConf *pb.DeploymentConfig) { + if index < 0 { + log.Fatal("Error: -delete-subnet requires a positive index") + } + var blockRange int = 0 + var weightedSubnets = &deployConf.PhantomSubnetsList.WeightedSubnets + for blockIndex, block := range *weightedSubnets { + blockRange += len(block.Subnets) + if blockRange > index { + fmt.Printf("index: %d, block_range: %d, len_block: %d", index, blockRange, len(block.Subnets)) + var indexInBlock = index - (blockRange - len(block.Subnets)) + block.Subnets[indexInBlock] = block.Subnets[len(block.Subnets)-1] + block.Subnets = block.Subnets[:len(block.Subnets)-1] + if len(block.Subnets) == 0 { // delete group if no longer contains subnets + (*weightedSubnets)[blockIndex] = (*weightedSubnets)[len(*weightedSubnets)-1] + (*weightedSubnets)[len(*weightedSubnets)-1] = nil + *weightedSubnets = (*weightedSubnets)[:len(*weightedSubnets)-1] + } + return + } + } + log.Fatal("Error: Index " + fmt.Sprint(index) + " provided to -delete-subnet is out of range") +} + +func parseRegistrarConf(file string, reg *pb.Registrar) { + tree, err := toml.LoadFile(file) + if err != nil { + log.Fatalf("error opening configuration file: %v", err.Error()) + } + + switch reg.GetRegistrarType() { + case pb.RegistrarType_REGISTRAR_TYPE_UNKNOWN: + // pass + case pb.RegistrarType_REGISTRAR_TYPE_API: + setRegParamsApi(reg, tree) + case pb.RegistrarType_REGISTRAR_TYPE_DECOY: + setRegParamsDecoy(reg, tree) + case pb.RegistrarType_REGISTRAR_TYPE_DNS: + setRegParamsDns(reg, tree) + default: + log.Fatalf("unknown registrar type: %s", reg.GetRegistrarType()) + } +} + +func setRegParamsApi(reg *pb.Registrar, tree *toml.Tree) { + api_params := &pb.APIRegConf{} + err := tree.Unmarshal(api_params) + if err != nil { + log.Fatalf("error unmarshalling tree: %v", err) + } + reg.ApiRegConfParams = api_params +} + +func setRegParamsDecoy(reg *pb.Registrar, tree *toml.Tree) { + decoy_params := &pb.DecoyRegConf{} + err := tree.Unmarshal(decoy_params) + if err != nil { + log.Fatalf("error unmarshalling tree: %v", err) + } + reg.DecoyRegConfParams = decoy_params +} + +func setRegParamsDns(reg *pb.Registrar, tree *toml.Tree) { + // Assert required fields (required in proto) + if !tree.Has("DnsRegMethod") || !tree.Has("Domain") || !tree.Has("Pubkey") { + log.Fatalf("DNSRegConf requires DnsRegMethod, Domain, and Pubkey") + } + + // Convert fields with diff type than proto + if tree.Has("DnsRegMethod") { + dns_method_str := strings.ToLower(tree.Get("DnsRegMethod").(string)) + switch dns_method_str { + case "unknown": + tree.Set("DnsRegMethod", pb.RegistrarDNSProtocol_REGISTRAR_DNS_PROTOCOL_UNKNOWN) + case "udp": + tree.Set("DnsRegMethod", pb.RegistrarDNSProtocol_REGISTRAR_DNS_PROTOCOL_UDP) + case "doh": + tree.Set("DnsRegMethod", pb.RegistrarDNSProtocol_REGISTRAR_DNS_PROTOCOL_DOH) + case "dot": + tree.Set("DnsRegMethod", pb.RegistrarDNSProtocol_REGISTRAR_DNS_PROTOCOL_DOT) + default: + log.Fatalf("unknown DNS protocol type %s", dns_method_str) + } + } + + if tree.Has("Pubkey") { + pubkey_str := tree.Get("Pubkey").(string) + tree.Set("Pubkey", parsePubkey(pubkey_str)) + } + + dns_params := &pb.DNSRegConf{} + err := tree.Unmarshal(dns_params) + if err != nil { + log.Fatalf("error unmarshalling tree: %v", err) + } + reg.DnsRegConfParams = dns_params +} + +func main() { + params := parseCmdLineFlags() + clientConf := &pb.ClientConfig2{} + deployConf := &pb.DeploymentConfig{} + + // Parse ClientConf + if params.fname != "" { + clientConf = parseClientConf(params.fname) + } + + // -add_config and -del_config cannot both be set + if params.add_config && params.del_config != -1 { + log.Fatal("Error: -add_config cannot be used with -del-config") + } + + // Update deploy config + if params.update_config != -1 { + // Check whether index is valid + if params.update_config < 0 || params.update_config >= len(clientConf.DeploymentConfigs) { + log.Fatalf("Error: -update-config %d out of range, expected [0, %d)", params.update_config, len(clientConf.DeploymentConfigs)) + } + + // Select deploy conf and update + deployConf = clientConf.DeploymentConfigs[params.update_config] + updateDeployConf(deployConf, params) + } + + // Delete deploy config + if params.del_config != -1 { + // Check whether index is valid + if params.del_config < 0 || params.del_config >= len(clientConf.DeploymentConfigs) { + log.Fatalf("Error: -del_config %d out of range, expected [0, %d)", params.del_config, len(clientConf.DeploymentConfigs)) + } + + clientConf.DeploymentConfigs = append(clientConf.DeploymentConfigs[:params.del_config], clientConf.DeploymentConfigs[params.del_config+1:]...) + } + + // Append new deploy config + if params.add_config { + updateDeployConf(deployConf, params) + clientConf.DeploymentConfigs = append(clientConf.GetDeploymentConfigs(), deployConf) + } + + // Print all deploy configs + if !params.noout { + printClientConf(clientConf) + } + + if params.out_fname != "" { + buf, err := proto.Marshal(clientConf) + if err != nil { + log.Fatal("Error writing output:", err) + } + err = ioutil.WriteFile(params.out_fname, buf[:], 0644) + if err != nil { + log.Fatal("Error writing output:", err) + } + } +} diff --git a/tools/clientconf2/reg_toml_examples/reg_api_ex.toml b/tools/clientconf2/reg_toml_examples/reg_api_ex.toml new file mode 100644 index 00000000..f3fce544 --- /dev/null +++ b/tools/clientconf2/reg_toml_examples/reg_api_ex.toml @@ -0,0 +1 @@ +ApiUrl = "apiurl.com" \ No newline at end of file diff --git a/tools/clientconf2/reg_toml_examples/reg_dns_ex.toml b/tools/clientconf2/reg_toml_examples/reg_dns_ex.toml new file mode 100644 index 00000000..7eb2205b --- /dev/null +++ b/tools/clientconf2/reg_toml_examples/reg_dns_ex.toml @@ -0,0 +1,8 @@ +DnsRegMethod = "udp" # required +UdpAddr = "192.168.1.2" +#DotAddr = "192.168.1.3" +#DohUrl = "dohurl.com" +Domain = "cooldomainna.me" # required +Pubkey = "103ebf3d7d501aa202c78b7016ffccd51079c4c00137500100ef5bd1cac47e16" # required +UtlsDistribution = "utls" +StunServer = "stun" \ No newline at end of file diff --git a/tools/clientconf2/registrar_test.go b/tools/clientconf2/registrar_test.go new file mode 100644 index 00000000..91afc03f --- /dev/null +++ b/tools/clientconf2/registrar_test.go @@ -0,0 +1,67 @@ +package main + +import ( + "fmt" + "testing" + + pb "github.com/refraction-networking/gotapdance/protobuf" +) + +func TestRegParseDns(t *testing.T) { + reg_type_const := pb.RegistrarType_REGISTRAR_TYPE_DNS + true_var := true + reg_dns := &pb.Registrar{ + RegistrarType: ®_type_const, + Bidirectional: &true_var, + } + parseRegistrarConf("reg_toml_examples/reg_dns_ex.toml", reg_dns) + dns_params := reg_dns.GetDnsRegConfParams() + + dns_reg_method := dns_params.GetDnsRegMethod() + dns_reg_method_exp := pb.RegistrarDNSProtocol(pb.RegistrarDNSProtocol_REGISTRAR_DNS_PROTOCOL_UDP) + assert_eq("DnsRegMethod", dns_reg_method_exp, dns_reg_method, t) + + udp_addr := dns_params.GetUdpAddr() + udp_addr_exp := "192.168.1.2" + assert_eq("UdpAddr", udp_addr_exp, udp_addr, t) + + domain := dns_params.GetDomain() + domain_exp := "cooldomainna.me" + assert_eq("Domain", domain_exp, domain, t) + + pubkey := dns_params.GetPubkey() + pubkey_exp := parsePubkey("103ebf3d7d501aa202c78b7016ffccd51079c4c00137500100ef5bd1cac47e16") + assert_eq("Pubkey_len", len(pubkey_exp), len(pubkey), t) + for i := range pubkey { + assert_eq(fmt.Sprintf("Pubkey[%d]", i), pubkey_exp[i], pubkey[i], t) + } + + utls_dist := dns_params.GetUtlsDistribution() + utls_dist_exp := "utls" + assert_eq("UtlsDistribution", utls_dist_exp, utls_dist, t) + + stun := dns_params.GetStunServer() + stun_exp := "stun" + assert_eq("StunServer", stun_exp, stun, t) +} + +func TestRegParseApi(t *testing.T) { + reg_type_const := pb.RegistrarType_REGISTRAR_TYPE_API + false_var := false + reg_api := &pb.Registrar{ + RegistrarType: ®_type_const, + Bidirectional: &false_var, + } + parseRegistrarConf("reg_toml_examples/reg_api_ex.toml", reg_api) + api_params := reg_api.GetApiRegConfParams() + + api_url := api_params.GetApiUrl() + api_url_exp := "apiurl.com" + assert_eq("ApiUrl", api_url_exp, api_url, t) +} + +func assert_eq(name string, exp, act interface{}, t *testing.T) { + if exp != act { + t.Fatal(name, ": expected", exp, ", got", act) + } +} diff --git a/tools/makefile b/tools/makefile index 696c3709..d7a2accf 100644 --- a/tools/makefile +++ b/tools/makefile @@ -15,11 +15,16 @@ build: cd -; \ done -clientconf: +cc: echo "building clientconf"; \ cd clientconf && $(GOBUILD) -o ../bin/clientconf ; \ cd ../; \ +cc2: + echo "building clientconf2"; \ + cd clientconf2 && $(GOBUILD) -o ../bin/clientconf2 ; \ + cd ../; \ + v6lookup: echo "building v6lookup"; \ cd v6lookup && $(GOBUILD) -o ../bin/v6lookup ; \