Documentation ¶
Index ¶
- Variables
- type ClientCommonConf
- type HTTPProxy
- func (hp *HTTPProxy) Auth(req *http.Request, header string) bool
- func (hp *HTTPProxy) ConnectHandler(rw http.ResponseWriter, req *http.Request)
- func (hp *HTTPProxy) HTTPHandler(rw http.ResponseWriter, req *http.Request)
- func (hp *HTTPProxy) InfoHandler(rw http.ResponseWriter, req *http.Request)
- func (hp *HTTPProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)
- type HTTPService
- func (s *HTTPService) ExposedDomainPort() (string, string, error)
- func (s *HTTPService) GetCfg() *ServiceConf
- func (s *HTTPService) GetInfo() *ServiceInfo
- func (s *HTTPService) ModifyResponse(r *http.Response) error
- func (s *HTTPService) Serve(l net.Listener) (err error)
- func (s *HTTPService) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *HTTPService) SetExposedAddr(addr string)
- func (s *HTTPService) Shutdown(ctx context.Context) error
- type HTTPServiceConf
- type Server
- func (s *Server) AddService(svc *ServiceInfo) (*ServiceInfo, error)
- func (s *Server) DelService(ctx context.Context, name string) error
- func (s *Server) DeleteService(c *gin.Context)
- func (s *Server) GetServiceByName(c *gin.Context)
- func (s *Server) GetServices(c *gin.Context)
- func (s *Server) PostService(c *gin.Context)
- func (s *Server) PutService(c *gin.Context)
- func (s *Server) PutServiceExposedAddr(c *gin.Context)
- func (s *Server) PutServiceProxyAddr(c *gin.Context)
- func (s *Server) Serve(l net.Listener) error
- func (s *Server) ServeTLS(l net.Listener) error
- func (s *Server) Shutdown(ctx context.Context) error
- func (s *Server) UpdateService(ctx context.Context, name string, svc *ServiceInfo) (*ServiceInfo, error)
- type Service
- type ServiceClient
- func (c *ServiceClient) DialBindAddr(ctx context.Context, _ string, addr string) (net.Conn, error)
- func (c *ServiceClient) DialProxyAddr(ctx context.Context, _ string, addr string) (net.Conn, error)
- func (c *ServiceClient) Start(force bool) error
- func (c *ServiceClient) Stop(ctx context.Context) error
- type ServiceConf
- type ServiceInfo
- type ServiceReflector
- func (r *ServiceReflector) GetServiceInfo() *ServiceInfo
- func (r *ServiceReflector) Handle(conn net.Conn) error
- func (r *ServiceReflector) Listen() error
- func (r *ServiceReflector) Rename(name string) *ServiceInfo
- func (r *ServiceReflector) Running() bool
- func (r *ServiceReflector) Serve()
- func (r *ServiceReflector) Stop(ctx context.Context) error
- func (r *ServiceReflector) UpdateAddr(exposedAddr *string, proxyAddr *string)
- type TCPService
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrorServiceNotFound = errors.New("Service is not found")
)
Functions ¶
This section is empty.
Types ¶
type ClientCommonConf ¶
type ClientCommonConf struct { // ServerAddr specifies the address of the server to connect to. By // default, this value is "http://0.0.0.0:7001". Server string `ini:"server" json:"server"` // SkipTLSVerify willl skip the check of TLS certificates. SkipTLSVerify bool `ini:"skip_verify" json:"skip_verify"` // HeartBeatInterval specifies at what interval heartbeats are sent to the // server, in seconds. It is not recommended to change this value. By // default, this value is 30. HeartbeatInterval int64 `ini:"heartbeat_interval" json:"heartbeat_interval"` // HeartBeatTimeout specifies the maximum allowed heartbeat response delay // before the connection is terminated, in seconds. It is not recommended // to change this value. By default, this value is 90. HeartbeatTimeout int64 `ini:"heartbeat_timeout" json:"heartbeat_timeout"` // RequestTimeout specifies the timeout for any API request in seconds. // By default, this value is 5. RequestTimeout int64 `ini:"request_timeout" json:"request_timeout"` // UseIPv6 specifies if the connection to server should use IPv6 instead of IPv4. // By default, this value is false. UseIPv6 bool `ini:"use_ipv6" json:"use_ipv6"` // ServiceInfoPath specifies a directory for service info to be saved to. // External services can obtain the exposed address and port from the file. // By default, this value is /run/fcbreak/services/ ServicesInfoPath string `ini:"services_info_path" json:"services_info_path"` }
func GetDefaultClientConf ¶
func GetDefaultClientConf() ClientCommonConf
type HTTPProxy ¶
type HTTPProxy struct {
// contains filtered or unexported fields
}
func NewHTTPProxy ¶ added in v0.2.0
func NewHTTPProxy(s *HTTPService) *HTTPProxy
func (*HTTPProxy) ConnectHandler ¶
func (hp *HTTPProxy) ConnectHandler(rw http.ResponseWriter, req *http.Request)
deprecated Hijack needs to SetReadDeadline on the Conn of the request, but if we use stream compression here, we may always get i/o timeout error.
func (*HTTPProxy) HTTPHandler ¶
func (hp *HTTPProxy) HTTPHandler(rw http.ResponseWriter, req *http.Request)
func (*HTTPProxy) InfoHandler ¶
func (hp *HTTPProxy) InfoHandler(rw http.ResponseWriter, req *http.Request)
type HTTPService ¶
type HTTPService struct {
// contains filtered or unexported fields
}
func NewHTTPService ¶ added in v0.3.0
func NewHTTPService(name string, cfg *ServiceConf) *HTTPService
func (*HTTPService) ExposedDomainPort ¶ added in v0.2.2
func (s *HTTPService) ExposedDomainPort() (string, string, error)
func (*HTTPService) GetCfg ¶ added in v0.3.0
func (s *HTTPService) GetCfg() *ServiceConf
func (*HTTPService) GetInfo ¶ added in v0.3.0
func (s *HTTPService) GetInfo() *ServiceInfo
func (*HTTPService) ModifyResponse ¶
func (s *HTTPService) ModifyResponse(r *http.Response) error
func (*HTTPService) ServeHTTP ¶
func (s *HTTPService) ServeHTTP(w http.ResponseWriter, r *http.Request)
HTTP Reverse Proxy Handler
func (*HTTPService) SetExposedAddr ¶ added in v0.3.6
func (s *HTTPService) SetExposedAddr(addr string)
type HTTPServiceConf ¶
type HTTPServiceConf struct { Hostname string `ini:"http_hostname"` Username string `ini:"http_username"` Password string `ini:"http_password"` CacheTime int `ini:"http_cache_time"` Redirect bool `ini:"http_redirect"` AltSvc bool `ini:"http_altsvc"` DDNSDomain string `ini:"http_ddns_domain"` NIPDomain string `ini:"http_nip_domain"` Backend string `ini:"http_backend"` ChainProxy string `ini:"http_proxy_chain"` TLSCert string `ini:"https_crt"` TLSKey string `ini:"https_key"` ProxyInsecure bool `ini:"https_proxy_skip_cert_verification"` }
type Server ¶
func (*Server) AddService ¶
func (s *Server) AddService(svc *ServiceInfo) (*ServiceInfo, error)
func (*Server) DeleteService ¶
func (*Server) GetServiceByName ¶
func (*Server) GetServices ¶
func (*Server) PostService ¶
func (*Server) PutService ¶
func (*Server) PutServiceExposedAddr ¶
func (*Server) PutServiceProxyAddr ¶
func (*Server) UpdateService ¶
func (s *Server) UpdateService(ctx context.Context, name string, svc *ServiceInfo) (*ServiceInfo, error)
type Service ¶
type Service interface { Serve(net.Listener) error Shutdown(context.Context) error GetCfg() *ServiceConf GetInfo() *ServiceInfo SetExposedAddr(addr string) }
func NewService ¶
func NewService(name string, cfg *ServiceConf) Service
type ServiceClient ¶
type ServiceClient struct {
// contains filtered or unexported fields
}
func NewServiceClient ¶
func NewServiceClient(svc Service, clientCfg *ClientCommonConf) *ServiceClient
func (*ServiceClient) DialBindAddr ¶
Use the binded address to dial
func (*ServiceClient) DialProxyAddr ¶
Use the binded address to dial
func (*ServiceClient) Start ¶
func (c *ServiceClient) Start(force bool) error
type ServiceConf ¶
type ServiceConf struct { Name string `ini:"-" json:"name"` Scheme string `ini:"type" json:"type"` LocalAddr string `ini:"local_ip" json:"local_ip"` LocalPort uint16 `ini:"local_port" json:"local_port"` BindAddr string `ini:"bind_addr" json:"bind_addr"` BindPort uint16 `ini:"bind_port" json:"bind_port"` RemoteAddr string `ini:"remote_addr" json:"remote_addr"` RemotePort uint16 `ini:"remote_port" json:"remote_port"` HTTPServiceConf `ini:",extends"` }
func GetDefaultServiceConf ¶
func GetDefaultServiceConf() ServiceConf
type ServiceInfo ¶
type ServiceInfo struct { Name string `json:"name" binding:"required"` RemoteAddr string `json:"remote_addr,omitempty"` ExposedAddr string `json:"exposed_addr,omitempty"` // address for direct connection ProxyAddr string `json:"proxy_addr,omitempty"` // address for proxy_protocol Scheme string `json:"scheme" binding:"required"` Hostnames []string `json:"hostnames,omitempty"` // binding hostname if scheme is supported }
type ServiceReflector ¶
type ServiceReflector struct {
// contains filtered or unexported fields
}
ServiceReflector is the implementation on Server-side.
func NewServiceReflector ¶
func NewServiceReflector(info *ServiceInfo) *ServiceReflector
func (*ServiceReflector) GetServiceInfo ¶
func (r *ServiceReflector) GetServiceInfo() *ServiceInfo
func (*ServiceReflector) Handle ¶
func (r *ServiceReflector) Handle(conn net.Conn) error
Handle an client request
func (*ServiceReflector) Listen ¶
func (r *ServiceReflector) Listen() error
func (*ServiceReflector) Rename ¶
func (r *ServiceReflector) Rename(name string) *ServiceInfo
func (*ServiceReflector) Running ¶
func (r *ServiceReflector) Running() bool
func (*ServiceReflector) Serve ¶
func (r *ServiceReflector) Serve()
func (*ServiceReflector) UpdateAddr ¶
func (r *ServiceReflector) UpdateAddr(exposedAddr *string, proxyAddr *string)
type TCPService ¶ added in v0.3.0
type TCPService struct {
// contains filtered or unexported fields
}
func NewTCPService ¶ added in v0.3.0
func NewTCPService(name string, cfg *ServiceConf) *TCPService
func (*TCPService) GetCfg ¶ added in v0.3.0
func (s *TCPService) GetCfg() *ServiceConf
func (*TCPService) GetInfo ¶ added in v0.3.0
func (s *TCPService) GetInfo() *ServiceInfo
func (*TCPService) Handle ¶ added in v0.3.0
func (s *TCPService) Handle(conn net.Conn) error
Handle raw connection
func (*TCPService) SetExposedAddr ¶ added in v0.3.6
func (s *TCPService) SetExposedAddr(addr string)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.