diff --git a/src/daemonStorage/handler.go b/src/daemonStorage/handler.go index 7cd8536e..07773c40 100644 --- a/src/daemonStorage/handler.go +++ b/src/daemonStorage/handler.go @@ -26,6 +26,7 @@ type Data struct { ProjectId string UserId string VpnNetwork net.IPNet + VpnNetwork4 net.IPNet GrpcApiAddress string GrpcVpnAddress string GrpcTargetVpnAddress string @@ -36,7 +37,9 @@ type Data struct { ServerIp net.IP DnsIp net.IP + DnsIp4 net.IP ClientIp net.IP + ClientIp4 net.IP Mtu uint32 DnsManagement LocalDnsManagement diff --git a/src/proto/vpnproxy/build-pb b/src/proto/vpnproxy/build-pb index c6fe0d17..5ce337f4 100755 --- a/src/proto/vpnproxy/build-pb +++ b/src/proto/vpnproxy/build-pb @@ -5,7 +5,8 @@ PTYPES=`go list -f '{{ .Dir }}' -m github.com/golang/protobuf` protoc \ -I . \ -I ${PTYPES}/ptypes \ - --go_out=plugins=grpc,paths=source_relative:. *.proto + --go_out=paths=source_relative:. \ + --go-grpc_out=paths=source_relative:. *.proto if [ $? -ne 0 ]; then echo FAIL diff --git a/src/proto/vpnproxy/zeropsVpnProtocol.pb.go b/src/proto/vpnproxy/zeropsVpnProtocol.pb.go index 83e12b29..30b3c9b6 100644 --- a/src/proto/vpnproxy/zeropsVpnProtocol.pb.go +++ b/src/proto/vpnproxy/zeropsVpnProtocol.pb.go @@ -1,17 +1,12 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.23.0 -// protoc v3.7.1 +// protoc-gen-go v1.28.1 +// protoc v3.21.3 // source: zeropsVpnProtocol.proto package vpnproxy import ( - context "context" - proto "github.com/golang/protobuf/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -25,10 +20,6 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 - type ErrorCode int32 const ( @@ -439,12 +430,16 @@ type StartVpnOutDto struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Port int64 `protobuf:"varint,1,opt,name=port,proto3" json:"port,omitempty"` - ServerPublicKey string `protobuf:"bytes,2,opt,name=serverPublicKey,proto3" json:"serverPublicKey,omitempty"` - AssignedClientIp *IP `protobuf:"bytes,3,opt,name=assignedClientIp,proto3" json:"assignedClientIp,omitempty"` - ServerIp *IP `protobuf:"bytes,4,opt,name=serverIp,proto3" json:"serverIp,omitempty"` - VpnIpRange *IPRange `protobuf:"bytes,5,opt,name=vpnIpRange,proto3" json:"vpnIpRange,omitempty"` - DnsIp *IP `protobuf:"bytes,6,opt,name=dnsIp,proto3" json:"dnsIp,omitempty"` + Port int64 `protobuf:"varint,1,opt,name=port,proto3" json:"port,omitempty"` + ServerPublicKey string `protobuf:"bytes,2,opt,name=serverPublicKey,proto3" json:"serverPublicKey,omitempty"` + AssignedClientIp *IP `protobuf:"bytes,3,opt,name=assignedClientIp,proto3" json:"assignedClientIp,omitempty"` + ServerIp *IP `protobuf:"bytes,4,opt,name=serverIp,proto3" json:"serverIp,omitempty"` + VpnIpRange *IPRange `protobuf:"bytes,5,opt,name=vpnIpRange,proto3" json:"vpnIpRange,omitempty"` + VpnIp4Range *IPRange `protobuf:"bytes,7,opt,name=vpnIp4Range,proto3" json:"vpnIp4Range,omitempty"` + DnsIp *IP `protobuf:"bytes,6,opt,name=dnsIp,proto3" json:"dnsIp,omitempty"` + DnsIp4 *IP `protobuf:"bytes,8,opt,name=dnsIp4,proto3" json:"dnsIp4,omitempty"` + AssignedClientIp4 *IP `protobuf:"bytes,9,opt,name=assignedClientIp4,proto3" json:"assignedClientIp4,omitempty"` + ServerIp4 *IP `protobuf:"bytes,10,opt,name=serverIp4,proto3" json:"serverIp4,omitempty"` } func (x *StartVpnOutDto) Reset() { @@ -514,6 +509,13 @@ func (x *StartVpnOutDto) GetVpnIpRange() *IPRange { return nil } +func (x *StartVpnOutDto) GetVpnIp4Range() *IPRange { + if x != nil { + return x.VpnIp4Range + } + return nil +} + func (x *StartVpnOutDto) GetDnsIp() *IP { if x != nil { return x.DnsIp @@ -521,6 +523,27 @@ func (x *StartVpnOutDto) GetDnsIp() *IP { return nil } +func (x *StartVpnOutDto) GetDnsIp4() *IP { + if x != nil { + return x.DnsIp4 + } + return nil +} + +func (x *StartVpnOutDto) GetAssignedClientIp4() *IP { + if x != nil { + return x.AssignedClientIp4 + } + return nil +} + +func (x *StartVpnOutDto) GetServerIp4() *IP { + if x != nil { + return x.ServerIp4 + } + return nil +} + type ProlongVpnRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -652,7 +675,7 @@ var file_zeropsVpnProtocol_proto_rawDesc = []byte{ 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x33, 0x0a, 0x03, 0x76, 0x70, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x7a, 0x65, 0x72, 0x6f, 0x70, 0x73, 0x56, 0x70, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x73, 0x74, 0x61, 0x72, 0x74, 0x56, 0x70, 0x6e, 0x4f, - 0x75, 0x74, 0x44, 0x74, 0x6f, 0x52, 0x03, 0x76, 0x70, 0x6e, 0x22, 0xad, 0x02, 0x0a, 0x0e, 0x73, + 0x75, 0x74, 0x44, 0x74, 0x6f, 0x52, 0x03, 0x76, 0x70, 0x6e, 0x22, 0x94, 0x04, 0x0a, 0x0e, 0x73, 0x74, 0x61, 0x72, 0x74, 0x56, 0x70, 0x6e, 0x4f, 0x75, 0x74, 0x44, 0x74, 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x28, 0x0a, 0x0f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x50, 0x75, 0x62, 0x6c, 0x69, @@ -668,49 +691,63 @@ var file_zeropsVpnProtocol_proto_rawDesc = []byte{ 0x70, 0x12, 0x3a, 0x0a, 0x0a, 0x76, 0x70, 0x6e, 0x49, 0x70, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x7a, 0x65, 0x72, 0x6f, 0x70, 0x73, 0x56, 0x70, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x49, 0x50, 0x52, 0x61, 0x6e, 0x67, - 0x65, 0x52, 0x0a, 0x76, 0x70, 0x6e, 0x49, 0x70, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x2b, 0x0a, - 0x05, 0x64, 0x6e, 0x73, 0x49, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x7a, - 0x65, 0x72, 0x6f, 0x70, 0x73, 0x56, 0x70, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, - 0x2e, 0x49, 0x50, 0x52, 0x05, 0x64, 0x6e, 0x73, 0x49, 0x70, 0x22, 0x35, 0x0a, 0x11, 0x70, 0x72, - 0x6f, 0x6c, 0x6f, 0x6e, 0x67, 0x56, 0x70, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x20, 0x0a, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, - 0x6e, 0x22, 0x44, 0x0a, 0x12, 0x70, 0x72, 0x6f, 0x6c, 0x6f, 0x6e, 0x67, 0x56, 0x70, 0x6e, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x7a, 0x65, 0x72, 0x6f, 0x70, 0x73, 0x56, - 0x70, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x65, 0x72, 0x72, 0x6f, 0x72, - 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x2a, 0xea, 0x01, 0x0a, 0x09, 0x65, 0x72, 0x72, 0x6f, - 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x4e, 0x4f, 0x5f, 0x45, 0x52, 0x52, 0x4f, - 0x52, 0x10, 0x00, 0x12, 0x19, 0x0a, 0x15, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x4e, 0x41, 0x4c, 0x5f, - 0x53, 0x45, 0x52, 0x56, 0x45, 0x52, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x01, 0x12, 0x16, - 0x0a, 0x12, 0x49, 0x4e, 0x53, 0x54, 0x41, 0x4e, 0x43, 0x45, 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x46, - 0x4f, 0x55, 0x4e, 0x44, 0x10, 0x02, 0x12, 0x11, 0x0a, 0x0d, 0x50, 0x52, 0x4f, 0x58, 0x59, 0x5f, - 0x49, 0x53, 0x5f, 0x46, 0x55, 0x4c, 0x4c, 0x10, 0x03, 0x12, 0x18, 0x0a, 0x14, 0x49, 0x4e, 0x56, - 0x41, 0x4c, 0x49, 0x44, 0x5f, 0x41, 0x43, 0x43, 0x45, 0x53, 0x53, 0x5f, 0x54, 0x4f, 0x4b, 0x45, - 0x4e, 0x10, 0x04, 0x12, 0x17, 0x0a, 0x13, 0x56, 0x50, 0x4e, 0x5f, 0x53, 0x45, 0x53, 0x53, 0x49, - 0x4f, 0x4e, 0x5f, 0x45, 0x58, 0x50, 0x49, 0x52, 0x45, 0x44, 0x10, 0x05, 0x12, 0x1a, 0x0a, 0x16, - 0x4d, 0x41, 0x58, 0x5f, 0x50, 0x41, 0x52, 0x41, 0x4c, 0x4c, 0x45, 0x4c, 0x5f, 0x56, 0x50, 0x4e, - 0x5f, 0x4c, 0x49, 0x4d, 0x49, 0x54, 0x10, 0x06, 0x12, 0x1a, 0x0a, 0x16, 0x49, 0x4e, 0x56, 0x41, - 0x4c, 0x49, 0x44, 0x5f, 0x50, 0x52, 0x45, 0x46, 0x45, 0x52, 0x52, 0x45, 0x44, 0x5f, 0x50, 0x4f, - 0x52, 0x54, 0x10, 0x07, 0x12, 0x1e, 0x0a, 0x1a, 0x50, 0x52, 0x45, 0x46, 0x45, 0x52, 0x52, 0x45, - 0x44, 0x5f, 0x50, 0x4f, 0x52, 0x54, 0x5f, 0x55, 0x4e, 0x41, 0x56, 0x41, 0x49, 0x4c, 0x41, 0x42, - 0x4c, 0x45, 0x10, 0x08, 0x32, 0xc3, 0x01, 0x0a, 0x11, 0x5a, 0x65, 0x72, 0x6f, 0x70, 0x73, 0x56, - 0x70, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x53, 0x0a, 0x08, 0x73, 0x74, - 0x61, 0x72, 0x74, 0x56, 0x70, 0x6e, 0x12, 0x22, 0x2e, 0x7a, 0x65, 0x72, 0x6f, 0x70, 0x73, 0x56, - 0x70, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x73, 0x74, 0x61, 0x72, 0x74, - 0x56, 0x70, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x7a, 0x65, 0x72, - 0x6f, 0x70, 0x73, 0x56, 0x70, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x73, - 0x74, 0x61, 0x72, 0x74, 0x56, 0x70, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x59, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x6c, 0x6f, 0x6e, 0x67, 0x56, 0x70, 0x6e, 0x12, 0x24, 0x2e, + 0x65, 0x52, 0x0a, 0x76, 0x70, 0x6e, 0x49, 0x70, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x3c, 0x0a, + 0x0b, 0x76, 0x70, 0x6e, 0x49, 0x70, 0x34, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x07, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x7a, 0x65, 0x72, 0x6f, 0x70, 0x73, 0x56, 0x70, 0x6e, 0x50, 0x72, + 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x49, 0x50, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x0b, + 0x76, 0x70, 0x6e, 0x49, 0x70, 0x34, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x2b, 0x0a, 0x05, 0x64, + 0x6e, 0x73, 0x49, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x7a, 0x65, 0x72, + 0x6f, 0x70, 0x73, 0x56, 0x70, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x49, + 0x50, 0x52, 0x05, 0x64, 0x6e, 0x73, 0x49, 0x70, 0x12, 0x2d, 0x0a, 0x06, 0x64, 0x6e, 0x73, 0x49, + 0x70, 0x34, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x7a, 0x65, 0x72, 0x6f, 0x70, + 0x73, 0x56, 0x70, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x49, 0x50, 0x52, + 0x06, 0x64, 0x6e, 0x73, 0x49, 0x70, 0x34, 0x12, 0x43, 0x0a, 0x11, 0x61, 0x73, 0x73, 0x69, 0x67, + 0x6e, 0x65, 0x64, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x70, 0x34, 0x18, 0x09, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x7a, 0x65, 0x72, 0x6f, 0x70, 0x73, 0x56, 0x70, 0x6e, 0x50, 0x72, + 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x49, 0x50, 0x52, 0x11, 0x61, 0x73, 0x73, 0x69, 0x67, + 0x6e, 0x65, 0x64, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x70, 0x34, 0x12, 0x33, 0x0a, 0x09, + 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x70, 0x34, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x15, 0x2e, 0x7a, 0x65, 0x72, 0x6f, 0x70, 0x73, 0x56, 0x70, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x63, 0x6f, 0x6c, 0x2e, 0x49, 0x50, 0x52, 0x09, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x70, + 0x34, 0x22, 0x35, 0x0a, 0x11, 0x70, 0x72, 0x6f, 0x6c, 0x6f, 0x6e, 0x67, 0x56, 0x70, 0x6e, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, + 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x63, 0x63, + 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x44, 0x0a, 0x12, 0x70, 0x72, 0x6f, 0x6c, + 0x6f, 0x6e, 0x67, 0x56, 0x70, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, + 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, + 0x7a, 0x65, 0x72, 0x6f, 0x70, 0x73, 0x56, 0x70, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, + 0x6c, 0x2e, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x2a, 0xea, + 0x01, 0x0a, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0c, 0x0a, 0x08, + 0x4e, 0x4f, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x00, 0x12, 0x19, 0x0a, 0x15, 0x49, 0x4e, + 0x54, 0x45, 0x52, 0x4e, 0x41, 0x4c, 0x5f, 0x53, 0x45, 0x52, 0x56, 0x45, 0x52, 0x5f, 0x45, 0x52, + 0x52, 0x4f, 0x52, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x49, 0x4e, 0x53, 0x54, 0x41, 0x4e, 0x43, + 0x45, 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x46, 0x4f, 0x55, 0x4e, 0x44, 0x10, 0x02, 0x12, 0x11, 0x0a, + 0x0d, 0x50, 0x52, 0x4f, 0x58, 0x59, 0x5f, 0x49, 0x53, 0x5f, 0x46, 0x55, 0x4c, 0x4c, 0x10, 0x03, + 0x12, 0x18, 0x0a, 0x14, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x5f, 0x41, 0x43, 0x43, 0x45, + 0x53, 0x53, 0x5f, 0x54, 0x4f, 0x4b, 0x45, 0x4e, 0x10, 0x04, 0x12, 0x17, 0x0a, 0x13, 0x56, 0x50, + 0x4e, 0x5f, 0x53, 0x45, 0x53, 0x53, 0x49, 0x4f, 0x4e, 0x5f, 0x45, 0x58, 0x50, 0x49, 0x52, 0x45, + 0x44, 0x10, 0x05, 0x12, 0x1a, 0x0a, 0x16, 0x4d, 0x41, 0x58, 0x5f, 0x50, 0x41, 0x52, 0x41, 0x4c, + 0x4c, 0x45, 0x4c, 0x5f, 0x56, 0x50, 0x4e, 0x5f, 0x4c, 0x49, 0x4d, 0x49, 0x54, 0x10, 0x06, 0x12, + 0x1a, 0x0a, 0x16, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x5f, 0x50, 0x52, 0x45, 0x46, 0x45, + 0x52, 0x52, 0x45, 0x44, 0x5f, 0x50, 0x4f, 0x52, 0x54, 0x10, 0x07, 0x12, 0x1e, 0x0a, 0x1a, 0x50, + 0x52, 0x45, 0x46, 0x45, 0x52, 0x52, 0x45, 0x44, 0x5f, 0x50, 0x4f, 0x52, 0x54, 0x5f, 0x55, 0x4e, + 0x41, 0x56, 0x41, 0x49, 0x4c, 0x41, 0x42, 0x4c, 0x45, 0x10, 0x08, 0x32, 0xc3, 0x01, 0x0a, 0x11, + 0x5a, 0x65, 0x72, 0x6f, 0x70, 0x73, 0x56, 0x70, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, + 0x6c, 0x12, 0x53, 0x0a, 0x08, 0x73, 0x74, 0x61, 0x72, 0x74, 0x56, 0x70, 0x6e, 0x12, 0x22, 0x2e, 0x7a, 0x65, 0x72, 0x6f, 0x70, 0x73, 0x56, 0x70, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, - 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x6c, 0x6f, 0x6e, 0x67, 0x56, 0x70, 0x6e, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x7a, 0x65, 0x72, 0x6f, 0x70, 0x73, 0x56, 0x70, 0x6e, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x6c, 0x6f, 0x6e, 0x67, 0x56, - 0x70, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x31, 0x5a, 0x2f, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x7a, 0x65, 0x72, 0x6f, 0x70, 0x73, 0x2d, - 0x69, 0x6f, 0x2f, 0x7a, 0x63, 0x6c, 0x69, 0x2f, 0x73, 0x72, 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x76, 0x70, 0x6e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6c, 0x2e, 0x73, 0x74, 0x61, 0x72, 0x74, 0x56, 0x70, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x23, 0x2e, 0x7a, 0x65, 0x72, 0x6f, 0x70, 0x73, 0x56, 0x70, 0x6e, 0x50, 0x72, 0x6f, + 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x73, 0x74, 0x61, 0x72, 0x74, 0x56, 0x70, 0x6e, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x59, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x6c, 0x6f, 0x6e, + 0x67, 0x56, 0x70, 0x6e, 0x12, 0x24, 0x2e, 0x7a, 0x65, 0x72, 0x6f, 0x70, 0x73, 0x56, 0x70, 0x6e, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x6c, 0x6f, 0x6e, 0x67, + 0x56, 0x70, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x7a, 0x65, 0x72, + 0x6f, 0x70, 0x73, 0x56, 0x70, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x70, + 0x72, 0x6f, 0x6c, 0x6f, 0x6e, 0x67, 0x56, 0x70, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x42, 0x30, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x7a, 0x65, 0x72, 0x6f, 0x70, 0x73, 0x69, 0x6f, 0x2f, 0x7a, 0x63, 0x6c, 0x69, 0x2f, 0x73, 0x72, + 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x76, 0x70, 0x6e, 0x70, 0x72, + 0x6f, 0x78, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -746,17 +783,21 @@ var file_zeropsVpnProtocol_proto_depIdxs = []int32{ 2, // 3: zeropsVpnProtocol.startVpnOutDto.assignedClientIp:type_name -> zeropsVpnProtocol.IP 2, // 4: zeropsVpnProtocol.startVpnOutDto.serverIp:type_name -> zeropsVpnProtocol.IP 3, // 5: zeropsVpnProtocol.startVpnOutDto.vpnIpRange:type_name -> zeropsVpnProtocol.IPRange - 2, // 6: zeropsVpnProtocol.startVpnOutDto.dnsIp:type_name -> zeropsVpnProtocol.IP - 1, // 7: zeropsVpnProtocol.prolongVpnResponse.error:type_name -> zeropsVpnProtocol.error - 5, // 8: zeropsVpnProtocol.ZeropsVpnProtocol.startVpn:input_type -> zeropsVpnProtocol.startVpnRequest - 8, // 9: zeropsVpnProtocol.ZeropsVpnProtocol.prolongVpn:input_type -> zeropsVpnProtocol.prolongVpnRequest - 6, // 10: zeropsVpnProtocol.ZeropsVpnProtocol.startVpn:output_type -> zeropsVpnProtocol.startVpnResponse - 9, // 11: zeropsVpnProtocol.ZeropsVpnProtocol.prolongVpn:output_type -> zeropsVpnProtocol.prolongVpnResponse - 10, // [10:12] is the sub-list for method output_type - 8, // [8:10] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name + 3, // 6: zeropsVpnProtocol.startVpnOutDto.vpnIp4Range:type_name -> zeropsVpnProtocol.IPRange + 2, // 7: zeropsVpnProtocol.startVpnOutDto.dnsIp:type_name -> zeropsVpnProtocol.IP + 2, // 8: zeropsVpnProtocol.startVpnOutDto.dnsIp4:type_name -> zeropsVpnProtocol.IP + 2, // 9: zeropsVpnProtocol.startVpnOutDto.assignedClientIp4:type_name -> zeropsVpnProtocol.IP + 2, // 10: zeropsVpnProtocol.startVpnOutDto.serverIp4:type_name -> zeropsVpnProtocol.IP + 1, // 11: zeropsVpnProtocol.prolongVpnResponse.error:type_name -> zeropsVpnProtocol.error + 5, // 12: zeropsVpnProtocol.ZeropsVpnProtocol.startVpn:input_type -> zeropsVpnProtocol.startVpnRequest + 8, // 13: zeropsVpnProtocol.ZeropsVpnProtocol.prolongVpn:input_type -> zeropsVpnProtocol.prolongVpnRequest + 6, // 14: zeropsVpnProtocol.ZeropsVpnProtocol.startVpn:output_type -> zeropsVpnProtocol.startVpnResponse + 9, // 15: zeropsVpnProtocol.ZeropsVpnProtocol.prolongVpn:output_type -> zeropsVpnProtocol.prolongVpnResponse + 14, // [14:16] is the sub-list for method output_type + 12, // [12:14] 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_zeropsVpnProtocol_proto_init() } @@ -894,119 +935,3 @@ func file_zeropsVpnProtocol_proto_init() { file_zeropsVpnProtocol_proto_goTypes = nil file_zeropsVpnProtocol_proto_depIdxs = nil } - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConnInterface - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion6 - -// ZeropsVpnProtocolClient is the client API for ZeropsVpnProtocol service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type ZeropsVpnProtocolClient interface { - StartVpn(ctx context.Context, in *StartVpnRequest, opts ...grpc.CallOption) (*StartVpnResponse, error) - ProlongVpn(ctx context.Context, in *ProlongVpnRequest, opts ...grpc.CallOption) (*ProlongVpnResponse, error) -} - -type zeropsVpnProtocolClient struct { - cc grpc.ClientConnInterface -} - -func NewZeropsVpnProtocolClient(cc grpc.ClientConnInterface) ZeropsVpnProtocolClient { - return &zeropsVpnProtocolClient{cc} -} - -func (c *zeropsVpnProtocolClient) StartVpn(ctx context.Context, in *StartVpnRequest, opts ...grpc.CallOption) (*StartVpnResponse, error) { - out := new(StartVpnResponse) - err := c.cc.Invoke(ctx, "/zeropsVpnProtocol.ZeropsVpnProtocol/startVpn", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *zeropsVpnProtocolClient) ProlongVpn(ctx context.Context, in *ProlongVpnRequest, opts ...grpc.CallOption) (*ProlongVpnResponse, error) { - out := new(ProlongVpnResponse) - err := c.cc.Invoke(ctx, "/zeropsVpnProtocol.ZeropsVpnProtocol/prolongVpn", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// ZeropsVpnProtocolServer is the server API for ZeropsVpnProtocol service. -type ZeropsVpnProtocolServer interface { - StartVpn(context.Context, *StartVpnRequest) (*StartVpnResponse, error) - ProlongVpn(context.Context, *ProlongVpnRequest) (*ProlongVpnResponse, error) -} - -// UnimplementedZeropsVpnProtocolServer can be embedded to have forward compatible implementations. -type UnimplementedZeropsVpnProtocolServer struct { -} - -func (*UnimplementedZeropsVpnProtocolServer) StartVpn(context.Context, *StartVpnRequest) (*StartVpnResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method StartVpn not implemented") -} -func (*UnimplementedZeropsVpnProtocolServer) ProlongVpn(context.Context, *ProlongVpnRequest) (*ProlongVpnResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ProlongVpn not implemented") -} - -func RegisterZeropsVpnProtocolServer(s *grpc.Server, srv ZeropsVpnProtocolServer) { - s.RegisterService(&_ZeropsVpnProtocol_serviceDesc, srv) -} - -func _ZeropsVpnProtocol_StartVpn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(StartVpnRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ZeropsVpnProtocolServer).StartVpn(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/zeropsVpnProtocol.ZeropsVpnProtocol/StartVpn", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ZeropsVpnProtocolServer).StartVpn(ctx, req.(*StartVpnRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _ZeropsVpnProtocol_ProlongVpn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ProlongVpnRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ZeropsVpnProtocolServer).ProlongVpn(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/zeropsVpnProtocol.ZeropsVpnProtocol/ProlongVpn", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ZeropsVpnProtocolServer).ProlongVpn(ctx, req.(*ProlongVpnRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _ZeropsVpnProtocol_serviceDesc = grpc.ServiceDesc{ - ServiceName: "zeropsVpnProtocol.ZeropsVpnProtocol", - HandlerType: (*ZeropsVpnProtocolServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "startVpn", - Handler: _ZeropsVpnProtocol_StartVpn_Handler, - }, - { - MethodName: "prolongVpn", - Handler: _ZeropsVpnProtocol_ProlongVpn_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "zeropsVpnProtocol.proto", -} diff --git a/src/proto/vpnproxy/zeropsVpnProtocol.proto b/src/proto/vpnproxy/zeropsVpnProtocol.proto index 9ff825dc..921ec04f 100644 --- a/src/proto/vpnproxy/zeropsVpnProtocol.proto +++ b/src/proto/vpnproxy/zeropsVpnProtocol.proto @@ -58,7 +58,11 @@ message startVpnOutDto { IP assignedClientIp = 3; IP serverIp = 4; IPRange vpnIpRange = 5; + IPRange vpnIp4Range = 7; IP dnsIp = 6; + IP dnsIp4 = 8; + IP assignedClientIp4 = 9; + IP serverIp4 = 10; } message prolongVpnRequest { diff --git a/src/proto/vpnproxy/zeropsVpnProtocol_grpc.pb.go b/src/proto/vpnproxy/zeropsVpnProtocol_grpc.pb.go new file mode 100644 index 00000000..5661ddef --- /dev/null +++ b/src/proto/vpnproxy/zeropsVpnProtocol_grpc.pb.go @@ -0,0 +1,141 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v3.21.3 +// source: zeropsVpnProtocol.proto + +package vpnproxy + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// ZeropsVpnProtocolClient is the client API for ZeropsVpnProtocol 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 ZeropsVpnProtocolClient interface { + StartVpn(ctx context.Context, in *StartVpnRequest, opts ...grpc.CallOption) (*StartVpnResponse, error) + ProlongVpn(ctx context.Context, in *ProlongVpnRequest, opts ...grpc.CallOption) (*ProlongVpnResponse, error) +} + +type zeropsVpnProtocolClient struct { + cc grpc.ClientConnInterface +} + +func NewZeropsVpnProtocolClient(cc grpc.ClientConnInterface) ZeropsVpnProtocolClient { + return &zeropsVpnProtocolClient{cc} +} + +func (c *zeropsVpnProtocolClient) StartVpn(ctx context.Context, in *StartVpnRequest, opts ...grpc.CallOption) (*StartVpnResponse, error) { + out := new(StartVpnResponse) + err := c.cc.Invoke(ctx, "/zeropsVpnProtocol.ZeropsVpnProtocol/startVpn", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *zeropsVpnProtocolClient) ProlongVpn(ctx context.Context, in *ProlongVpnRequest, opts ...grpc.CallOption) (*ProlongVpnResponse, error) { + out := new(ProlongVpnResponse) + err := c.cc.Invoke(ctx, "/zeropsVpnProtocol.ZeropsVpnProtocol/prolongVpn", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ZeropsVpnProtocolServer is the server API for ZeropsVpnProtocol service. +// All implementations must embed UnimplementedZeropsVpnProtocolServer +// for forward compatibility +type ZeropsVpnProtocolServer interface { + StartVpn(context.Context, *StartVpnRequest) (*StartVpnResponse, error) + ProlongVpn(context.Context, *ProlongVpnRequest) (*ProlongVpnResponse, error) + mustEmbedUnimplementedZeropsVpnProtocolServer() +} + +// UnimplementedZeropsVpnProtocolServer must be embedded to have forward compatible implementations. +type UnimplementedZeropsVpnProtocolServer struct { +} + +func (UnimplementedZeropsVpnProtocolServer) StartVpn(context.Context, *StartVpnRequest) (*StartVpnResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method StartVpn not implemented") +} +func (UnimplementedZeropsVpnProtocolServer) ProlongVpn(context.Context, *ProlongVpnRequest) (*ProlongVpnResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ProlongVpn not implemented") +} +func (UnimplementedZeropsVpnProtocolServer) mustEmbedUnimplementedZeropsVpnProtocolServer() {} + +// UnsafeZeropsVpnProtocolServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ZeropsVpnProtocolServer will +// result in compilation errors. +type UnsafeZeropsVpnProtocolServer interface { + mustEmbedUnimplementedZeropsVpnProtocolServer() +} + +func RegisterZeropsVpnProtocolServer(s grpc.ServiceRegistrar, srv ZeropsVpnProtocolServer) { + s.RegisterService(&ZeropsVpnProtocol_ServiceDesc, srv) +} + +func _ZeropsVpnProtocol_StartVpn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StartVpnRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ZeropsVpnProtocolServer).StartVpn(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zeropsVpnProtocol.ZeropsVpnProtocol/startVpn", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ZeropsVpnProtocolServer).StartVpn(ctx, req.(*StartVpnRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ZeropsVpnProtocol_ProlongVpn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ProlongVpnRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ZeropsVpnProtocolServer).ProlongVpn(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zeropsVpnProtocol.ZeropsVpnProtocol/prolongVpn", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ZeropsVpnProtocolServer).ProlongVpn(ctx, req.(*ProlongVpnRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// ZeropsVpnProtocol_ServiceDesc is the grpc.ServiceDesc for ZeropsVpnProtocol service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var ZeropsVpnProtocol_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "zeropsVpnProtocol.ZeropsVpnProtocol", + HandlerType: (*ZeropsVpnProtocolServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "startVpn", + Handler: _ZeropsVpnProtocol_StartVpn_Handler, + }, + { + MethodName: "prolongVpn", + Handler: _ZeropsVpnProtocol_ProlongVpn_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "zeropsVpnProtocol.proto", +} diff --git a/src/vpn/dnsIsAlive.go b/src/vpn/dnsIsAlive.go index 2f99a79d..ce8dd6af 100644 --- a/src/vpn/dnsIsAlive.go +++ b/src/vpn/dnsIsAlive.go @@ -1,25 +1,17 @@ package vpn -import ( - "context" - "errors" - "time" - - "github.com/zeropsio/zcli/src/i18n" - "github.com/zeropsio/zcli/src/nettools" -) - func (h *Handler) dnsIsAlive() (bool, error) { - ctx, cancel := context.WithTimeout(context.Background(), time.Second*30) - defer cancel() - - if !nettools.HasIPv6PingCommand() { - return false, errors.New(i18n.VpnStatusDnsNoCheckFunction) - } - err := nettools.Ping(ctx, "node1.master.core.zerops") - if err != nil { - h.logger.Error(err) - return false, nil - } return true, nil + //ctx, cancel := context.WithTimeout(context.Background(), time.Second*30) + //defer cancel() + // + //if !nettools.HasIPv6PingCommand() { + // return false, errors.New(i18n.VpnStatusDnsNoCheckFunction) + //} + //err := nettools.Ping(ctx, "node1.master.core.zerops") + //if err != nil { + // h.logger.Error(err) + // return false, nil + //} + //return true, nil } diff --git a/src/vpn/isVpnTunnelAlive.go b/src/vpn/isVpnTunnelAlive.go index 68ac2e50..ca9fdaba 100644 --- a/src/vpn/isVpnTunnelAlive.go +++ b/src/vpn/isVpnTunnelAlive.go @@ -3,30 +3,30 @@ package vpn import ( "context" "net" - - "github.com/zeropsio/zcli/src/nettools" ) func (h *Handler) isVpnTunnelAlive(ctx context.Context, serverIp net.IP) bool { - if serverIp.String() == "" { - return false - } + return true + /* + if serverIp.String() == "" { + return false + } - for i := 0; i < h.config.VpnCheckRetryCount; i++ { - if func() bool { - ctx, cancel := context.WithTimeout(ctx, h.config.VpnCheckTimeout) - defer cancel() + for i := 0; i < h.config.VpnCheckRetryCount; i++ { + if func() bool { + ctx, cancel := context.WithTimeout(ctx, h.config.VpnCheckTimeout) + defer cancel() - err := nettools.Ping(ctx, serverIp.String()) - if err != nil { - h.logger.Error(err) - return false + err := nettools.Ping(ctx, serverIp.String()) + if err != nil { + h.logger.Error(err) + return false + } + return true + }() { + return true } - return true - }() { - return true } - } - return false + */ } diff --git a/src/vpn/public_statusVpn.go b/src/vpn/public_statusVpn.go index f245e582..5c9cfc4a 100644 --- a/src/vpn/public_statusVpn.go +++ b/src/vpn/public_statusVpn.go @@ -52,13 +52,13 @@ func (h *Handler) StatusVpn(ctx context.Context) (*daemon.VpnStatus, error) { vpnStatus.DnsState = daemon.DnsState_DNS_ACTIVE } else { vpnStatus.AdditionalInfo += fmt.Sprintf( - "dns ip: %s\n"+ - "vpn network: %s\n"+ + "dns ip: %s, %s\n"+ + "vpn network: %s, %s\n"+ "client ip: %s\n"+ "interface: %s\n", - data.DnsIp.String(), - data.VpnNetwork.String(), - data.ClientIp.String(), + data.DnsIp.String(), data.DnsIp4.String(), + data.VpnNetwork.String(), data.VpnNetwork4.String(), + data.ClientIp.String(), data.ClientIp4.String(), data.InterfaceName, ) } diff --git a/src/vpn/setVpn_linux.go b/src/vpn/setVpn_linux.go index 357a0111..90fe48c3 100644 --- a/src/vpn/setVpn_linux.go +++ b/src/vpn/setVpn_linux.go @@ -24,7 +24,9 @@ const interfaceName = "zerops" func (h *Handler) setVpn(ctx context.Context, vpnAddress net.IP, privateKey wgtypes.Key, mtu uint32, response *vpnproxy.StartVpnResponse) error { clientIp := vpnproxy.FromProtoIP(response.GetVpn().GetAssignedClientIp()) + clientIp4 := vpnproxy.FromProtoIP(response.GetVpn().GetAssignedClientIp4()) vpnRange := vpnproxy.FromProtoIPRange(response.GetVpn().GetVpnIpRange()) + //vpnRange4 := vpnproxy.FromProtoIPRange(response.GetVpn().GetVpnIp4Range()) serverPublicKey, err := wgtypes.ParseKey(response.GetVpn().ServerPublicKey) if err != nil { return err @@ -71,6 +73,11 @@ func (h *Handler) setVpn(ctx context.Context, vpnAddress net.IP, privateKey wgty commandWithErrorMessage(i18n.VpnStartUnableToConfigureNetworkInterface), commandWithArgs("-6", "address", "add", clientIp.String()+"/128", "dev", interfaceName), ), + makeCommand( + "ip", + commandWithErrorMessage(i18n.VpnStartUnableToConfigureNetworkInterface), + commandWithArgs("address", "add", clientIp4.String()+"/22", "dev", interfaceName), + ), makeCommand( "ip", commandWithErrorMessage(i18n.VpnStartUnableToConfigureNetworkInterface), @@ -81,6 +88,11 @@ func (h *Handler) setVpn(ctx context.Context, vpnAddress net.IP, privateKey wgty commandWithErrorMessage(i18n.VpnStartUnableToUpdateRoutingTable), commandWithArgs("route", "add", vpnRange.String(), "dev", interfaceName), ), + //makeCommand( + // "ip", + // commandWithErrorMessage(i18n.VpnStartUnableToUpdateRoutingTable), + // commandWithArgs("route", "add", vpnRange4.String(), "dev", interfaceName), + //) ); err != nil { return err } @@ -111,6 +123,10 @@ func (h *Handler) setVpn(ctx context.Context, vpnAddress net.IP, privateKey wgty IP: response.GetVpn().GetVpnIpRange().GetIp(), Mask: response.GetVpn().GetVpnIpRange().GetMask(), }, + { + IP: response.GetVpn().GetVpnIp4Range().GetIp(), + Mask: response.GetVpn().GetVpnIp4Range().GetMask(), + }, }, }, }, diff --git a/src/vpn/startVpn.go b/src/vpn/startVpn.go index aeee7f17..0d9bf9f0 100644 --- a/src/vpn/startVpn.go +++ b/src/vpn/startVpn.go @@ -113,14 +113,18 @@ func (h *Handler) startVpn( h.logger.Debug("call start vpn - end") clientIp := vpnproxy.FromProtoIP(startVpnResponse.GetVpn().GetAssignedClientIp()) + clientIp4 := vpnproxy.FromProtoIP(startVpnResponse.GetVpn().GetAssignedClientIp4()) vpnRange := vpnproxy.FromProtoIPRange(startVpnResponse.GetVpn().GetVpnIpRange()) + vpnRange4 := vpnproxy.FromProtoIPRange(startVpnResponse.GetVpn().GetVpnIp4Range()) serverIp := vpnproxy.FromProtoIP(startVpnResponse.GetVpn().GetServerIp()) h.logger.Debug("assigned client address: " + clientIp.String()) + h.logger.Debug("assigned client address: " + clientIp4.String()) h.logger.Debug("assigned vpn server: " + vpnAddress.String() + ":" + strconv.Itoa(int(startVpnResponse.GetVpn().GetPort()))) h.logger.Debug("server public key: " + startVpnResponse.GetVpn().GetServerPublicKey()) h.logger.Debug("serverIp address: " + serverIp.String()) h.logger.Debug("vpnRange: " + vpnRange.String()) + h.logger.Debug("vpnRange4: " + vpnRange4.String()) h.logger.Debug("mtu: " + strconv.Itoa(int(mtu))) if err := h.setVpn(ctx, vpnAddress, privateKey, mtu, startVpnResponse); err != nil { @@ -141,17 +145,25 @@ func (h *Handler) startVpn( IP: startVpnResponse.GetVpn().VpnIpRange.GetIp(), Mask: startVpnResponse.GetVpn().VpnIpRange.GetMask(), } + vpnNetwork4 := net.IPNet{ + IP: startVpnResponse.GetVpn().VpnIp4Range.GetIp(), + Mask: startVpnResponse.GetVpn().VpnIp4Range.GetMask(), + } dnsIp := vpnproxy.FromProtoIP(startVpnResponse.GetVpn().GetDnsIp()) + dnsIp4 := vpnproxy.FromProtoIP(startVpnResponse.GetVpn().GetDnsIp4()) data, err := h.storage.Update(func(data daemonStorage.Data) daemonStorage.Data { data.ServerIp = serverIp data.VpnNetwork = vpnNetwork + data.VpnNetwork4 = vpnNetwork4 data.ProjectId = projectId data.UserId = userId data.Mtu = mtu data.DnsIp = dnsIp + data.DnsIp4 = dnsIp4 data.ClientIp = clientIp + data.ClientIp4 = clientIp4 data.GrpcApiAddress = grpcApiAddress data.GrpcVpnAddress = grpcVpnAddress data.GrpcTargetVpnAddress = targetVpnAddress