Skip to content

Commit e502cf6

Browse files
committed
Complete (vpn model)
1 parent d92ac65 commit e502cf6

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

api/v1/server/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func ApplyRoutes(r *gin.RouterGroup) {
1616
g := r.Group("/server")
1717
{
1818
g.GET("", readServer)
19-
g.PATCH("", updateServer)
19+
// g.PATCH("", updateServer)
2020
g.GET("/version", versionStr)
2121
}
2222
}

core/vpn.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ func CreateVPN(vpn *model.VPN) (*model.VPN, error) {
174174
}
175175
vpn = v.(*model.VPN)
176176

177+
vpn.Complete = util.BoolPtr(true)
177178
// data modified, dump new config
178179
return vpn, nil
179180
}
@@ -241,6 +242,7 @@ func ReadVPN(id string) (*model.VPN, error) {
241242
return nil, err
242243
}
243244
vpn := v.(*model.VPN)
245+
vpn.Complete = util.BoolPtr(true)
244246

245247
return vpn, nil
246248
}
@@ -445,6 +447,7 @@ func ReadVPNsForUser(email string) ([]*model.VPN, error) {
445447
}
446448
}
447449
if !found {
450+
vpn.Complete = util.BoolPtr(true)
448451
results = append(results, vpn)
449452
}
450453
}

model/vpn.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type VPN struct {
3131
Enable bool `json:"enable" bson:"enable"`
3232
ReadOnly *bool `json:"readonly,omitempty" bson:"readonly,omitempty"`
3333
Tags []string `json:"tags" bson:"tags"`
34+
Complete *bool `json:"complete,omitempty"` // complete indicates this is a complete record
3435
CreatedBy string `json:"createdBy" bson:"createdBy"`
3536
UpdatedBy string `json:"updatedBy" bson:"updatedBy"`
3637
Created *time.Time `json:"created" bson:"created"`

util/util.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ func GetCleanAuthToken(c *gin.Context) string {
3232
return token
3333
}
3434

35+
// BoolPtr returns a pointer to the boolean value
36+
func BoolPtr(b bool) *bool {
37+
if b {
38+
return &b
39+
}
40+
return nil
41+
}
42+
3543
func DuplicateEliminate(s []string) []string {
3644

3745
for i := 0; i < len(s); i++ {

0 commit comments

Comments
 (0)