peer expiry feature: update api docs and readme

This commit is contained in:
Christoph Haas
2022-10-29 13:18:32 +02:00
parent c43e8d7ca2
commit 0f33871850
3 changed files with 109 additions and 125 deletions

View File

@@ -1,17 +1,10 @@
// Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// Package docs GENERATED BY SWAG; DO NOT EDIT
// This file was generated by swaggo/swag
package docs
import (
"bytes"
"encoding/json"
"strings"
"text/template"
import "github.com/swaggo/swag"
"github.com/swaggo/swag"
)
var doc = `{
const docTemplate = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
@@ -1267,10 +1260,13 @@ var doc = `{
"type": "string"
},
"Mtu": {
"type": "integer"
"type": "integer",
"maximum": 1500,
"minimum": 0
},
"PersistentKeepalive": {
"type": "integer"
"type": "integer",
"minimum": 0
}
}
},
@@ -1344,16 +1340,19 @@ var doc = `{
"type": "string"
},
"DefaultPersistentKeepalive": {
"type": "integer"
"type": "integer",
"minimum": 0
},
"DeviceName": {
"type": "string"
},
"DisplayName": {
"type": "string"
"type": "string",
"maxLength": 200
},
"FirewallMark": {
"type": "integer"
"type": "integer",
"minimum": 0
},
"IPsStr": {
"description": "comma separated list of the IPs of the client, wg-quick addition",
@@ -1364,7 +1363,9 @@ var doc = `{
},
"Mtu": {
"description": "the interface MTU, wg-quick addition",
"type": "integer"
"type": "integer",
"maximum": 1500,
"minimum": 0
},
"PostDown": {
"description": "post down script, wg-quick addition",
@@ -1399,7 +1400,11 @@ var doc = `{
"type": "boolean"
},
"Type": {
"type": "string"
"type": "string",
"enum": [
"client",
"server"
]
},
"UpdatedAt": {
"type": "string"
@@ -1438,11 +1443,18 @@ var doc = `{
"DeactivatedAt": {
"type": "string"
},
"DeactivatedReason": {
"type": "string"
},
"DeviceName": {
"type": "string"
},
"DeviceType": {
"type": "string"
"type": "string",
"enum": [
"client",
"server"
]
},
"Email": {
"type": "string"
@@ -1450,23 +1462,30 @@ var doc = `{
"Endpoint": {
"type": "string"
},
"ExpiresAt": {
"type": "string"
},
"IPsStr": {
"description": "a comma separated list of IPs of the client",
"type": "string"
},
"Identifier": {
"description": "Identifier AND Email make a WireGuard peer unique",
"type": "string"
"type": "string",
"maxLength": 64
},
"IgnoreGlobalSettings": {
"type": "boolean"
},
"Mtu": {
"description": "Global Device Settings (can be ignored, only make sense if device is in server mode)",
"type": "integer"
"type": "integer",
"maximum": 1500,
"minimum": 0
},
"PersistentKeepalive": {
"type": "integer"
"type": "integer",
"minimum": 0
},
"PresharedKey": {
"type": "string"
@@ -1502,56 +1521,18 @@ var doc = `{
}
}`
type swaggerInfo struct {
Version string
Host string
BasePath string
Schemes []string
Title string
Description string
}
// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = swaggerInfo{
Version: "1.0",
Host: "",
BasePath: "/api/v1",
Schemes: []string{},
Title: "WireGuard Portal API",
Description: "WireGuard Portal API for managing users and peers.",
}
type s struct{}
func (s *s) ReadDoc() string {
sInfo := SwaggerInfo
sInfo.Description = strings.Replace(sInfo.Description, "\n", "\\n", -1)
t, err := template.New("swagger_info").Funcs(template.FuncMap{
"marshal": func(v interface{}) string {
a, _ := json.Marshal(v)
return string(a)
},
"escape": func(v interface{}) string {
// escape tabs
str := strings.Replace(v.(string), "\t", "\\t", -1)
// replace " with \", and if that results in \\", replace that with \\\"
str = strings.Replace(str, "\"", "\\\"", -1)
return strings.Replace(str, "\\\\\"", "\\\\\\\"", -1)
},
}).Parse(doc)
if err != nil {
return doc
}
var tpl bytes.Buffer
if err := t.Execute(&tpl, sInfo); err != nil {
return doc
}
return tpl.String()
var SwaggerInfo = &swag.Spec{
Version: "1.0",
Host: "",
BasePath: "/api/v1",
Schemes: []string{},
Title: "WireGuard Portal API",
Description: "WireGuard Portal API for managing users and peers.",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
}
func init() {
swag.Register(swag.Name, &s{})
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
}