Documentation ¶
Index ¶
- Constants
- func Close() error
- func GetHostname(r *http.Request) string
- func GetJSONReader(data interface{}, compression int) (r io.Reader, err error)
- func GetReqReader(r *http.Request) (io.ReadCloser, error)
- func GetRespReader(r *http.Response) (io.ReadCloser, error)
- func ListenAndServe(addr string, tlsConf *tls.Config, handler http.Handler) error
- func LoadTLSConf(certPath, keyPath, caPath string) (conf *tls.Config, err error)
- func TLSConf(cert, key, ca []byte) (conf *tls.Config, err error)
- type BandwidthLoggingClient
- type Client
- func (h *Client) Destroy()
- func (c *Client) GetClientConf(clientID string) (conf *sts.ClientConf, err error)
- func (c *Client) GetClientStatus(clientID, clientName, clientOS string) (status sts.ClientStatus, err error)
- func (h *Client) Recover() (partials []*sts.Partial, err error)
- func (h *Client) RecoverTransmission(payload sts.Payload) (n int, err error)
- func (c *Client) SetClientConfReceived(clientID string, when time.Time) error
- func (c *Client) SetClientState(clientID string, state sts.ClientState) (err error)
- func (h *Client) Transmit(payload sts.Payload) (n int, err error)
- func (h *Client) Validate(sent []sts.Pollable) (polled []sts.Polled, err error)
- type GracefulServer
- type Internal
- type Server
Constants ¶
const ( // HeaderSourceName is the custom HTTP header for communicating the name of // the sending host. HeaderSourceName = "X-STS-SrcName" // HeaderKey is the custom HTTP header for communicating the key (if applicable) // provided by the target. HeaderKey = "X-STS-Key" // HeaderMetaLen is the custom HTTP header that houses the JSON-encoded metadata // length for a bin. HeaderMetaLen = "X-STS-MetaLen" // HeaderPartCount is the custom HTTP resopnse header that indicates the number // of parts successfully received. HeaderPartCount = "X-STS-PartCount" // HeaderSep is the custom HTTP header used to indicate the path separator string // to be used for parsing paths in request/response data. HeaderSep = "X-STS-Sep" // HeaderContentType is the standard HTTP header for specifying the payload // type. HeaderContentType = "Content-Type" // HeaderContentEncoding is the standard HTTP header for specifying the payload // encoding. HeaderContentEncoding = "Content-Encoding" // HeaderGzip is the content encoding value for gzip compression. HeaderGzip = "gzip" // HeaderJSON is the content type value for JSON-encoded payload. HeaderJSON = "application/json" )
Variables ¶
This section is empty.
Functions ¶
func GetHostname ¶
GetHostname uses an http.Request object to determine the name of the sending host. Falls back to the IP address.
func GetJSONReader ¶
GetJSONReader takes an arbitrary struct and generates a JSON reader with no intermediate buffer. It will also add gzip compression at specified level.
func GetReqReader ¶
func GetReqReader(r *http.Request) (io.ReadCloser, error)
GetReqReader will return the appropriate reader for this request body based on the content type.
func GetRespReader ¶
func GetRespReader(r *http.Response) (io.ReadCloser, error)
GetRespReader will return the appropriate reader for this response body based on the content type.
func ListenAndServe ¶
ListenAndServe listens on the TCP network address addr using the DefaultServer. If the handler is nil, http.DefaultServeMux is used.
func LoadTLSConf ¶
LoadTLSConf returns a tls.Config reference based on provided paths.
Types ¶
type BandwidthLoggingClient ¶
func GetClient ¶
func GetClient( tlsConf *tls.Config, logInterval time.Duration, logPrefix string, ) (client *BandwidthLoggingClient, err error)
GetClient returns a secure http.Client instance pointer based on cert paths.
func (*BandwidthLoggingClient) Stop ¶
func (blc *BandwidthLoggingClient) Stop()
type Client ¶
type Client struct { SourceName string TargetHost string TargetPort int TargetPrefix string TargetKey string Compression int Timeout time.Duration TLS *tls.Config PartialsDecoder sts.DecodePartials BandwidthLogInterval time.Duration // contains filtered or unexported fields }
Client is the main client struct
func (*Client) GetClientConf ¶
func (c *Client) GetClientConf(clientID string) (conf *sts.ClientConf, err error)
GetClientConf to fulfill sts.ClientManager interface
func (*Client) GetClientStatus ¶
func (c *Client) GetClientStatus( clientID, clientName, clientOS string, ) (status sts.ClientStatus, err error)
GetClientStatus to fulfill sts.ClientManager interface
func (*Client) Recover ¶
Recover is of type sts.Recoverer and is responsible for retrieving partial files on the target
func (*Client) RecoverTransmission ¶
RecoverTransmission is of type sts.RecoverTransmission for querying how many parts of a failed transmission were successfully received.
func (*Client) SetClientConfReceived ¶
SetClientConfReceived to fulfill sts.ClientManager interface
func (*Client) SetClientState ¶
func (c *Client) SetClientState(clientID string, state sts.ClientState) (err error)
SetClientState to fulfill sts.ClientManager interface
type GracefulServer ¶
type GracefulServer struct {
// contains filtered or unexported fields
}
GracefulServer is net/http compatible graceful server. https://github.com/icub3d/graceful/blob/master/graceful.go
var DefaultServer *GracefulServer
DefaultServer is the default Server used by the functions in this package. It's used as to simplify using the graceful server.
func NewGracefulServer ¶
func NewGracefulServer(srv *http.Server, tlsConf *tls.Config) *GracefulServer
NewGracefulServer turns the given net/http server into a graceful server.
func (*GracefulServer) Close ¶
func (s *GracefulServer) Close() error
Close gracefully shuts down the listener. This should be called when the server should stop listening for new connection and finish any open connections.
func (*GracefulServer) ListenAndServe ¶
func (s *GracefulServer) ListenAndServe() error
ListenAndServe works like net/http.Server.ListenAndServe except that it gracefully shuts down when Close() is called. When that occurs, no new connections will be allowed and existing connections will be allowed to finish. This will not return until all existing connections have closed. Will use provided tls.Config for https if applicable.
type Internal ¶
type Internal struct { Port int Handlers map[string]http.HandlerFunc }
Internal responds to internal HTTP command requests for altering the behavior of the running executable
type Server ¶
type Server struct { ServeDir string Host string Port int PathPrefix string TLS *tls.Config Compression int GateKeepers map[string]sts.GateKeeper GateKeeperFactory sts.GateKeeperFactory DecoderFactory sts.PayloadDecoderFactory IsValid sts.RequestValidator ClientManager sts.ClientManager ChanceOfSimulatedFailure float64 // contains filtered or unexported fields }
Server responds to client HTTP requests