vproxy_config

package
v0.0.0-...-8b4fbd1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const ApiVersion = CurrentVersion
View Source
const CurrentVersion = "app.vproxy.io/v1alpha1"

Variables

View Source
var AvailableKind = []string{
	"TcpLb", "tcp-lb", "tl",
	"Socks5Server", "socks5-server", "socks5",
	"DnsServer", "dns-server", "dns",
	"Upstream", "upstream", "ups",
	"ServerGroup", "server-group", "sg",
	"SecurityGroup", "security-group", "secg",
	"CertKey", "cert-key", "ck",
}
View Source
var KindMap = map[string]string{
	"server-group": "ServerGroup",
	"sg":           "ServerGroup",

	"security-group": "SecurityGroup",
	"secg":           "SecurityGroup",

	"cert-key": "CertKey",
	"ck":       "CertKey",

	"upstream": "Upstream",
	"ups":      "Upstream",

	"tcp-lb": "TcpLb",
	"tl":     "TcpLb",

	"socks5-server": "Socks5Server",
	"socks5":        "Socks5Server",

	"dns-server": "DnsServer",
	"dns":        "DnsServer",
}
View Source
var TypeOrderForApplying = []string{

	"ServerGroup",
	"SecurityGroup",
	"CertKey",

	"Upstream",

	"TcpLb",
	"Socks5Server",
	"DnsServer",
}
View Source
var Versions = []string{
	CurrentVersion,
}

Functions

func CertName

func CertName(s string, idx int) string

func GetHost

func GetHost() string

func GetHttpPort

func GetHttpPort() int

func GetWorkingDir

func GetWorkingDir() string

func IsCertKeyName

func IsCertKeyName(f string, s string) bool

func KeyName

func KeyName(s string) string

func PrintCertKey

func PrintCertKey(list []*CertKey, yaml bool)

func PrintDnsServer

func PrintDnsServer(list []*DnsServer, yaml bool)

func PrintOneCertKey

func PrintOneCertKey(ck *CertKey, yaml bool)

func PrintOneDnsServer

func PrintOneDnsServer(dns *DnsServer, yaml bool)

func PrintOneSecurityGroup

func PrintOneSecurityGroup(secg *SecurityGroup, yaml bool)

func PrintOneServerGroup

func PrintOneServerGroup(sg *ServerGroup, yaml bool)

func PrintOneSocks5Server

func PrintOneSocks5Server(socks5 *Socks5Server, yaml bool)

func PrintOneTcpLb

func PrintOneTcpLb(tl *TcpLb, yaml bool)

func PrintOneUpstream

func PrintOneUpstream(ups *Upstream, yaml bool)

func PrintSecurityGroup

func PrintSecurityGroup(list []*SecurityGroup, yaml bool)

func PrintServerGroup

func PrintServerGroup(list []*ServerGroup, yaml bool)

func PrintSocks5Server

func PrintSocks5Server(list []*Socks5Server, yaml bool)

func PrintTcpLb

func PrintTcpLb(list []*TcpLb, yaml bool)

func PrintUpstream

func PrintUpstream(list []*Upstream, yaml bool)

func PrintYaml

func PrintYaml(list interface{})

func RunTodoList

func RunTodoList(todo []*Todo, logger *logr.Logger) error

func RunTodoListAndPrint

func RunTodoListAndPrint(todo []*Todo) error

func UtilGetAndPrintList

func UtilGetAndPrintList(typ string, yaml bool) error

func UtilGetAndPrintOne

func UtilGetAndPrintOne(typ string, name string, yaml bool) error

func UtilWatchAndPrint

func UtilWatchAndPrint(typ string) error

func WatchHealthCheck

func WatchHealthCheck(chnl chan *HealthCheckEventChannelMessage, stop chan bool) error

Types

type Base

type Base struct {
	ApiVersion string   `json:"apiVersion" yaml:"apiVersion"`
	Kind       string   `json:"kind" yaml:"kind"`
	Metadata   Metadata `json:"metadata" yaml:"metadata"`
}

func (*Base) GetBase

func (o *Base) GetBase() Base

func (*Base) Validate

func (o *Base) Validate() error

type CertKey

type CertKey struct {
	Base   `yaml:",inline"`
	Spec   CertKeySpec   `json:"spec" yaml:"spec"`
	Status CertKeyStatus `json:"status" yaml:"status"`
}

func GetCertKey

func GetCertKey(name string) (*CertKey, error)

func ListCertKey

func ListCertKey() ([]*CertKey, error)

func (*CertKey) GetBase

func (o *CertKey) GetBase() Base

func (*CertKey) Validate

func (o *CertKey) Validate() error

type CertKeySpec

type CertKeySpec struct {
	Pem PemCertKey `json:"pem" yaml:"pem"`
}

func (*CertKeySpec) DeepCopyInto

func (o *CertKeySpec) DeepCopyInto(out *CertKeySpec)

type CertKeyStatus

type CertKeyStatus struct {
	CertFiles []string `json:"certs" yaml:"certs"`
	KeyFile   string   `json:"key" yaml:"key"`
	KeySHA1   string   `json:"keySHA1" yaml:"keySHA1"`
}

func (*CertKeyStatus) DeepCopyInto

func (o *CertKeyStatus) DeepCopyInto(out *CertKeyStatus)

type Config

type Config interface {
	GetBase() Base
	Validate() error
}

func NewEntity

func NewEntity(kind string) (Config, error)

func ParseFile

func ParseFile(fileName string) ([]Config, error)

type ConfigSortingArrayForApplying

type ConfigSortingArrayForApplying []Config

func (ConfigSortingArrayForApplying) Len

func (ConfigSortingArrayForApplying) Less

func (arr ConfigSortingArrayForApplying) Less(i, j int) bool

func (ConfigSortingArrayForApplying) Swap

func (arr ConfigSortingArrayForApplying) Swap(i, j int)

type ConfigSortingArrayForDeleting

type ConfigSortingArrayForDeleting []Config

func (ConfigSortingArrayForDeleting) Len

func (ConfigSortingArrayForDeleting) Less

func (arr ConfigSortingArrayForDeleting) Less(i, j int) bool

func (ConfigSortingArrayForDeleting) Swap

func (arr ConfigSortingArrayForDeleting) Swap(i, j int)

type DnsServer

type DnsServer struct {
	Base `yaml:",inline"`
	Spec DnsServerSpec `json:"spec" yaml:"spec"`
}

func GetDnsServer

func GetDnsServer(name string) (*DnsServer, error)

func ListDnsServer

func ListDnsServer() ([]*DnsServer, error)

func (*DnsServer) GetBase

func (o *DnsServer) GetBase() Base

func (*DnsServer) Validate

func (o *DnsServer) Validate() error

type DnsServerSpec

type DnsServerSpec struct {
	Address string `json:"address" yaml:"address"`
	RRSets  string `json:"rrsets" yaml:"rrsets"`

	//+optional
	TTL *int `json:"ttl,omitempty" yaml:"ttl,omitempty"`

	//+optional
	SecurityGroup string `json:"securityGroup,omitempty" yaml:"securityGroup,omitempty"`
}

func (*DnsServerSpec) DeepCopyInto

func (o *DnsServerSpec) DeepCopyInto(out *DnsServerSpec)

type HealthCheckEvent

type HealthCheckEvent struct {
	Base        `yaml:",inline"`
	ServerGroup ServerGroupInHC `json:"serverGroup" yaml:"serverGroup"`
	Server      ServerStatus    `json:"server" yaml:"server"`
}

type HealthCheckEventChannelMessage

type HealthCheckEventChannelMessage struct {
	Evt HealthCheckEvent
	Err error
}

type HealthCheckEventOnWire

type HealthCheckEventOnWire struct {
	Server      vproxy_client_model.Server      `json:"server"`
	ServerGroup vproxy_client_model.ServerGroup `json:"serverGroup"`
}

type Metadata

type Metadata struct {
	Name        string            `json:"name" yaml:"name"`
	Annotations map[string]string `json:"annotations" yaml:"annotations"`
}

type Op

type Op string
const (
	OpCreate Op = "create"
	OpUpdate Op = "update"
	OpDelete Op = "delete"
	OpNone   Op = "none"
	Op404    Op = "404"
	OpText   Op = "syntax"
)

type PemCertKey

type PemCertKey struct {
	Certs []string `json:"certs" yaml:"certs"`
	Key   string   `json:"key" yaml:"key"`
}

func (*PemCertKey) DeepCopyInto

func (o *PemCertKey) DeepCopyInto(out *PemCertKey)

type SecurityGroup

type SecurityGroup struct {
	Base `yaml:",inline"`
	Spec SecurityGroupSpec `json:"spec" yaml:"spec"`
}

func GetSecurityGroup

func GetSecurityGroup(name string) (*SecurityGroup, error)

func ListSecurityGroup

func ListSecurityGroup() ([]*SecurityGroup, error)

func (*SecurityGroup) GetBase

func (o *SecurityGroup) GetBase() Base

func (*SecurityGroup) Validate

func (o *SecurityGroup) Validate() error

type SecurityGroupRule

type SecurityGroupRule struct {
	Name          string `json:"name" yaml:"name"`
	ClientNetwork string `json:"clientNetwork" yaml:"clientNetwork"`
	Protocol      string `json:"protocol" yaml:"protocol"`
	ServerPortMin int    `json:"serverPortMin" yaml:"serverPortMin"`
	ServerPortMax int    `json:"serverPortMax" yaml:"serverPortMax"`
	Rule          string `json:"rule" yaml:"rule"`
}

func (*SecurityGroupRule) DeepCopyInto

func (o *SecurityGroupRule) DeepCopyInto(out *SecurityGroupRule)

func (*SecurityGroupRule) Validate

func (o *SecurityGroupRule) Validate() error

type SecurityGroupSpec

type SecurityGroupSpec struct {
	DefaultRule string              `json:"defaultRule" yaml:"defaultRule"`
	Rules       []SecurityGroupRule `json:"rules" yaml:"rules"`
}

func (*SecurityGroupSpec) DeepCopyInto

func (o *SecurityGroupSpec) DeepCopyInto(out *SecurityGroupSpec)

type ServerGroup

type ServerGroup struct {
	Base   `yaml:",inline"`
	Spec   ServerGroupSpec   `json:"spec" yaml:"spec"`
	Status ServerGroupStatus `json:"status" yaml:"status"`
}

func GetServerGroup

func GetServerGroup(name string) (*ServerGroup, error)

func ListServerGroup

func ListServerGroup() ([]*ServerGroup, error)

func (*ServerGroup) GetBase

func (o *ServerGroup) GetBase() Base

func (*ServerGroup) Validate

func (o *ServerGroup) Validate() error

type ServerGroupInHC

type ServerGroupInHC struct {
	Base `yaml:",inline"`
	Spec ServerGroupSelfSpec `json:"spec" yaml:"spec"`
}

type ServerGroupInUpstream

type ServerGroupInUpstream struct {
	Name string `json:"name" yaml:"name"`

	//+optional
	Weight *int `json:"weight,omitempty" yaml:"weight,omitempty"`

	//+optional
	Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
}

func (*ServerGroupInUpstream) DeepCopyInto

func (o *ServerGroupInUpstream) DeepCopyInto(out *ServerGroupInUpstream)

func (*ServerGroupInUpstream) Validate

func (o *ServerGroupInUpstream) Validate() error

type ServerGroupSelfSpec

type ServerGroupSelfSpec struct {
	Timeout int `json:"timeout" yaml:"timeout"`
	Period  int `json:"period" yaml:"period"`
	Up      int `json:"up" yaml:"up"`
	Down    int `json:"down" yaml:"down"`

	//+optional
	Protocol string `json:"protocol,omitempty" yaml:"protocol,omitempty"`

	//+optional
	Method string `json:"method,omitempty" yaml:"method,omitempty"`
}

func (*ServerGroupSelfSpec) DeepCopyInto

func (o *ServerGroupSelfSpec) DeepCopyInto(out *ServerGroupSelfSpec)

type ServerGroupSpec

type ServerGroupSpec struct {
	ServerGroupSelfSpec `json:",inline" yaml:",inline"`
	Servers             ServerInServerGroup `json:"servers" yaml:"servers"`
}

func (*ServerGroupSpec) DeepCopyInto

func (o *ServerGroupSpec) DeepCopyInto(out *ServerGroupSpec)

type ServerGroupStatus

type ServerGroupStatus struct {
	Servers []ServerStatus `json:"servers" yaml:"servers"`
}

func (*ServerGroupStatus) DeepCopyInto

func (o *ServerGroupStatus) DeepCopyInto(out *ServerGroupStatus)

type ServerInServerGroup

type ServerInServerGroup struct {
	Static []StaticServer `json:"static" yaml:"static"`
}

func (*ServerInServerGroup) DeepCopyInto

func (o *ServerInServerGroup) DeepCopyInto(out *ServerInServerGroup)

type ServerStatus

type ServerStatus struct {
	Name       string `json:"name" yaml:"name"`
	Address    string `json:"address" yaml:"address"`
	Weight     int    `json:"weight" yaml:"weight"`
	CurrentIp  string `json:"currentIp" yaml:"currentIp"`
	Status     string `json:"status" yaml:"status"`
	Cost       int    `json:"cost" yaml:"cost"`
	DownReason string `json:"downReason" yaml:"downReason"`
}

func (*ServerStatus) DeepCopyInto

func (o *ServerStatus) DeepCopyInto(out *ServerStatus)

type Socks5Server

type Socks5Server struct {
	Base `yaml:",inline"`
	Spec Socks5ServerSpec `json:"spec" yaml:"spec"`
}

func GetSocks5Server

func GetSocks5Server(name string) (*Socks5Server, error)

func ListSocks5Server

func ListSocks5Server() ([]*Socks5Server, error)

func (*Socks5Server) GetBase

func (o *Socks5Server) GetBase() Base

func (*Socks5Server) Validate

func (o *Socks5Server) Validate() error

type Socks5ServerSpec

type Socks5ServerSpec struct {
	Address string `json:"address" yaml:"address"`
	Backend string `json:"backend" yaml:"backend"`

	//+optional
	SecurityGroup string `json:"securityGroup,omitempty" yaml:"securityGroup,omitempty"`

	//+optional
	AllowNonBackend *bool `json:"allowNonBackend,omitempty" yaml:"allowNonBackend,omitempty"`
}

func (*Socks5ServerSpec) DeepCopyInto

func (o *Socks5ServerSpec) DeepCopyInto(out *Socks5ServerSpec)

type StaticServer

type StaticServer struct {
	Name    string `json:"name" yaml:"name"`
	Address string `json:"address" yaml:"address"`

	//+optional
	Weight *int `json:"weight,omitempty" yaml:"weight,omitempty"`
}

func (*StaticServer) DeepCopyInto

func (o *StaticServer) DeepCopyInto(out *StaticServer)

func (*StaticServer) Validate

func (o *StaticServer) Validate() error

type TcpLb

type TcpLb struct {
	Base `yaml:",inline"`
	Spec TcpLbSpec `json:"spec" yaml:"spec"`
}

func GetTcpLb

func GetTcpLb(name string) (*TcpLb, error)

func ListTcpLb

func ListTcpLb() ([]*TcpLb, error)

func (*TcpLb) GetBase

func (o *TcpLb) GetBase() Base

func (*TcpLb) Validate

func (o *TcpLb) Validate() error

type TcpLbSpec

type TcpLbSpec struct {
	Address string `json:"address" yaml:"address"`
	Backend string `json:"backend" yaml:"backend"`

	//+optional
	Protocol string `json:"protocol,omitempty" yaml:"protocol,omitempty"`

	//+optional
	ListOfCertKey []string `json:"listOfCertKey,omitempty" yaml:"listOfCertKey,omitempty"`

	//+optional
	SecurityGroup string `json:"securityGroup,omitempty" yaml:"securityGroup,omitempty"`
}

func (*TcpLbSpec) DeepCopyInto

func (o *TcpLbSpec) DeepCopyInto(out *TcpLbSpec)

type Todo

type Todo struct {
	Op    Op
	Ref   string
	Index int

	F func(todo *Todo) error
	// contains filtered or unexported fields
}

func ApplyByConfig

func ApplyByConfig(configs []Config) ([]*Todo, error)

func ApplyByFile

func ApplyByFile(filename string) ([]*Todo, error)

func DeleteByConfig

func DeleteByConfig(configs []Config) ([]*Todo, error)

func DeleteByFile

func DeleteByFile(filename string) ([]*Todo, error)

func DeleteOne

func DeleteOne(kind string, name string) ([]*Todo, error)

type Upstream

type Upstream struct {
	Base `yaml:",inline"`
	Spec UpstreamSpec `json:"spec" yaml:"spec"`
}

func GetUpstream

func GetUpstream(name string) (*Upstream, error)

func ListUpstream

func ListUpstream() ([]*Upstream, error)

func (*Upstream) GetBase

func (o *Upstream) GetBase() Base

func (*Upstream) Validate

func (o *Upstream) Validate() error

type UpstreamSpec

type UpstreamSpec struct {
	ServerGroups []ServerGroupInUpstream `json:"serverGroups" yaml:"serverGroups"`
}

func (*UpstreamSpec) DeepCopyInto

func (o *UpstreamSpec) DeepCopyInto(out *UpstreamSpec)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL