Documentation ¶
Index ¶
- Variables
- func DialContext(ctx context.Context, address string, header http.Header) (*websocket.Conn, *http.Response, error)
- func ErrorFromResponse(response Response) error
- func SameDomainRedirectPolicy() resty.RedirectPolicyFunc
- type Client
- type IReverser
- type LeveledLogger
- type Opt
- type Response
- type Reverser
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnkown is returned when a non-mapped error occurred. ErrUnknown = errors.New("unknown error") // ErrConnectionFailed is returned when the client could not communicate with the sever. ErrConnectionFailed = errors.New("connection failed") // ErrNotFound is returned when the resource wasn't found or the route does't exist. ErrNotFound = errors.New("not found") // ErrBadRequest is returned when the request is malformed or invalid. ErrBadRequest = errors.New("bad request") ErrUnauthorized = errors.New("unauthorized") // ErrForbidden is returned when the client is authenticated but not allowed to perform the operation. ErrForbidden = errors.New("forbidden") // ErrMethodNotAllowed is returned when the HTTP method used is not allowed for the resource. ErrMethodNotAllowed = errors.New("method not allowed") // ErrConflict is returned when there is a conflict with the current state of the resource. ErrConflict = errors.New("conflict") // ErrPreconditionFailed is returned when a precondition set by the client fails. ErrPreconditionFailed = errors.New("precondition failed") // ErrTooManyRequests is returned when the client has exceeded its rate limit. ErrTooManyRequests = errors.New("too many requests") // ErrInternalServerError is returned when the server has cannot response to the request due an error. ErrInternalServerError = errors.New("internal server error") )
var ErrParseAddress = fmt.Errorf("could not parse the address to the required format")
Functions ¶
func DialContext ¶ added in v0.13.6
func DialContext(ctx context.Context, address string, header http.Header) (*websocket.Conn, *http.Response, error)
DialContext creates a websocket connection to ShellHub's SSH server.
It receivees the endpoint to connect and the necessary headers for authentication on the server. If the server redirect the connection with status http.StatusTemporaryRedirect or http.StatusPermanentRedirect, the DialContext method will follow. Any other response from the server will result in an error as result of this function.
func ErrorFromResponse ¶ added in v0.13.6
ErrorFromResponse returns an error based on the response status code. Each Error is mapped to a specific status code, if the status code is not mapped ErrUnknown is returned.
func SameDomainRedirectPolicy ¶ added in v0.13.0
func SameDomainRedirectPolicy() resty.RedirectPolicyFunc
SameDomainRedirectPolicy allows redirect only if the redirected domain is the same as original domain, e.g. redirect to "www.imroc.cc" from "imroc.cc" is allowed, but redirect to "google.com" is not allowed.
Types ¶
type LeveledLogger ¶ added in v0.6.0
func (*LeveledLogger) Debugf ¶ added in v0.9.0
func (l *LeveledLogger) Debugf(msg string, keysAndValues ...interface{})
func (*LeveledLogger) Errorf ¶ added in v0.9.0
func (l *LeveledLogger) Errorf(msg string, keysAndValues ...interface{})
func (*LeveledLogger) Warnf ¶ added in v0.9.0
func (l *LeveledLogger) Warnf(msg string, keysAndValues ...interface{})
type Opt ¶
type Opt func(*client) error
func WithLogger ¶ added in v0.4.0
func WithReverser ¶ added in v0.13.6
func WithScheme ¶ added in v0.3.2
type Reverser ¶ added in v0.13.6
type Reverser struct {
// contains filtered or unexported fields
}
func NewReverser ¶ added in v0.13.6
func (*Reverser) Auth ¶ added in v0.13.6
Auth creates a initial connection to the ShellHub SSH's server and authenticate it with the token received.
func (*Reverser) NewListener ¶ added in v0.13.6
NewListener creates a new reverse listener to be used by the Agent to receive connections from the ShellHub's server.
It uses the authenticated connection generate by the [Auth] method to create a new reverse listener. Through this connection, the Agent will be able to receive connections from the ShellHub's server. This connections are, essentially, the SSH operations requested by the user.