From 133e350a70b870103843dc618a4a2f9391bbf374 Mon Sep 17 00:00:00 2001 From: Mustafa Arici Date: Mon, 27 Jul 2020 21:12:58 +0300 Subject: [PATCH 1/2] feat: vpn update option enable|disable use-lzo --- api/pb/vpn.pb.go | 141 +++++++++++++++++++++++++++-------------- api/pb/vpn.proto | 8 +++ api/rpc.go | 13 +++- cmd/ovpm/action_vpn.go | 25 ++++++-- cmd/ovpm/cmd_vpn.go | 26 +++++++- go.mod | 1 + go.sum | 24 +++++++ vpn.go | 6 +- vpn_test.go | 17 +++-- 9 files changed, 200 insertions(+), 61 deletions(-) diff --git a/api/pb/vpn.pb.go b/api/pb/vpn.pb.go index 3ca23ac..014e6f6 100644 --- a/api/pb/vpn.pb.go +++ b/api/pb/vpn.pb.go @@ -53,6 +53,34 @@ func (VPNProto) EnumDescriptor() ([]byte, []int) { return fileDescriptor_75c5922f473942e1, []int{0} } +type VPNLZOPref int32 + +const ( + VPNLZOPref_USE_LZO_NOPREF VPNLZOPref = 0 + VPNLZOPref_USE_LZO_ENABLE VPNLZOPref = 1 + VPNLZOPref_USE_LZO_DISABLE VPNLZOPref = 3 +) + +var VPNLZOPref_name = map[int32]string{ + 0: "USE_LZO_NOPREF", + 1: "USE_LZO_ENABLE", + 3: "USE_LZO_DISABLE", +} + +var VPNLZOPref_value = map[string]int32{ + "USE_LZO_NOPREF": 0, + "USE_LZO_ENABLE": 1, + "USE_LZO_DISABLE": 3, +} + +func (x VPNLZOPref) String() string { + return proto.EnumName(VPNLZOPref_name, int32(x)) +} + +func (VPNLZOPref) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_75c5922f473942e1, []int{1} +} + type VPNStatusRequest struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -180,11 +208,12 @@ func (m *VPNInitRequest) GetUseLzo() bool { } type VPNUpdateRequest struct { - IpBlock string `protobuf:"bytes,1,opt,name=ip_block,json=ipBlock,proto3" json:"ip_block,omitempty"` - Dns string `protobuf:"bytes,2,opt,name=dns,proto3" json:"dns,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + IpBlock string `protobuf:"bytes,1,opt,name=ip_block,json=ipBlock,proto3" json:"ip_block,omitempty"` + Dns string `protobuf:"bytes,2,opt,name=dns,proto3" json:"dns,omitempty"` + LzoPref VPNLZOPref `protobuf:"varint,3,opt,name=lzo_pref,json=lzoPref,proto3,enum=pb.VPNLZOPref" json:"lzo_pref,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *VPNUpdateRequest) Reset() { *m = VPNUpdateRequest{} } @@ -226,6 +255,13 @@ func (m *VPNUpdateRequest) GetDns() string { return "" } +func (m *VPNUpdateRequest) GetLzoPref() VPNLZOPref { + if m != nil { + return m.LzoPref + } + return VPNLZOPref_USE_LZO_NOPREF +} + type VPNRestartRequest struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -271,6 +307,7 @@ type VPNStatusResponse struct { Dns string `protobuf:"bytes,11,opt,name=dns,proto3" json:"dns,omitempty"` ExpiresAt string `protobuf:"bytes,12,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at,omitempty"` CaExpiresAt string `protobuf:"bytes,13,opt,name=ca_expires_at,json=caExpiresAt,proto3" json:"ca_expires_at,omitempty"` + UseLzo bool `protobuf:"varint,14,opt,name=use_lzo,json=useLzo,proto3" json:"use_lzo,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -392,6 +429,13 @@ func (m *VPNStatusResponse) GetCaExpiresAt() string { return "" } +func (m *VPNStatusResponse) GetUseLzo() bool { + if m != nil { + return m.UseLzo + } + return false +} + type VPNInitResponse struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -487,6 +531,7 @@ var xxx_messageInfo_VPNRestartResponse proto.InternalMessageInfo func init() { proto.RegisterEnum("pb.VPNProto", VPNProto_name, VPNProto_value) + proto.RegisterEnum("pb.VPNLZOPref", VPNLZOPref_name, VPNLZOPref_value) proto.RegisterType((*VPNStatusRequest)(nil), "pb.VPNStatusRequest") proto.RegisterType((*VPNInitRequest)(nil), "pb.VPNInitRequest") proto.RegisterType((*VPNUpdateRequest)(nil), "pb.VPNUpdateRequest") @@ -500,47 +545,51 @@ func init() { func init() { proto.RegisterFile("vpn.proto", fileDescriptor_75c5922f473942e1) } var fileDescriptor_75c5922f473942e1 = []byte{ - // 628 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x93, 0x4f, 0x6f, 0xd3, 0x4c, - 0x10, 0xc6, 0x5f, 0x3b, 0xa9, 0x93, 0x4c, 0xff, 0xb9, 0xd3, 0xf4, 0xad, 0x09, 0x54, 0xaa, 0xcc, - 0x25, 0xb4, 0x52, 0x23, 0xca, 0x8d, 0x0b, 0x2a, 0xa5, 0x48, 0x48, 0x55, 0x30, 0xa6, 0xcd, 0xd5, - 0xda, 0x38, 0xdb, 0x62, 0x35, 0xf1, 0x2e, 0xbb, 0xeb, 0x08, 0xf5, 0xc8, 0x95, 0x23, 0x1f, 0x8d, - 0x13, 0x9c, 0xf9, 0x20, 0xc8, 0x63, 0x3b, 0x75, 0x22, 0xb8, 0x8d, 0x7f, 0x33, 0x79, 0x34, 0x79, - 0x9e, 0x59, 0xe8, 0xcc, 0x65, 0x7a, 0x22, 0x95, 0x30, 0x02, 0x6d, 0x39, 0xee, 0x3d, 0xb9, 0x15, - 0xe2, 0x76, 0xca, 0x07, 0x4c, 0x26, 0x03, 0x96, 0xa6, 0xc2, 0x30, 0x93, 0x88, 0x54, 0x17, 0x13, - 0x3e, 0x82, 0x3b, 0x0a, 0x86, 0x1f, 0x0d,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, 0xd7, 0xca, 0x8b, 0xab, 0xf3, 0xc0, 0xb5, 0x4f, 0x7f, 0xd9, 0x00, 0x79, - 0x86, 0x5c, 0xcd, 0x93, 0x98, 0xe3, 0x07, 0x70, 0x8a, 0x38, 0xb1, 0x5b, 0x5e, 0xfa, 0xd2, 0xb3, - 0xea, 0xed, 0xad, 0xd0, 0x72, 0x8b, 0xde, 0xd7, 0x1f, 0xbf, 0xbf, 0xdb, 0x5d, 0x44, 0x7a, 0xa1, - 0xf3, 0xe7, 0x83, 0xb9, 0x4c, 0x07, 0xba, 0x10, 0xba, 0x84, 0x66, 0xfe, 0x37, 0x10, 0xcb, 0x9f, - 0xd6, 0x9e, 0x64, 0x6f, 0x77, 0x89, 0x95, 0x62, 0x8f, 0x49, 0x6c, 0xcf, 0x77, 0xeb, 0x62, 0x49, - 0x9a, 0x98, 0x97, 0xd6, 0x11, 0x5e, 0x81, 0x53, 0x38, 0xb0, 0x58, 0x70, 0xe9, 0xaa, 0x17, 0x0b, - 0xae, 0xd8, 0x74, 0x40, 0x9a, 0xfb, 0xfe, 0xd2, 0x82, 0x19, 0xcd, 0xe4, 0xaa, 0xd7, 0xd0, 0x2a, - 0x2d, 0xc4, 0x4a, 0x60, 0xf9, 0xd6, 0x7b, 0xff, 0xaf, 0xe2, 0x95, 0x65, 0x77, 0xeb, 0xc2, 0xaa, - 0x18, 0x1a, 0x3b, 0x74, 0x20, 0x2f, 0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, 0xba, 0x04, 0x57, 0xbd, - 0xce, 0x04, 0x00, 0x00, + // 690 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x94, 0xcd, 0x6e, 0xd3, 0x40, + 0x10, 0xc7, 0xb1, 0x93, 0xe6, 0x63, 0xda, 0xa6, 0xee, 0x24, 0xa5, 0x26, 0x50, 0xa9, 0x32, 0x97, + 0xd0, 0x4a, 0x8d, 0x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xb7, 0x88, 0x46, 0x21, 0xbe, 0x01, + 0xed, 0x89, 0x73, 0xc1, 0x66, 0xee, 0x92, 0xdb, 0x82, 0x07, 0xae, 0x3f, 0xd5, 0x2b, 0x94, 0xde, + 0xcb, 0xb8, 0x49, 0x18, 0x4f, 0x61, 0x7f, 0x5d, 0x2a, 0xdd, 0x39, 0xf7, 0x17, 0x52, 0xaf, 0x52, + 0xed, 0x5a, 0xe3, 0x2e, 0xe6, 0x78, 0x08, 0xd5, 0x45, 0xc8, 0xed, 0xd9, 0xca, 0xd7, 0x6b, 0xc7, + 0x4a, 0xa7, 0x66, 0x55, 0x16, 0x21, 0xef, 0xaf, 0x7c, 0xe3, 0x33, 0x39, 0x34, 0x12, 0x53, 0x26, + 0x79, 0x6a, 0x47, 0xbe, 0x63, 0xe5, 0x9f, 0x1d, 0xab, 0xf9, 0x8e, 0x6b, 0xb3, 0x55, 0xc1, 0x89, + 0x46, 0xe2, 0x44, 0xff, 0xfe, 0x36, 0x32, 0xc0, 0xaa, 0xce, 0x56, 0xe4, 0x84, 0xd1, 0x84, 0xfd, + 0xb1, 0x39, 0xb0, 0x78, 0x28, 0x59, 0x90, 0x7a, 0x6f, 0xfc, 0x51, 0x89, 0xa6, 0x33, 0x0a, 0x85, + 0xef, 0x85, 0xe4, 0x7a, 0x6e, 0x1a, 0x14, 0xe3, 0x6b, 0xd8, 0x0d, 0x79, 0xe0, 0xb2, 0x99, 0xed, + 0x2d, 0xe6, 0x13, 0x1e, 0x24, 0x5d, 0xec, 0xc4, 0x70, 0x40, 0xac, 0x30, 0xca, 0xd2, 0x7f, 0x46, + 0x59, 0xce, 0x8d, 0x12, 0xa1, 0xec, 0xf0, 0x40, 0x26, 0x33, 0xa0, 0x38, 0x32, 0xcb, 0x61, 0x36, + 0xe1, 0xd8, 0xfb, 0x8a, 0xc3, 0xae, 0xa2, 0x84, 0x06, 0x25, 0x8f, 0xa7, 0x26, 0x47, 0x61, 0x74, + 0x7d, 0xce, 0xc2, 0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x6d, 0x21, 0xd2, 0x0f, 0x63, 0xf9, + 0xb6, 0xbb, 0x14, 0x5e, 0x37, 0x8c, 0x85, 0xfa, 0x50, 0x8e, 0x1c, 0x41, 0x4c, 0xae, 0xe6, 0xfe, + 0x10, 0xed, 0x66, 0x81, 0x25, 0x62, 0x2f, 0x49, 0xec, 0xc0, 0xd0, 0xf2, 0x62, 0xae, 0xe7, 0xca, + 0xf7, 0xca, 0x09, 0xde, 0x41, 0x25, 0x36, 0x33, 0x6b, 0xb0, 0xf0, 0xc8, 0xb2, 0x06, 0x37, 0x1c, + 0x3f, 0x22, 0xcd, 0x43, 0xa3, 0xd0, 0xe0, 0x82, 0x6a, 0x22, 0xd5, 0x11, 0x54, 0x93, 0x69, 0x60, + 0x2a, 0x50, 0x7c, 0x4f, 0xed, 0xe7, 0x9b, 0x78, 0xa3, 0xd9, 0x66, 0x5e, 0x38, 0x88, 0x8b, 0x26, + 0x15, 0x5a, 0xc2, 0x77, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x23, 0xdf, 0xe7, 0x58, 0x5d, 0x05, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/api/pb/vpn.proto b/api/pb/vpn.proto index d3c4bcf..2275eba 100644 --- a/api/pb/vpn.proto +++ b/api/pb/vpn.proto @@ -10,6 +10,12 @@ enum VPNProto { TCP = 2; } +enum VPNLZOPref { + USE_LZO_NOPREF = 0; + USE_LZO_ENABLE = 1; + USE_LZO_DISABLE= 3; +} + message VPNStatusRequest {} message VPNInitRequest { string hostname = 1; @@ -25,6 +31,7 @@ message VPNInitRequest { message VPNUpdateRequest { string ip_block = 1; string dns = 2; + VPNLZOPref lzo_pref = 3; } message VPNRestartRequest {} @@ -68,6 +75,7 @@ message VPNStatusResponse { string dns = 11; string expires_at = 12; string ca_expires_at = 13; + bool use_lzo = 14; } message VPNInitResponse {} message VPNUpdateResponse {} diff --git a/api/rpc.go b/api/rpc.go index 7d900d5..5d693bd 100644 --- a/api/rpc.go +++ b/api/rpc.go @@ -1,6 +1,7 @@ package api import ( + "go.uber.org/thriftrw/ptr" "os" "time" @@ -132,7 +133,7 @@ func (s *UserService) Create(ctx context.Context, req *pb.UserCreateRequest) (*p NoGw: user.IsNoGW(), HostId: user.GetHostID(), IsAdmin: user.IsAdmin(), - Description: user.GetDescription(), + Description: user.GetDescription(), } ut = append(ut, &pbUser) @@ -354,6 +355,7 @@ func (s *VPNService) Status(ctx context.Context, req *pb.VPNStatusRequest) (*pb. Dns: server.GetDNS(), ExpiresAt: server.ExpiresAt().UTC().Format(time.RFC3339), CaExpiresAt: server.CAExpiresAt().UTC().Format(time.RFC3339), + UseLzo: server.IsUseLZO(), } return &response, nil } @@ -396,7 +398,14 @@ func (s *VPNService) Update(ctx context.Context, req *pb.VPNUpdateRequest) (*pb. return nil, grpc.Errorf(codes.PermissionDenied, "ovpm.UpdateVPNPerm is required for this operation.") } - if err := ovpm.TheServer().Update(req.IpBlock, req.Dns); err != nil { + var useLzo *bool + switch req.LzoPref { + case pb.VPNLZOPref_USE_LZO_ENABLE: + useLzo = ptr.Bool(true) + case pb.VPNLZOPref_USE_LZO_DISABLE: + useLzo = ptr.Bool(false) + } + if err := ovpm.TheServer().Update(req.IpBlock, req.Dns, useLzo); err != nil { logrus.Errorf("server can not be updated: %v", err) } return &pb.VPNUpdateResponse{}, nil diff --git a/cmd/ovpm/action_vpn.go b/cmd/ovpm/action_vpn.go index 3feddac..544fcd5 100644 --- a/cmd/ovpm/action_vpn.go +++ b/cmd/ovpm/action_vpn.go @@ -64,6 +64,8 @@ func vpnStatusAction(rpcServURLStr string) error { table.Append([]string{"DNS", vpnStatusResp.Dns}) table.Append([]string{"Cert Exp", vpnStatusResp.ExpiresAt}) table.Append([]string{"CA Cert Exp", vpnStatusResp.CaExpiresAt}) + table.Append([]string{"Use LZO", fmt.Sprintf("%t", vpnStatusResp.UseLzo)}) + table.Render() return nil @@ -117,7 +119,7 @@ func vpnInitAction(params vpnInitParams) error { return nil } -func vpnUpdateAction(rpcServURLStr string, netCIDR *string, dnsAddr *string) error { +func vpnUpdateAction(rpcServURLStr string, netCIDR *string, dnsAddr *string, useLzo *bool) error { // Parse RPC Server's URL. rpcSrvURL, err := url.Parse(rpcServURLStr) if err != nil { @@ -171,6 +173,19 @@ func vpnUpdateAction(rpcServURLStr string, netCIDR *string, dnsAddr *string) err targetDNSAddr = *dnsAddr } + // Set USE-LZO preference if provided. + var targetLZOPref pb.VPNLZOPref + if useLzo == nil { + targetLZOPref = pb.VPNLZOPref_USE_LZO_NOPREF + } else { + if *useLzo == true { + targetLZOPref = pb.VPNLZOPref_USE_LZO_ENABLE + } + if *useLzo == false { + targetLZOPref = pb.VPNLZOPref_USE_LZO_DISABLE + } + } + // Prepare service caller. var vpnSvc = pb.NewVPNServiceClient(rpcConn) @@ -178,6 +193,7 @@ func vpnUpdateAction(rpcServURLStr string, netCIDR *string, dnsAddr *string) err _, err = vpnSvc.Update(context.Background(), &pb.VPNUpdateRequest{ IpBlock: targetNetCIDR, Dns: targetDNSAddr, + LzoPref: targetLZOPref, }) if err != nil { err := errors.UnknownGRPCError(err) @@ -186,9 +202,10 @@ func vpnUpdateAction(rpcServURLStr string, netCIDR *string, dnsAddr *string) err } logrus.WithFields(logrus.Fields{ - "SERVER": "OpenVPN", - "CIDR": targetNetCIDR, - "DNS": targetDNSAddr, + "SERVER": "OpenVPN", + "CIDR": targetNetCIDR, + "DNS": targetDNSAddr, + "USE_LZO": targetLZOPref.String(), }).Infoln("changes applied") return nil diff --git a/cmd/ovpm/cmd_vpn.go b/cmd/ovpm/cmd_vpn.go index 11052d5..338b76c 100644 --- a/cmd/ovpm/cmd_vpn.go +++ b/cmd/ovpm/cmd_vpn.go @@ -2,13 +2,13 @@ package main import ( "fmt" - "github.com/asaskevich/govalidator" "github.com/cad/ovpm" "github.com/cad/ovpm/api/pb" "github.com/cad/ovpm/errors" "github.com/sirupsen/logrus" "github.com/urfave/cli" + "go.uber.org/thriftrw/ptr" ) var vpnStatusCommand = cli.Command{ @@ -204,6 +204,14 @@ var vpnUpdateCommand = cli.Command{ Name: "dns, d", Usage: fmt.Sprintf("DNS server to push to clients (default: %s)", ovpm.DefaultVPNDNS), }, + cli.BoolFlag{ + Name: "enable-use-lzo", + Usage: fmt.Sprintf("Enable use of the deprecated lzo compression algorithm to support older clients."), + }, + cli.BoolFlag{ + Name: "disable-use-lzo", + Usage: fmt.Sprintf("Disable use of the deprecated lzo compression algorithm to support older clients."), + }, }, Action: func(c *cli.Context) error { action = "vpn:update" @@ -223,12 +231,26 @@ var vpnUpdateCommand = cli.Command{ dnsAddr = &dns } + var useLzo *bool + if c.Bool("enable-use-lzo") && c.Bool("disable-use-lzo") { + e := fmt.Errorf("can not use --enable-use-lzo and --disable-use-lzo together") + fmt.Println(e.Error()) + exit(1) + return e + } + if enableLzo := c.Bool("enable-use-lzo"); enableLzo { + useLzo = ptr.Bool(true) + } + if disableLzo := c.Bool("disable-use-lzo"); disableLzo { + useLzo = ptr.Bool(false) + } + // If dry run, then don't call the action, just preprocess. if c.GlobalBool("dry-run") { return nil } - return vpnUpdateAction(fmt.Sprintf("grpc://localhost:%d", daemonPort), netCIDR, dnsAddr) + return vpnUpdateAction(fmt.Sprintf("grpc://localhost:%d", daemonPort), netCIDR, dnsAddr, useLzo) }, } diff --git a/go.mod b/go.mod index a7ed89e..af6c50d 100644 --- a/go.mod +++ b/go.mod @@ -28,6 +28,7 @@ require ( github.com/stretchr/testify v1.5.1 github.com/urfave/cli v1.22.3 go.mongodb.org/mongo-driver v1.3.1 // indirect + go.uber.org/thriftrw v1.24.0 golang.org/x/crypto v0.0.0-20200317142112-1b76d66859c6 // indirect golang.org/x/net v0.0.0-20200319234117-63522dbf7eec golang.org/x/sys v0.0.0-20200317113312-5766fd39f98d // indirect diff --git a/go.sum b/go.sum index 2e09ba9..4382a6f 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,7 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= +github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q= github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a h1:idn718Q4B6AGu/h5Sxe66HYVdqdGu2l9Iebqhi/AEoA= @@ -40,6 +41,8 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y= github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0= +github.com/fatih/structtag v1.0.0/go.mod h1:IKitwq45uXL/yqi5mYghiD3w9H6eTOvI9vnk8tXMphA= +github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= @@ -153,6 +156,7 @@ github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2V github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= @@ -169,6 +173,7 @@ github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.0.0 h1:b4Gk+7WdP/d3HZH8EJsZpvV7EtDOgaZLtnaNGIu1adA= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= @@ -176,6 +181,7 @@ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/grpc-ecosystem/grpc-gateway v1.14.3 h1:OCJlWkOUoTnl0neNGlf4fUm3TmbEtguw7vR+nGtnDjY= github.com/grpc-ecosystem/grpc-gateway v1.14.3/go.mod h1:6CwZWGDSPRJidgKAtJVvND6soZe6fT7iteq8wDPdhb0= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jinzhu/gorm v1.9.12 h1:Drgk1clyWT9t9ERbzHza6Mj/8FY/CqMyVzOiHviMo6Q= github.com/jinzhu/gorm v1.9.12/go.mod h1:vhTjlKSJUTWNtcbQtrMBFCxy7eXTzeCAzfL5fBZT/Qs= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= @@ -186,6 +192,7 @@ github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqx github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -270,16 +277,23 @@ go.mongodb.org/mongo-driver v1.3.0 h1:ew6uUIeJOo+qdUUv7LxFCUhtWmVv7ZV/Xuy4FAUsw2 go.mongodb.org/mongo-driver v1.3.0/go.mod h1:MSWZXKOynuguX+JSvwP8i+58jYCXxbia8HS3gZBapIE= go.mongodb.org/mongo-driver v1.3.1 h1:op56IfTQiaY2679w922KVWa3qcHdml2K/Io8ayAOUEQ= go.mongodb.org/mongo-driver v1.3.1/go.mod h1:MSWZXKOynuguX+JSvwP8i+58jYCXxbia8HS3gZBapIE= +go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/thriftrw v1.24.0 h1:vGEJA6CxTkCEshA4o0RP8dWHttkH+fu0lJ3z8cJfkj0= +go.uber.org/thriftrw v1.24.0/go.mod h1:IcIfSeZgc59AlYb0xr0DlDKIdD7SgjnFpG9BXCPyy9g= +go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c h1:Vj5n4GlwjmQteupaxJ9+0FNOmBrHfq7vN4btdGoDZgI= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190617133340-57b3e21c3d56/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200317142112-1b76d66859c6 h1:TjszyFsQsyZNHwdVdZ5m7bjmreu0znc2kRYsEml9/Ww= golang.org/x/crypto v0.0.0-20200317142112-1b76d66859c6/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -287,6 +301,9 @@ golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -297,6 +314,7 @@ golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8= @@ -342,6 +360,11 @@ golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgw golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190617190820-da514acc4774/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191226212025-6b505debf4bc/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -383,3 +406,4 @@ gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= diff --git a/vpn.go b/vpn.go index dd1cd4f..b5e0805 100644 --- a/vpn.go +++ b/vpn.go @@ -374,7 +374,7 @@ func (svr *Server) Init(hostname string, port string, proto string, ipblock stri } // Update updates VPN server attributes. -func (svr *Server) Update(ipblock string, dns string) error { +func (svr *Server) Update(ipblock string, dns string, useLzo *bool) error { if !svr.IsInitialized() { return fmt.Errorf("server is not initialized") } @@ -395,6 +395,10 @@ func (svr *Server) Update(ipblock string, dns string) error { svr.dbServerModel.DNS = dns changed = true } + if useLzo != nil { + svr.dbServerModel.UseLZO = *useLzo + changed = true + } if changed { db.Save(svr.dbServerModel) users, err := GetAllUsers() diff --git a/vpn_test.go b/vpn_test.go index 7f7e6ca..ec90cb0 100644 --- a/vpn_test.go +++ b/vpn_test.go @@ -1,6 +1,7 @@ package ovpm import ( + "fmt" "io" "reflect" "strings" @@ -121,23 +122,27 @@ func TestVPNUpdate(t *testing.T) { var updatetests = []struct { vpnnet string dns string + useLZO *bool vpnChanged bool dnsChanged bool }{ - {"", "", false, false}, - {"192.168.9.0/24", "", true, false}, - {"", "2.2.2.2", false, true}, - {"9.9.9.0/24", "1.1.1.1", true, true}, + {"", "", nil, false, false}, + {"192.168.9.0/24", "", nil, true, false}, + {"", "2.2.2.2", nil, false, true}, + {"9.9.9.0/24", "1.1.1.1", nil, true, true}, + {"9.9.9.0/24", "1.1.1.1", nil, true, true}, } - for _, tt := range updatetests { + for i, tt := range updatetests { svr := TheServer() + svr.Init("localhost", "", UDPProto, "", "", "", "", false) oldIP := svr.Net oldDNS := svr.DNS - svr.Update(tt.vpnnet, tt.dns) + svr.Update(tt.vpnnet, tt.dns, tt.useLZO) svr = nil svr = TheServer() if (svr.Net != oldIP) != tt.vpnChanged { + fmt.Println(i, svr.Net, oldIP, svr.Net == oldIP, tt.vpnChanged) t.Fatalf("expected vpn change: %t but opposite happened", tt.vpnChanged) } if (svr.DNS != oldDNS) != tt.dnsChanged { From 22399f96c90059a764db829ca2461adffc0b41ff Mon Sep 17 00:00:00 2001 From: Mustafa Arici Date: Mon, 27 Jul 2020 21:35:07 +0300 Subject: [PATCH 2/2] release: v0.2.9 --- CHANGELOG.md | 6 ++++++ README.md | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9c7302..897b7f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,15 @@ # Change Log +## [v0.2.9](https://github.com/cad/ovpm/tree/v0.2.9) + +- CLI options to enable comp-lzo back. +- Minor fixes. + ## [v0.2.8](https://github.com/cad/ovpm/tree/v0.2.8) - WebUI: dependency updates and switched to yarn (thanks to @drac) [\#92](https://github.com/cad/ovpm/pull/92) - CI: switched to Github Actions +- comp-lzo is now disabled by default (thanks to @archaron) [\#81](#81) - Minor fixes. diff --git a/README.md b/README.md index 2a1ef8a..63dfbc4 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ With OVPM you can create and run an OpenVPN server, add/remove VPN users, genera *This software is not stable yet. We recommend against using it for anything serious until, version 1.0 is released.* +**NOTICE: Version 0.2.8 comes with `comp-lzo` option disabled by default as it is deprecated by OpenVPN.** + **Roadmap** - [x] OpenVPN management functionality @@ -108,3 +110,19 @@ another computer. * [User Management](https://github.com/cad/ovpm/wiki/User-Management) * [Network Management](https://github.com/cad/ovpm/wiki/Network-Management) * [Web Interface](https://github.com/cad/ovpm/wiki/Web-Interface) + +# Troubleshooting + +## Q: My clients cannot connect to VPN after updating OVPM to v0.2.8 + +Since `comp-lzo` is disabled by default in OVPM v0.2.8, existing clients' .ovpn profiles became invalid. + +In order to solve this you have the options below: + +* Generate new .ovpn profile for existing clients +* Or manually remove `comp-lzo` line from clients .ovpn profiles yourself. +* Or you can upgrade to v0.2.9 and enable lzo option back by invoking the following command. +```bash +$ ovpm vpn update --enable-use-lzo +``` +But please note that this is not recommended as lzo option is [deprecated](https://community.openvpn.net/openvpn/wiki/DeprecatedOptions?__cf_chl_jschl_tk__=0468cbb180cdf21ca5119b591d260538cf788d30-1595873970-0-AY1Yn79gf57uYv2hrAKPwvzk-xuDvhY79eHrxJqWw1hpbapF-XgOJSsglI70HxmV78LDzJSz7m_A7eDhvzo_hCM-tx4UB7PfccKTtoHATGrOBqq4mHDhggN_EwJ7yee3fIzLgc9kvhL9pOCiISlE3NpbC0SOX21tYwFs1njdpOVGG4dHLMyudNKRGexapsQxiD2i23r30i_dzqS12QobGvPe96CuWS84ARjIRAUlutT6t5SxkccyOBunduDnbgYoB7RN8x7ab8y8Paim9ypizKiEHbxwP0Z2Y3lXByKdzHUUZSJzjzolHyRyQx-nSBuZQQ#Option:--comp-lzo) in OpenVPN. \ No newline at end of file