mirror of
https://github.com/openziti/zrok.git
synced 2025-06-23 19:22:19 +02:00
added bounds for /agent/access#[autoStartPort|autoEndPort] (#967)
This commit is contained in:
parent
6b995e0f35
commit
c761a6636c
@ -11,9 +11,11 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
|
"github.com/go-openapi/errors"
|
||||||
"github.com/go-openapi/runtime"
|
"github.com/go-openapi/runtime"
|
||||||
"github.com/go-openapi/strfmt"
|
"github.com/go-openapi/strfmt"
|
||||||
"github.com/go-openapi/swag"
|
"github.com/go-openapi/swag"
|
||||||
|
"github.com/go-openapi/validate"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RemoteAccessReader is a Reader for the RemoteAccess structure.
|
// RemoteAccessReader is a Reader for the RemoteAccess structure.
|
||||||
@ -301,12 +303,16 @@ type RemoteAccessBody struct {
|
|||||||
AutoAddress string `json:"autoAddress,omitempty"`
|
AutoAddress string `json:"autoAddress,omitempty"`
|
||||||
|
|
||||||
// auto end port
|
// auto end port
|
||||||
|
// Maximum: 65535
|
||||||
|
// Minimum: 1
|
||||||
AutoEndPort int64 `json:"autoEndPort,omitempty"`
|
AutoEndPort int64 `json:"autoEndPort,omitempty"`
|
||||||
|
|
||||||
// auto mode
|
// auto mode
|
||||||
AutoMode bool `json:"autoMode,omitempty"`
|
AutoMode bool `json:"autoMode,omitempty"`
|
||||||
|
|
||||||
// auto start port
|
// auto start port
|
||||||
|
// Maximum: 65535
|
||||||
|
// Minimum: 1
|
||||||
AutoStartPort int64 `json:"autoStartPort,omitempty"`
|
AutoStartPort int64 `json:"autoStartPort,omitempty"`
|
||||||
|
|
||||||
// bind address
|
// bind address
|
||||||
@ -324,6 +330,51 @@ type RemoteAccessBody struct {
|
|||||||
|
|
||||||
// Validate validates this remote access body
|
// Validate validates this remote access body
|
||||||
func (o *RemoteAccessBody) Validate(formats strfmt.Registry) error {
|
func (o *RemoteAccessBody) Validate(formats strfmt.Registry) error {
|
||||||
|
var res []error
|
||||||
|
|
||||||
|
if err := o.validateAutoEndPort(formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := o.validateAutoStartPort(formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(res) > 0 {
|
||||||
|
return errors.CompositeValidationError(res...)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *RemoteAccessBody) validateAutoEndPort(formats strfmt.Registry) error {
|
||||||
|
if swag.IsZero(o.AutoEndPort) { // not required
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := validate.MinimumInt("body"+"."+"autoEndPort", "body", o.AutoEndPort, 1, false); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := validate.MaximumInt("body"+"."+"autoEndPort", "body", o.AutoEndPort, 65535, false); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *RemoteAccessBody) validateAutoStartPort(formats strfmt.Registry) error {
|
||||||
|
if swag.IsZero(o.AutoStartPort) { // not required
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := validate.MinimumInt("body"+"."+"autoStartPort", "body", o.AutoStartPort, 1, false); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := validate.MaximumInt("body"+"."+"autoStartPort", "body", o.AutoStartPort, 65535, false); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,13 +206,17 @@ func init() {
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"autoEndPort": {
|
"autoEndPort": {
|
||||||
"type": "integer"
|
"type": "integer",
|
||||||
|
"maximum": 65535,
|
||||||
|
"minimum": 1
|
||||||
},
|
},
|
||||||
"autoMode": {
|
"autoMode": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
"autoStartPort": {
|
"autoStartPort": {
|
||||||
"type": "integer"
|
"type": "integer",
|
||||||
|
"maximum": 65535,
|
||||||
|
"minimum": 1
|
||||||
},
|
},
|
||||||
"bindAddress": {
|
"bindAddress": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -3026,13 +3030,17 @@ func init() {
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"autoEndPort": {
|
"autoEndPort": {
|
||||||
"type": "integer"
|
"type": "integer",
|
||||||
|
"maximum": 65535,
|
||||||
|
"minimum": 1
|
||||||
},
|
},
|
||||||
"autoMode": {
|
"autoMode": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
"autoStartPort": {
|
"autoStartPort": {
|
||||||
"type": "integer"
|
"type": "integer",
|
||||||
|
"maximum": 65535,
|
||||||
|
"minimum": 1
|
||||||
},
|
},
|
||||||
"bindAddress": {
|
"bindAddress": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
@ -9,9 +9,11 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/go-openapi/errors"
|
||||||
"github.com/go-openapi/runtime/middleware"
|
"github.com/go-openapi/runtime/middleware"
|
||||||
"github.com/go-openapi/strfmt"
|
"github.com/go-openapi/strfmt"
|
||||||
"github.com/go-openapi/swag"
|
"github.com/go-openapi/swag"
|
||||||
|
"github.com/go-openapi/validate"
|
||||||
|
|
||||||
"github.com/openziti/zrok/rest_model_zrok"
|
"github.com/openziti/zrok/rest_model_zrok"
|
||||||
)
|
)
|
||||||
@ -82,12 +84,16 @@ type RemoteAccessBody struct {
|
|||||||
AutoAddress string `json:"autoAddress,omitempty"`
|
AutoAddress string `json:"autoAddress,omitempty"`
|
||||||
|
|
||||||
// auto end port
|
// auto end port
|
||||||
|
// Maximum: 65535
|
||||||
|
// Minimum: 1
|
||||||
AutoEndPort int64 `json:"autoEndPort,omitempty"`
|
AutoEndPort int64 `json:"autoEndPort,omitempty"`
|
||||||
|
|
||||||
// auto mode
|
// auto mode
|
||||||
AutoMode bool `json:"autoMode,omitempty"`
|
AutoMode bool `json:"autoMode,omitempty"`
|
||||||
|
|
||||||
// auto start port
|
// auto start port
|
||||||
|
// Maximum: 65535
|
||||||
|
// Minimum: 1
|
||||||
AutoStartPort int64 `json:"autoStartPort,omitempty"`
|
AutoStartPort int64 `json:"autoStartPort,omitempty"`
|
||||||
|
|
||||||
// bind address
|
// bind address
|
||||||
@ -105,6 +111,51 @@ type RemoteAccessBody struct {
|
|||||||
|
|
||||||
// Validate validates this remote access body
|
// Validate validates this remote access body
|
||||||
func (o *RemoteAccessBody) Validate(formats strfmt.Registry) error {
|
func (o *RemoteAccessBody) Validate(formats strfmt.Registry) error {
|
||||||
|
var res []error
|
||||||
|
|
||||||
|
if err := o.validateAutoEndPort(formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := o.validateAutoStartPort(formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(res) > 0 {
|
||||||
|
return errors.CompositeValidationError(res...)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *RemoteAccessBody) validateAutoEndPort(formats strfmt.Registry) error {
|
||||||
|
if swag.IsZero(o.AutoEndPort) { // not required
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := validate.MinimumInt("body"+"."+"autoEndPort", "body", o.AutoEndPort, 1, false); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := validate.MaximumInt("body"+"."+"autoEndPort", "body", o.AutoEndPort, 65535, false); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *RemoteAccessBody) validateAutoStartPort(formats strfmt.Registry) error {
|
||||||
|
if swag.IsZero(o.AutoStartPort) { // not required
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := validate.MinimumInt("body"+"."+"autoStartPort", "body", o.AutoStartPort, 1, false); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := validate.MaximumInt("body"+"."+"autoStartPort", "body", o.AutoStartPort, 65535, false); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,8 +40,8 @@ class TestRemoteAccessRequest(unittest.TestCase):
|
|||||||
bind_address = '',
|
bind_address = '',
|
||||||
auto_mode = True,
|
auto_mode = True,
|
||||||
auto_address = '',
|
auto_address = '',
|
||||||
auto_start_port = 56,
|
auto_start_port = 1,
|
||||||
auto_end_port = 56,
|
auto_end_port = 1,
|
||||||
response_headers = [
|
response_headers = [
|
||||||
''
|
''
|
||||||
]
|
]
|
||||||
|
@ -17,8 +17,9 @@ import pprint
|
|||||||
import re # noqa: F401
|
import re # noqa: F401
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
|
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
|
||||||
from typing import Any, ClassVar, Dict, List, Optional
|
from typing import Any, ClassVar, Dict, List, Optional
|
||||||
|
from typing_extensions import Annotated
|
||||||
from typing import Optional, Set
|
from typing import Optional, Set
|
||||||
from typing_extensions import Self
|
from typing_extensions import Self
|
||||||
|
|
||||||
@ -31,8 +32,8 @@ class RemoteAccessRequest(BaseModel):
|
|||||||
bind_address: Optional[StrictStr] = Field(default=None, alias="bindAddress")
|
bind_address: Optional[StrictStr] = Field(default=None, alias="bindAddress")
|
||||||
auto_mode: Optional[StrictBool] = Field(default=None, alias="autoMode")
|
auto_mode: Optional[StrictBool] = Field(default=None, alias="autoMode")
|
||||||
auto_address: Optional[StrictStr] = Field(default=None, alias="autoAddress")
|
auto_address: Optional[StrictStr] = Field(default=None, alias="autoAddress")
|
||||||
auto_start_port: Optional[StrictInt] = Field(default=None, alias="autoStartPort")
|
auto_start_port: Optional[Annotated[int, Field(le=65535, strict=True, ge=1)]] = Field(default=None, alias="autoStartPort")
|
||||||
auto_end_port: Optional[StrictInt] = Field(default=None, alias="autoEndPort")
|
auto_end_port: Optional[Annotated[int, Field(le=65535, strict=True, ge=1)]] = Field(default=None, alias="autoEndPort")
|
||||||
response_headers: Optional[List[StrictStr]] = Field(default=None, alias="responseHeaders")
|
response_headers: Optional[List[StrictStr]] = Field(default=None, alias="responseHeaders")
|
||||||
__properties: ClassVar[List[str]] = ["envZId", "token", "bindAddress", "autoMode", "autoAddress", "autoStartPort", "autoEndPort", "responseHeaders"]
|
__properties: ClassVar[List[str]] = ["envZId", "token", "bindAddress", "autoMode", "autoAddress", "autoStartPort", "autoEndPort", "responseHeaders"]
|
||||||
|
|
||||||
|
@ -640,8 +640,12 @@ paths:
|
|||||||
type: string
|
type: string
|
||||||
autoStartPort:
|
autoStartPort:
|
||||||
type: integer
|
type: integer
|
||||||
|
minimum: 1
|
||||||
|
maximum: 65535
|
||||||
autoEndPort:
|
autoEndPort:
|
||||||
type: integer
|
type: integer
|
||||||
|
minimum: 1
|
||||||
|
maximum: 65535
|
||||||
responseHeaders:
|
responseHeaders:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user