mirror of
https://github.com/openziti/zrok.git
synced 2025-06-19 17:27:54 +02:00
better json naming/name indirection (#922)
This commit is contained in:
parent
76d83dad4e
commit
0c3f6347e3
@ -7,13 +7,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type AccessPrivateRequest struct {
|
type AccessPrivateRequest struct {
|
||||||
Token string
|
Token string `json:"token"`
|
||||||
BindAddress string
|
BindAddress string `json:"bind_address"`
|
||||||
AutoMode bool
|
AutoMode bool `json:"auto_mode"`
|
||||||
AutoAddress string
|
AutoAddress string `json:"auto_address"`
|
||||||
AutoStartPort uint16
|
AutoStartPort uint16 `json:"auto_start_port"`
|
||||||
AutoEndPort uint16
|
AutoEndPort uint16 `json:"auto_end_port"`
|
||||||
ResponseHeaders []string
|
ResponseHeaders []string `json:"response_headers"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type access struct {
|
type access struct {
|
||||||
|
@ -2,12 +2,16 @@ package agent
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const RegistryV = "1"
|
||||||
|
|
||||||
type Registry struct {
|
type Registry struct {
|
||||||
ReservedShares []*ShareReservedRequest
|
V string `json:"v"`
|
||||||
PrivateAccesses []*AccessPrivateRequest
|
ReservedShares []*ShareReservedRequest `json:"reserved_shares"`
|
||||||
|
PrivateAccesses []*AccessPrivateRequest `json:"private_accesses"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadRegistry(path string) (*Registry, error) {
|
func LoadRegistry(path string) (*Registry, error) {
|
||||||
@ -19,10 +23,14 @@ func LoadRegistry(path string) (*Registry, error) {
|
|||||||
if err := json.Unmarshal(data, r); err != nil {
|
if err := json.Unmarshal(data, r); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if r.V != RegistryV {
|
||||||
|
return nil, fmt.Errorf("invalid registry version '%v'; expected '%v", r.V, RegistryV)
|
||||||
|
}
|
||||||
return r, nil
|
return r, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registry) Save(path string) error {
|
func (r *Registry) Save(path string) error {
|
||||||
|
r.V = RegistryV
|
||||||
data, err := json.MarshalIndent(r, "", " ")
|
data, err := json.MarshalIndent(r, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -10,30 +10,30 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SharePrivateRequest struct {
|
type SharePrivateRequest struct {
|
||||||
Target string
|
Target string `json:"target"`
|
||||||
BackendMode string
|
BackendMode string `json:"backend_mode"`
|
||||||
Insecure bool
|
Insecure bool `json:"insecure"`
|
||||||
Closed bool
|
Closed bool `json:"closed"`
|
||||||
AccessGrants []string
|
AccessGrants []string `json:"access_grants"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SharePublicRequest struct {
|
type SharePublicRequest struct {
|
||||||
Target string
|
Target string `json:"target"`
|
||||||
BasicAuth []string
|
BasicAuth []string `json:"basic_auth"`
|
||||||
FrontendSelection []string
|
FrontendSelection []string `json:"frontend_selection"`
|
||||||
BackendMode string
|
BackendMode string `json:"backend_mode"`
|
||||||
Insecure bool
|
Insecure bool `json:"insecure"`
|
||||||
OauthProvider string
|
OauthProvider string `json:"oauth_provider"`
|
||||||
OauthEmailAddressPatterns []string
|
OauthEmailAddressPatterns []string `json:"oauth_email_address_patterns"`
|
||||||
OauthCheckInterval string
|
OauthCheckInterval string `json:"oauth_check_interval"`
|
||||||
Closed bool
|
Closed bool `json:"closed"`
|
||||||
AccessGrants []string
|
AccessGrants []string `json:"access_grants"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ShareReservedRequest struct {
|
type ShareReservedRequest struct {
|
||||||
Token string
|
Token string `json:"token"`
|
||||||
OverrideEndpoint string
|
OverrideEndpoint string `json:"override_endpoint"`
|
||||||
Insecure bool
|
Insecure bool `json:"insecure"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ShareReservedResponse struct {
|
type ShareReservedResponse struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user