Documentation ¶
Index ¶
- Constants
- Variables
- func AddGroup(name string, vs []string) (err error)
- func AddProxy(name string, vs []string) error
- func ApplyConfig(config IProxyConfig) (err error)
- func CheckSelector(method string) bool
- func DestroyServers()
- func Duration2Str(d time.Duration) string
- func EditGroup(name string, vs []string) (err error)
- func EditProxy(name string, vs []string) error
- func InitServers(gs []*ServerGroup, ss []*Server) error
- func ParseServer(v interface{}) (*ServerGroup, *Server, error)
- func RegisterProxyProtocolCreator(name string, p NewProtocol)
- func RegisterSelector(method string, newSelector NewSelector)
- func RemoveGroup(name string) (effects, deletes []string, err error)
- func RemoveProxy(name string) (effects, deletes []string, err error)
- func SelectRefresh(groupName string) error
- func SelectServer(groupName, serverName string) error
- func TestRTT(s IServer, testURL string) (rtt time.Duration, err error)
- type GroupExternal
- type IProtocol
- type IProxyConfig
- type IRequest
- type ISelector
- type IServer
- type NewProtocol
- type NewSelector
- type ProxyExternal
- type ProxyExternal2
- type Server
- type ServerGroup
Constants ¶
View Source
const ( ProxyDirect = "DIRECT" ProxyReject = "REJECT" ProxyGlobal = "GLOBAL" )
Variables ¶
View Source
var ( ErrorReject = errors.New("connection reject") ErrorServerNotFound = errors.New("server or server group not found") MockServer = &Server{Name: "MOCK"} FailedServer = &Server{Name: "FAILED"} RejectServer = &Server{Name: "REJECT"} )
View Source
var ErrorUnknowType = errors.New("unknow select type")
Functions ¶
func ApplyConfig ¶
func ApplyConfig(config IProxyConfig) (err error)
func CheckSelector ¶
func DestroyServers ¶
func DestroyServers()
func Duration2Str ¶
func InitServers ¶
func InitServers(gs []*ServerGroup, ss []*Server) error
func ParseServer ¶
func ParseServer(v interface{}) (*ServerGroup, *Server, error)
func RegisterProxyProtocolCreator ¶
func RegisterProxyProtocolCreator(name string, p NewProtocol)
func RegisterSelector ¶
func RegisterSelector(method string, newSelector NewSelector)
func RemoveGroup ¶
func RemoveProxy ¶
func SelectRefresh ¶
func SelectServer ¶
Types ¶
type GroupExternal ¶
type GroupExternal struct { Name string `json:"name"` SelectType string `json:"select_type"` Servers []*ProxyExternal2 `json:"servers"` Selected *ProxyExternal2 `json:"selected"` RttUrl string `json:"rtt_url"` }
func GetGroupExternals ¶
func GetGroupExternals(names ...string) []*GroupExternal
type IProxyConfig ¶
type ISelector ¶
type ISelector interface { Get() (*Server, error) Select(string) error Refresh() error Reset(group *ServerGroup) error Destroy() Current() IServer }
func GetSelector ¶
func GetSelector(method string, group *ServerGroup) (ISelector, error)
type NewProtocol ¶
type NewSelector ¶
type NewSelector func(group *ServerGroup) (ISelector, error)
type ProxyExternal ¶
type ProxyExternal struct { Name string `json:"name"` Rtt time.Duration `json:"rtt"` RttText string `json:"rtt_text"` Protocol string `json:"protocol"` }
func GetServerExternals ¶
func GetServerExternals() []*ProxyExternal
type ProxyExternal2 ¶
type ProxyExternal2 struct { ProxyExternal SubName string `json:"sub_name"` IsSelected bool `json:"is_selected"` }
type Server ¶
type Server struct { Name string Rtt time.Duration ProxyProtocol string RttUrl string IProtocol `json:"-"` }
func ProxyExist ¶
type ServerGroup ¶
type ServerGroup struct { Servers []interface{} Name string SelectType string Selector ISelector RttUrl string sync.RWMutex }
func GetGroups ¶
func GetGroups() []*ServerGroup
func GroupExist ¶
func GroupExist(name string) (*ServerGroup, bool)
func (*ServerGroup) GetName ¶
func (s *ServerGroup) GetName() string
func (*ServerGroup) GetRttRrl ¶
func (s *ServerGroup) GetRttRrl() string
func (*ServerGroup) GetServer ¶
func (s *ServerGroup) GetServer() (*Server, error)
func (*ServerGroup) Remove ¶
func (s *ServerGroup) Remove(name string) (isExist bool)
Click to show internal directories.
Click to hide internal directories.