Browse Source

Merge branch 'feat/change-dns-41' into dev

Mustafa Arici 8 years ago
parent
commit
ee82e38e6f
15 changed files with 451 additions and 79 deletions
  1. 10 1
      api/rpc.go
  2. 1 1
      bindata/bindata.go
  3. 1 0
      cmd/ovpm/main.go
  4. 67 1
      cmd/ovpm/vpn.go
  5. 3 0
      const.go
  6. 7 7
      net_test.go
  7. 2 0
      pb/user.pb.go
  8. 116 30
      pb/vpn.pb.go
  9. 46 0
      pb/vpn.pb.gw.go
  10. 15 0
      pb/vpn.proto
  11. 46 0
      pb/vpn.swagger.json
  12. 1 1
      template/server.conf.tmpl
  13. 10 10
      user_test.go
  14. 74 16
      vpn.go
  15. 52 12
      vpn_test.go

+ 10 - 1
api/rpc.go

@@ -187,6 +187,7 @@ func (s *VPNService) Status(ctx context.Context, req *pb.VPNStatusRequest) (*pb.
 		Net:          server.GetNet(),
 		Mask:         server.GetMask(),
 		CreatedAt:    server.GetCreatedAt(),
+		DNS:          server.GetDNS(),
 	}
 	return &response, nil
 }
@@ -203,12 +204,20 @@ func (s *VPNService) Init(ctx context.Context, req *pb.VPNInitRequest) (*pb.VPNI
 		proto = ovpm.UDPProto
 	}
 
-	if err := ovpm.Init(req.Hostname, req.Port, proto, req.IPBlock); err != nil {
+	if err := ovpm.Init(req.Hostname, req.Port, proto, req.IPBlock, req.DNS); err != nil {
 		logrus.Errorf("server can not be created: %v", err)
 	}
 	return &pb.VPNInitResponse{}, nil
 }
 
+func (s *VPNService) Update(ctx context.Context, req *pb.VPNUpdateRequest) (*pb.VPNUpdateResponse, error) {
+	logrus.Debugf("rpc call: vpn update")
+	if err := ovpm.Update(req.IPBlock, req.DNS); err != nil {
+		logrus.Errorf("server can not be updated: %v", err)
+	}
+	return &pb.VPNUpdateResponse{}, nil
+}
+
 type NetworkService struct{}
 
 func (s *NetworkService) List(ctx context.Context, req *pb.NetworkListRequest) (*pb.NetworkListResponse, error) {

File diff suppressed because it is too large
+ 1 - 1
bindata/bindata.go


+ 1 - 0
cmd/ovpm/main.go

@@ -54,6 +54,7 @@ func main() {
 			Subcommands: []cli.Command{
 				vpnStatusCommand,
 				vpnInitCommand,
+				vpnUpdateCommand,
 			},
 		},
 		{

+ 67 - 1
cmd/ovpm/vpn.go

@@ -37,6 +37,7 @@ var vpnStatusCommand = cli.Command{
 		table.Append([]string{"Network", res.Net})
 		table.Append([]string{"Netmask", res.Mask})
 		table.Append([]string{"Created At", res.CreatedAt})
+		table.Append([]string{"DNS", res.DNS})
 		table.Render()
 
 		return nil
@@ -65,6 +66,10 @@ var vpnInitCommand = cli.Command{
 			Name:  "net, n",
 			Usage: fmt.Sprintf("VPN network to give clients IP addresses from, in the CIDR form (default: %s)", ovpm.DefaultVPNNetwork),
 		},
+		cli.StringFlag{
+			Name:  "dns, d",
+			Usage: fmt.Sprintf("DNS server to push to clients (default: %s)", ovpm.DefaultVPNDNS),
+		},
 	},
 	Action: func(c *cli.Context) error {
 		action = "vpn:init"
@@ -96,6 +101,14 @@ var vpnInitCommand = cli.Command{
 			os.Exit(1)
 		}
 
+		dns := c.String("dns")
+		if dns != "" && !govalidator.IsIPv4(dns) {
+			fmt.Println("--dns takes an IPv4 address. e.g. 8.8.8.8")
+			fmt.Println()
+			fmt.Println(cli.ShowSubcommandHelp(c))
+			os.Exit(1)
+		}
+
 		conn := getConn(c.GlobalString("daemon-port"))
 		defer conn.Close()
 		vpnSvc := pb.NewVPNServiceClient(conn)
@@ -115,7 +128,7 @@ var vpnInitCommand = cli.Command{
 			okayResponses := []string{"y", "Y", "yes", "Yes", "YES"}
 			nokayResponses := []string{"n", "N", "no", "No", "NO"}
 			if stringInSlice(response, okayResponses) {
-				if _, err := vpnSvc.Init(context.Background(), &pb.VPNInitRequest{Hostname: hostname, Port: port, Protopref: proto, IPBlock: ipblock}); err != nil {
+				if _, err := vpnSvc.Init(context.Background(), &pb.VPNInitRequest{Hostname: hostname, Port: port, Protopref: proto, IPBlock: ipblock, DNS: dns}); err != nil {
 					logrus.Errorf("server can not be initialized: %v", err)
 					os.Exit(1)
 					return err
@@ -130,3 +143,56 @@ var vpnInitCommand = cli.Command{
 		return nil
 	},
 }
+
+var vpnUpdateCommand = cli.Command{
+	Name:    "update",
+	Usage:   "Update VPN server.",
+	Aliases: []string{"i"},
+	Flags: []cli.Flag{
+		cli.StringFlag{
+			Name:  "net, n",
+			Usage: fmt.Sprintf("VPN network to give clients IP addresses from, in the CIDR form (default: %s)", ovpm.DefaultVPNNetwork),
+		},
+		cli.StringFlag{
+			Name:  "dns, d",
+			Usage: fmt.Sprintf("DNS server to push to clients (default: %s)", ovpm.DefaultVPNDNS),
+		},
+	},
+	Action: func(c *cli.Context) error {
+		action = "vpn:update"
+
+		ipblock := c.String("net")
+		if ipblock != "" && !govalidator.IsCIDR(ipblock) {
+			fmt.Println("--net takes an ip network in the CIDR form. e.g. 10.9.0.0/24")
+			fmt.Println()
+			fmt.Println(cli.ShowSubcommandHelp(c))
+			os.Exit(1)
+		}
+
+		dns := c.String("dns")
+		if dns != "" && !govalidator.IsIPv4(dns) {
+			fmt.Println("--dns takes an IPv4 address. e.g. 8.8.8.8")
+			fmt.Println()
+			fmt.Println(cli.ShowSubcommandHelp(c))
+			os.Exit(1)
+		}
+
+		if !(ipblock != "" || dns != "") {
+			fmt.Println()
+			fmt.Println(cli.ShowSubcommandHelp(c))
+			os.Exit(1)
+		}
+
+		conn := getConn(c.GlobalString("daemon-port"))
+		defer conn.Close()
+		vpnSvc := pb.NewVPNServiceClient(conn)
+
+		if _, err := vpnSvc.Update(context.Background(), &pb.VPNUpdateRequest{IPBlock: ipblock, DNS: dns}); err != nil {
+			logrus.Errorf("server can not be updated: %v", err)
+			os.Exit(1)
+			return err
+		}
+		logrus.Info("ovpm server updated")
+		return nil
+	},
+}

+ 3 - 0
const.go

@@ -13,6 +13,9 @@ const (
 	// DefaultVPNNetwork is the default OpenVPN network to use.
 	DefaultVPNNetwork = "10.9.0.0/24"
 
+	// DefaultVPNDNS is the default DNS to push to clients.
+	DefaultVPNDNS = "8.8.8.8"
+
 	etcBasePath = "/etc/ovpm/"
 	varBasePath = "/var/db/ovpm/"
 

+ 7 - 7
net_test.go

@@ -9,7 +9,7 @@ func TestVPNCreateNewNetwork(t *testing.T) {
 	setupTestCase()
 	CreateDB("sqlite3", ":memory:")
 	defer db.Cease()
-	Init("localhost", "", UDPProto, "")
+	Init("localhost", "", UDPProto, "", "")
 
 	// Prepare:
 	// Test:
@@ -56,7 +56,7 @@ func TestVPNDeleteNetwork(t *testing.T) {
 	setupTestCase()
 	CreateDB("sqlite3", ":memory:")
 	defer db.Cease()
-	Init("localhost", "", UDPProto, "")
+	Init("localhost", "", UDPProto, "", "")
 
 	// Prepare:
 	// Test:
@@ -94,7 +94,7 @@ func TestVPNGetNetwork(t *testing.T) {
 	setupTestCase()
 	CreateDB("sqlite3", ":memory:")
 	defer db.Cease()
-	Init("localhost", "", UDPProto, "")
+	Init("localhost", "", UDPProto, "", "")
 
 	// Prepare:
 	// Test:
@@ -129,7 +129,7 @@ func TestVPNGetAllNetworks(t *testing.T) {
 	setupTestCase()
 	CreateDB("sqlite3", ":memory:")
 	defer db.Cease()
-	Init("localhost", "", UDPProto, "")
+	Init("localhost", "", UDPProto, "", "")
 
 	// Prepare:
 	// Test:
@@ -175,7 +175,7 @@ func TestNetAssociate(t *testing.T) {
 	setupTestCase()
 	CreateDB("sqlite3", ":memory:")
 	defer db.Cease()
-	Init("localhost", "", UDPProto, "")
+	Init("localhost", "", UDPProto, "", "")
 
 	// Prepare:
 	// Test:
@@ -220,7 +220,7 @@ func TestNetDissociate(t *testing.T) {
 	setupTestCase()
 	CreateDB("sqlite3", ":memory:")
 	defer db.Cease()
-	err := Init("localhost", "", UDPProto, "")
+	err := Init("localhost", "", UDPProto, "", "")
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -273,7 +273,7 @@ func TestNetGetAssociatedUsers(t *testing.T) {
 	setupTestCase()
 	CreateDB("sqlite3", ":memory:")
 	defer db.Cease()
-	Init("localhost", "", UDPProto, "")
+	Init("localhost", "", UDPProto, "", "")
 
 	// Prepare:
 	// Test:

+ 2 - 0
pb/user.pb.go

@@ -20,8 +20,10 @@ It has these top-level messages:
 	UserGenConfigResponse
 	VPNStatusRequest
 	VPNInitRequest
+	VPNUpdateRequest
 	VPNStatusResponse
 	VPNInitResponse
+	VPNUpdateResponse
 	NetworkCreateRequest
 	NetworkListRequest
 	NetworkDeleteRequest

+ 116 - 30
pb/vpn.pb.go

@@ -55,6 +55,7 @@ type VPNInitRequest struct {
 	Port      string   `protobuf:"bytes,2,opt,name=Port" json:"Port,omitempty"`
 	Protopref VPNProto `protobuf:"varint,3,opt,name=Protopref,enum=pb.VPNProto" json:"Protopref,omitempty"`
 	IPBlock   string   `protobuf:"bytes,4,opt,name=IPBlock" json:"IPBlock,omitempty"`
+	DNS       string   `protobuf:"bytes,5,opt,name=DNS" json:"DNS,omitempty"`
 }
 
 func (m *VPNInitRequest) Reset()                    { *m = VPNInitRequest{} }
@@ -90,6 +91,37 @@ func (m *VPNInitRequest) GetIPBlock() string {
 	return ""
 }
 
+func (m *VPNInitRequest) GetDNS() string {
+	if m != nil {
+		return m.DNS
+	}
+	return ""
+}
+
+type VPNUpdateRequest struct {
+	IPBlock string `protobuf:"bytes,1,opt,name=IPBlock" json:"IPBlock,omitempty"`
+	DNS     string `protobuf:"bytes,2,opt,name=DNS" json:"DNS,omitempty"`
+}
+
+func (m *VPNUpdateRequest) Reset()                    { *m = VPNUpdateRequest{} }
+func (m *VPNUpdateRequest) String() string            { return proto.CompactTextString(m) }
+func (*VPNUpdateRequest) ProtoMessage()               {}
+func (*VPNUpdateRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{2} }
+
+func (m *VPNUpdateRequest) GetIPBlock() string {
+	if m != nil {
+		return m.IPBlock
+	}
+	return ""
+}
+
+func (m *VPNUpdateRequest) GetDNS() string {
+	if m != nil {
+		return m.DNS
+	}
+	return ""
+}
+
 type VPNStatusResponse struct {
 	Name         string `protobuf:"bytes,1,opt,name=Name" json:"Name,omitempty"`
 	SerialNumber string `protobuf:"bytes,2,opt,name=SerialNumber" json:"SerialNumber,omitempty"`
@@ -101,12 +133,13 @@ type VPNStatusResponse struct {
 	Mask         string `protobuf:"bytes,8,opt,name=Mask" json:"Mask,omitempty"`
 	CreatedAt    string `protobuf:"bytes,9,opt,name=CreatedAt" json:"CreatedAt,omitempty"`
 	Proto        string `protobuf:"bytes,10,opt,name=Proto" json:"Proto,omitempty"`
+	DNS          string `protobuf:"bytes,11,opt,name=DNS" json:"DNS,omitempty"`
 }
 
 func (m *VPNStatusResponse) Reset()                    { *m = VPNStatusResponse{} }
 func (m *VPNStatusResponse) String() string            { return proto.CompactTextString(m) }
 func (*VPNStatusResponse) ProtoMessage()               {}
-func (*VPNStatusResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{2} }
+func (*VPNStatusResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{3} }
 
 func (m *VPNStatusResponse) GetName() string {
 	if m != nil {
@@ -178,19 +211,36 @@ func (m *VPNStatusResponse) GetProto() string {
 	return ""
 }
 
+func (m *VPNStatusResponse) GetDNS() string {
+	if m != nil {
+		return m.DNS
+	}
+	return ""
+}
+
 type VPNInitResponse struct {
 }
 
 func (m *VPNInitResponse) Reset()                    { *m = VPNInitResponse{} }
 func (m *VPNInitResponse) String() string            { return proto.CompactTextString(m) }
 func (*VPNInitResponse) ProtoMessage()               {}
-func (*VPNInitResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{3} }
+func (*VPNInitResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{4} }
+
+type VPNUpdateResponse struct {
+}
+
+func (m *VPNUpdateResponse) Reset()                    { *m = VPNUpdateResponse{} }
+func (m *VPNUpdateResponse) String() string            { return proto.CompactTextString(m) }
+func (*VPNUpdateResponse) ProtoMessage()               {}
+func (*VPNUpdateResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{5} }
 
 func init() {
 	proto.RegisterType((*VPNStatusRequest)(nil), "pb.VPNStatusRequest")
 	proto.RegisterType((*VPNInitRequest)(nil), "pb.VPNInitRequest")
+	proto.RegisterType((*VPNUpdateRequest)(nil), "pb.VPNUpdateRequest")
 	proto.RegisterType((*VPNStatusResponse)(nil), "pb.VPNStatusResponse")
 	proto.RegisterType((*VPNInitResponse)(nil), "pb.VPNInitResponse")
+	proto.RegisterType((*VPNUpdateResponse)(nil), "pb.VPNUpdateResponse")
 	proto.RegisterEnum("pb.VPNProto", VPNProto_name, VPNProto_value)
 }
 
@@ -207,6 +257,7 @@ const _ = grpc.SupportPackageIsVersion4
 type VPNServiceClient interface {
 	Status(ctx context.Context, in *VPNStatusRequest, opts ...grpc.CallOption) (*VPNStatusResponse, error)
 	Init(ctx context.Context, in *VPNInitRequest, opts ...grpc.CallOption) (*VPNInitResponse, error)
+	Update(ctx context.Context, in *VPNUpdateRequest, opts ...grpc.CallOption) (*VPNUpdateResponse, error)
 }
 
 type vPNServiceClient struct {
@@ -235,11 +286,21 @@ func (c *vPNServiceClient) Init(ctx context.Context, in *VPNInitRequest, opts ..
 	return out, nil
 }
 
+func (c *vPNServiceClient) Update(ctx context.Context, in *VPNUpdateRequest, opts ...grpc.CallOption) (*VPNUpdateResponse, error) {
+	out := new(VPNUpdateResponse)
+	err := grpc.Invoke(ctx, "/pb.VPNService/Update", in, out, c.cc, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 // Server API for VPNService service
 
 type VPNServiceServer interface {
 	Status(context.Context, *VPNStatusRequest) (*VPNStatusResponse, error)
 	Init(context.Context, *VPNInitRequest) (*VPNInitResponse, error)
+	Update(context.Context, *VPNUpdateRequest) (*VPNUpdateResponse, error)
 }
 
 func RegisterVPNServiceServer(s *grpc.Server, srv VPNServiceServer) {
@@ -282,6 +343,24 @@ func _VPNService_Init_Handler(srv interface{}, ctx context.Context, dec func(int
 	return interceptor(ctx, in, info, handler)
 }
 
+func _VPNService_Update_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(VPNUpdateRequest)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(VPNServiceServer).Update(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/pb.VPNService/Update",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(VPNServiceServer).Update(ctx, req.(*VPNUpdateRequest))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 var _VPNService_serviceDesc = grpc.ServiceDesc{
 	ServiceName: "pb.VPNService",
 	HandlerType: (*VPNServiceServer)(nil),
@@ -294,6 +373,10 @@ var _VPNService_serviceDesc = grpc.ServiceDesc{
 			MethodName: "Init",
 			Handler:    _VPNService_Init_Handler,
 		},
+		{
+			MethodName: "Update",
+			Handler:    _VPNService_Update_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "vpn.proto",
@@ -302,32 +385,35 @@ var _VPNService_serviceDesc = grpc.ServiceDesc{
 func init() { proto.RegisterFile("vpn.proto", fileDescriptor1) }
 
 var fileDescriptor1 = []byte{
-	// 423 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xcf, 0x72, 0xd3, 0x30,
-	0x10, 0xc6, 0xb1, 0xe3, 0x3a, 0xf1, 0x4e, 0x26, 0x38, 0xdb, 0x02, 0x22, 0xd3, 0x43, 0x47, 0xa7,
-	0x4c, 0x0e, 0xf1, 0x50, 0x6e, 0xbd, 0x95, 0x00, 0xd3, 0x1e, 0x30, 0x9a, 0x14, 0x72, 0x57, 0x8a,
-	0xe8, 0x78, 0x9a, 0x4a, 0x42, 0x52, 0x72, 0x87, 0x03, 0x2f, 0xc0, 0x4b, 0xf0, 0x3e, 0xbc, 0x02,
-	0x0f, 0xc2, 0x48, 0x76, 0xfe, 0x98,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3, 0x8c, 0x87, 0xee, 0xe9,
+	0x2f, 0x07, 0xa0, 0xc8, 0x59, 0x66, 0xdb, 0xf4, 0x46, 0x22, 0x07, 0xbf, 0x8c, 0x1c, 0x8f, 0xaa,
+	0x2b, 0x68, 0x5d, 0xdc, 0xe8, 0xf9, 0x1f, 0x68, 0x65, 0xe2, 0xd5, 0xb7, 0x1f, 0x3f, 0x1f, 0xdd,
+	0x61, 0xd4, 0x8f, 0xb7, 0xaf, 0xe3, 0xad, 0x51, 0x71, 0x4e, 0xf3, 0x33, 0x67, 0x82, 0x97, 0xe0,
+	0x15, 0x7e, 0x11, 0x2b, 0xe6, 0xde, 0xb1, 0x8e, 0x86, 0x2d, 0xac, 0xd2, 0x7a, 0x49, 0x5a, 0x83,
+	0xa8, 0x57, 0x6b, 0xa5, 0x2a, 0xb5, 0x85, 0x12, 0x07, 0xbf, 0x5c, 0x73, 0xe7, 0xad, 0x75, 0x5e,
+	0x3b, 0x6f, 0xed, 0x2c, 0xfe, 0xf6, 0xb6, 0xa1, 0xf9, 0x99, 0x33, 0x59, 0xf9, 0xf4, 0x6b, 0xbd,
+	0xf9, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x98, 0x14, 0x2a, 0x0b, 0x89, 0x03, 0x00, 0x00,
 }

+ 46 - 0
pb/vpn.pb.gw.go

@@ -54,6 +54,19 @@ func request_VPNService_Init_0(ctx context.Context, marshaler runtime.Marshaler,
 
 }
 
+func request_VPNService_Update_0(ctx context.Context, marshaler runtime.Marshaler, client VPNServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+	var protoReq VPNUpdateRequest
+	var metadata runtime.ServerMetadata
+
+	if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+		return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+	}
+
+	msg, err := client.Update(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+	return msg, metadata, err
+
+}
+
 // RegisterVPNServiceHandlerFromEndpoint is same as RegisterVPNServiceHandler but
 // automatically dials to "endpoint" and closes the connection when "ctx" gets done.
 func RegisterVPNServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
@@ -142,6 +155,35 @@ func RegisterVPNServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn
 
 	})
 
+	mux.Handle("POST", pattern_VPNService_Update_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+		ctx, cancel := context.WithCancel(ctx)
+		defer cancel()
+		if cn, ok := w.(http.CloseNotifier); ok {
+			go func(done <-chan struct{}, closed <-chan bool) {
+				select {
+				case <-done:
+				case <-closed:
+					cancel()
+				}
+			}(ctx.Done(), cn.CloseNotify())
+		}
+		inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+		rctx, err := runtime.AnnotateContext(ctx, mux, req)
+		if err != nil {
+			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+			return
+		}
+		resp, md, err := request_VPNService_Update_0(rctx, inboundMarshaler, client, req, pathParams)
+		ctx = runtime.NewServerMetadataContext(ctx, md)
+		if err != nil {
+			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+			return
+		}
+
+		forward_VPNService_Update_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+	})
+
 	return nil
 }
 
@@ -149,10 +191,14 @@ var (
 	pattern_VPNService_Status_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "vpn", "status"}, ""))
 
 	pattern_VPNService_Init_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "vpn", "init"}, ""))
+
+	pattern_VPNService_Update_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "vpn", "update"}, ""))
 )
 
 var (
 	forward_VPNService_Status_0 = runtime.ForwardResponseMessage
 
 	forward_VPNService_Init_0 = runtime.ForwardResponseMessage
+
+	forward_VPNService_Update_0 = runtime.ForwardResponseMessage
 )

+ 15 - 0
pb/vpn.proto

@@ -16,8 +16,15 @@ message VPNInitRequest {
   string Port = 2;
   VPNProto Protopref = 3;
   string IPBlock = 4;
+  string DNS = 5;
 }
 
+message VPNUpdateRequest {
+  string IPBlock = 1;
+  string DNS = 2;
+}
+
+
 service VPNService {
   rpc Status (VPNStatusRequest) returns (VPNStatusResponse) {
     option (google.api.http) = {
@@ -29,6 +36,12 @@ service VPNService {
       post: "/v1/vpn/init"
       body: "*"
     };}
+  rpc Update (VPNUpdateRequest) returns (VPNUpdateResponse) {
+    option (google.api.http) = {
+      post: "/v1/vpn/update"
+      body: "*"
+    };}
+
 }
 
 message VPNStatusResponse {
@@ -42,5 +55,7 @@ message VPNStatusResponse {
   string Mask = 8;
   string CreatedAt = 9;
   string Proto = 10;
+  string DNS = 11;
 }
 message VPNInitResponse {}
+message VPNUpdateResponse {}

+ 46 - 0
pb/vpn.swagger.json

@@ -66,6 +66,32 @@
           "VPNService"
         ]
       }
+    },
+    "/v1/vpn/update": {
+      "post": {
+        "operationId": "Update",
+        "responses": {
+          "200": {
+            "description": "",
+            "schema": {
+              "$ref": "#/definitions/pbVPNUpdateResponse"
+            }
+          }
+        },
+        "parameters": [
+          {
+            "name": "body",
+            "in": "body",
+            "required": true,
+            "schema": {
+              "$ref": "#/definitions/pbVPNUpdateRequest"
+            }
+          }
+        ],
+        "tags": [
+          "VPNService"
+        ]
+      }
     }
   },
   "definitions": {
@@ -83,6 +109,9 @@
         },
         "IPBlock": {
           "type": "string"
+        },
+        "DNS": {
+          "type": "string"
         }
       }
     },
@@ -133,8 +162,25 @@
         },
         "Proto": {
           "type": "string"
+        },
+        "DNS": {
+          "type": "string"
+        }
+      }
+    },
+    "pbVPNUpdateRequest": {
+      "type": "object",
+      "properties": {
+        "IPBlock": {
+          "type": "string"
+        },
+        "DNS": {
+          "type": "string"
         }
       }
+    },
+    "pbVPNUpdateResponse": {
+      "type": "object"
     }
   }
 }

+ 1 - 1
template/server.conf.tmpl

@@ -182,7 +182,7 @@ crl-verify {{ .CRLPath }}
 # The addresses below refer to the public
 # DNS servers provided by opendns.com.
 ;push "dhcp-option DNS 208.67.222.222"
-push "dhcp-option DNS 8.8.8.8"
+push "dhcp-option DNS {{ .DNS }}"
 
 # Uncomment this directive to allow different
 # clients to be able to "see" each other.

+ 10 - 10
user_test.go

@@ -13,7 +13,7 @@ func TestCreateNewUser(t *testing.T) {
 	// Initialize:
 	db := ovpm.CreateDB("sqlite3", ":memory:")
 	defer db.Cease()
-	ovpm.Init("localhost", "", ovpm.UDPProto, "")
+	ovpm.Init("localhost", "", ovpm.UDPProto, "", "")
 	server, _ := ovpm.GetServerInstance()
 
 	// Prepare:
@@ -84,7 +84,7 @@ func TestUserUpdate(t *testing.T) {
 	// Initialize:
 	db := ovpm.CreateDB("sqlite3", ":memory:")
 	defer db.Cease()
-	ovpm.Init("localhost", "", ovpm.UDPProto, "")
+	ovpm.Init("localhost", "", ovpm.UDPProto, "", "")
 
 	// Prepare:
 	username := "testUser"
@@ -122,7 +122,7 @@ func TestUserPasswordCorrect(t *testing.T) {
 	// Initialize:
 	db := ovpm.CreateDB("sqlite3", ":memory:")
 	defer db.Cease()
-	ovpm.Init("localhost", "", ovpm.UDPProto, "")
+	ovpm.Init("localhost", "", ovpm.UDPProto, "", "")
 
 	// Prepare:
 	initialPassword := "g00dp@ssW0rd9"
@@ -139,7 +139,7 @@ func TestUserPasswordReset(t *testing.T) {
 	// Initialize:
 	db := ovpm.CreateDB("sqlite3", ":memory:")
 	defer db.Cease()
-	ovpm.Init("localhost", "", ovpm.UDPProto, "")
+	ovpm.Init("localhost", "", ovpm.UDPProto, "", "")
 
 	// Prepare:
 	initialPassword := "g00dp@ssW0rd9"
@@ -166,7 +166,7 @@ func TestUserDelete(t *testing.T) {
 	// Initialize:
 	db := ovpm.CreateDB("sqlite3", ":memory:")
 	defer db.Cease()
-	ovpm.Init("localhost", "", ovpm.UDPProto, "")
+	ovpm.Init("localhost", "", ovpm.UDPProto, "", "")
 
 	// Prepare:
 	username := "testUser"
@@ -204,7 +204,7 @@ func TestUserGet(t *testing.T) {
 	// Initialize:
 	db := ovpm.CreateDB("sqlite3", ":memory:")
 	defer db.Cease()
-	ovpm.Init("localhost", "", ovpm.UDPProto, "")
+	ovpm.Init("localhost", "", ovpm.UDPProto, "", "")
 
 	// Prepare:
 	username := "testUser"
@@ -228,7 +228,7 @@ func TestUserGetAll(t *testing.T) {
 	// Initialize:
 	db := ovpm.CreateDB("sqlite3", ":memory:")
 	defer db.Cease()
-	ovpm.Init("localhost", "", ovpm.UDPProto, "")
+	ovpm.Init("localhost", "", ovpm.UDPProto, "", "")
 	count := 5
 
 	// Prepare:
@@ -266,14 +266,14 @@ func TestUserRenew(t *testing.T) {
 	// Initialize:
 	db := ovpm.CreateDB("sqlite3", ":memory:")
 	defer db.Cease()
-	ovpm.Init("localhost", "", ovpm.UDPProto, "")
+	ovpm.Init("localhost", "", ovpm.UDPProto, "", "")
 
 	// Prepare:
 	user, _ := ovpm.CreateNewUser("user", "1234", false, 0, true)
 
 	// Test:
 	// Re initialize the server.
-	ovpm.Init("example.com", "3333", ovpm.UDPProto, "") // This causes implicit Renew() on every user in the system.
+	ovpm.Init("example.com", "3333", ovpm.UDPProto, "", "") // This causes implicit Renew() on every user in the system.
 
 	// Fetch user back.
 	fetchedUser, _ := ovpm.GetUser(user.GetUsername())
@@ -288,7 +288,7 @@ func TestUserIPAllocator(t *testing.T) {
 	// Initialize:
 	db := ovpm.CreateDB("sqlite3", ":memory:")
 	defer db.Cease()
-	ovpm.Init("localhost", "", ovpm.UDPProto, "")
+	ovpm.Init("localhost", "", ovpm.UDPProto, "", "")
 
 	// Prepare:
 

+ 74 - 16
vpn.go

@@ -52,6 +52,7 @@ type dbServerModel struct {
 	Net      string // VPN network.
 	Mask     string // VPN network mask.
 	CRL      string // Certificate Revocation List
+	DNS      string // DNS servers to push to the clients.
 }
 
 // Server represents VPN server.
@@ -134,25 +135,19 @@ func (s *Server) GetCRL() string {
 	return s.CRL
 }
 
+// GetDNS returns vpn server's dns.
+func (s *Server) GetDNS() string {
+	if s.DNS != "" {
+		return s.DNS
+	}
+	return DefaultVPNDNS
+}
+
 // GetCreatedAt returns server's created at.
 func (s *Server) GetCreatedAt() string {
 	return s.CreatedAt.Format(time.UnixDate)
 }
 
-type _VPNServerConfig struct {
-	CertPath     string
-	KeyPath      string
-	CACertPath   string
-	CAKeyPath    string
-	CCDPath      string
-	CRLPath      string
-	DHParamsPath string
-	Net          string
-	Mask         string
-	Port         string
-	Proto        string
-}
-
 // Init regenerates keys and certs for a Root CA, gets initial settings for the VPN server
 // and saves them in the database.
 //
@@ -163,11 +158,15 @@ type _VPNServerConfig struct {
 //
 // Please note that, Init is potentially destructive procedure, it will cause invalidation of
 // existing .ovpn profiles of the current users. So it should be used carefully.
-func Init(hostname string, port string, proto string, ipblock string) error {
+func Init(hostname string, port string, proto string, ipblock string, dns string) error {
 	if port == "" {
 		port = DefaultVPNPort
 	}
 
+	if dns == "" {
+		dns = DefaultVPNDNS
+	}
+
 	switch proto {
 	case "":
 		proto = UDPProto
@@ -222,6 +221,10 @@ func Init(hostname string, port string, proto string, ipblock string) error {
 		return fmt.Errorf("validation error: hostname:`%s` should be either an ip address or a FQDN", hostname)
 	}
 
+	if !govalidator.IsIPv4(dns) {
+		return fmt.Errorf("validation error: dns:`%s` should be an ip address", dns)
+	}
+
 	ca, err := pki.NewCA()
 	if err != nil {
 		return fmt.Errorf("can not create ca creds: %s", err)
@@ -246,6 +249,7 @@ func Init(hostname string, port string, proto string, ipblock string) error {
 		CAKey:        ca.Key,
 		Net:          ipnet.IP.To4().String(),
 		Mask:         net.IP(ipnet.Mask).To4().String(),
+		DNS:          dns,
 	}
 
 	db.Create(&serverInstance)
@@ -272,6 +276,41 @@ func Init(hostname string, port string, proto string, ipblock string) error {
 	return nil
 }
 
+// Update updates VPN server attributes.
+func Update(ipblock string, dns string) error {
+	if !IsInitialized() {
+		return fmt.Errorf("server is not initialized")
+	}
+
+	server, err := GetServerInstance()
+	if err != nil {
+		return err
+	}
+
+	var changed bool
+	if ipblock != "" && govalidator.IsCIDR(ipblock) {
+		var ipnet *net.IPNet
+		_, ipnet, err = net.ParseCIDR(ipblock)
+		if err != nil {
+			return fmt.Errorf("can not parse CIDR %s: %v", ipblock, err)
+		}
+		server.dbServerModel.Net = ipnet.IP.To4().String()
+		server.dbServerModel.Mask = net.IP(ipnet.Mask).To4().String()
+		changed = true
+	}
+
+	if dns != "" && govalidator.IsIPv4(dns) {
+		server.dbServerModel.DNS = dns
+		changed = true
+	}
+	if changed {
+		db.Save(server.dbServerModel)
+		Emit()
+		logrus.Infof("server updated")
+	}
+	return nil
+}
+
 // Deinit deletes the VPN server from the database and frees the allocated resources.
 func Deinit() error {
 	if !IsInitialized() {
@@ -515,9 +554,27 @@ func emitServerConf() error {
 		proto = serverInstance.Proto
 	}
 
+	dns := DefaultVPNDNS
+	if serverInstance.DNS != "" {
+		dns = serverInstance.DNS
+	}
+
 	var result bytes.Buffer
 
-	server := _VPNServerConfig{
+	server := struct {
+		CertPath     string
+		KeyPath      string
+		CACertPath   string
+		CAKeyPath    string
+		CCDPath      string
+		CRLPath      string
+		DHParamsPath string
+		Net          string
+		Mask         string
+		Port         string
+		Proto        string
+		DNS          string
+	}{
 		CertPath:     _DefaultCertPath,
 		KeyPath:      _DefaultKeyPath,
 		CACertPath:   _DefaultCACertPath,
@@ -529,6 +586,7 @@ func emitServerConf() error {
 		Mask:         dbServer.Mask,
 		Port:         port,
 		Proto:        proto,
+		DNS:          dns,
 	}
 	data, err := bindata.Asset("template/server.conf.tmpl")
 	if err != nil {

+ 52 - 12
vpn_test.go

@@ -35,13 +35,13 @@ func TestVPNInit(t *testing.T) {
 	}
 
 	// Wrongfully initialize server.
-	err := Init("localhost", "asdf", UDPProto, "")
+	err := Init("localhost", "asdf", UDPProto, "", "")
 	if err == nil {
 		t.Fatalf("error is expected to be not nil but it's nil instead")
 	}
 
 	// Initialize the server.
-	Init("localhost", "", UDPProto, "")
+	Init("localhost", "", UDPProto, "", "")
 
 	// Check database if the database has no server.
 	var server2 dbServerModel
@@ -61,7 +61,7 @@ func TestVPNDeinit(t *testing.T) {
 
 	// Prepare:
 	// Initialize the server.
-	Init("localhost", "", UDPProto, "")
+	Init("localhost", "", UDPProto, "", "")
 	u, err := CreateNewUser("user", "p", false, 0, true)
 	if err != nil {
 		t.Fatal(err)
@@ -106,6 +106,46 @@ func TestVPNDeinit(t *testing.T) {
 		t.Errorf("revoked should be empty")
 	}
 }
+func TestVPNUpdate(t *testing.T) {
+	// Init:
+	setupTestCase()
+	CreateDB("sqlite3", ":memory:")
+	defer db.Cease()
+	// Prepare:
+	Init("localhost", "", UDPProto, "", "")
+	// Test:
+
+	var updatetests = []struct {
+		vpnnet     string
+		dns        string
+		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},
+	}
+	for _, tt := range updatetests {
+		server, err := GetServerInstance()
+		if err != nil {
+			t.Fatal(err)
+		}
+
+		oldIP := server.Net
+		oldDNS := server.DNS
+		Update(tt.vpnnet, tt.dns)
+		server = nil
+		server, err = GetServerInstance()
+		if (server.Net != oldIP) != tt.vpnChanged {
+			t.Fatalf("expected vpn change: %t but opposite happened", tt.vpnChanged)
+		}
+		if (server.DNS != oldDNS) != tt.dnsChanged {
+			t.Fatalf("expected vpn change: %t but opposite happened", tt.dnsChanged)
+		}
+	}
+
+}
 
 func TestVPNIsInitialized(t *testing.T) {
 	// Init:
@@ -122,7 +162,7 @@ func TestVPNIsInitialized(t *testing.T) {
 	}
 
 	// Initialize the server.
-	Init("localhost", "", UDPProto, "")
+	Init("localhost", "", UDPProto, "", "")
 
 	// Isn't initialized?
 	if !IsInitialized() {
@@ -152,7 +192,7 @@ func TestVPNGetServerInstance(t *testing.T) {
 	}
 
 	// Initialize server.
-	Init("localhost", "", UDPProto, "")
+	Init("localhost", "", UDPProto, "", "")
 
 	server, err = GetServerInstance()
 
@@ -172,7 +212,7 @@ func TestVPNDumpsClientConfig(t *testing.T) {
 	setupTestCase()
 	CreateDB("sqlite3", ":memory:")
 	defer db.Cease()
-	Init("localhost", "", UDPProto, "")
+	Init("localhost", "", UDPProto, "", "")
 
 	// Prepare:
 	user, _ := CreateNewUser("user", "password", false, 0, true)
@@ -194,7 +234,7 @@ func TestVPNDumpClientConfig(t *testing.T) {
 	setupTestCase()
 	CreateDB("sqlite3", ":memory:")
 	defer db.Cease()
-	Init("localhost", "", UDPProto, "")
+	Init("localhost", "", UDPProto, "", "")
 
 	// Prepare:
 	noGW := false
@@ -262,7 +302,7 @@ func TestVPNGetSystemCA(t *testing.T) {
 	}
 
 	// Initialize system.
-	Init("localhost", "", UDPProto, "")
+	Init("localhost", "", UDPProto, "", "")
 
 	ca, err = GetSystemCA()
 	if err != nil {
@@ -302,7 +342,7 @@ func TestVPNStartVPNProc(t *testing.T) {
 	}
 
 	// Initialize OVPM server.
-	Init("localhost", "", UDPProto, "")
+	Init("localhost", "", UDPProto, "", "")
 
 	// Call start again..
 	StartVPNProc()
@@ -318,7 +358,7 @@ func TestVPNStopVPNProc(t *testing.T) {
 	setupTestCase()
 	CreateDB("sqlite3", ":memory:")
 	defer db.Cease()
-	Init("localhost", "", UDPProto, "")
+	Init("localhost", "", UDPProto, "", "")
 
 	// Prepare:
 	vpnProc.Start()
@@ -342,7 +382,7 @@ func TestVPNRestartVPNProc(t *testing.T) {
 	// Init:
 	CreateDB("sqlite3", ":memory:")
 	defer db.Cease()
-	Init("localhost", "", UDPProto, "")
+	Init("localhost", "", UDPProto, "", "")
 
 	// Prepare:
 
@@ -371,7 +411,7 @@ func TestVPNEmit(t *testing.T) {
 	setupTestCase()
 	CreateDB("sqlite3", ":memory:")
 	defer db.Cease()
-	Init("localhost", "", UDPProto, "")
+	Init("localhost", "", UDPProto, "", "")
 
 	// Prepare:
 

Some files were not shown because too many files changed in this diff