Documentation ¶
Index ¶
- Variables
- func CheckEnvWarp(ctx context.Context) error
- func ConfigPath(ctx context.Context) (*string, error)
- func RunLocalCommand(ctx context.Context, cmd warp.Command) (*warp.CommandResult, error)
- type Cli
- type CmdName
- type Command
- type Config
- type Credentials
- type Session
- func (ss *Session) DataC() net.Conn
- func (ss *Session) DecodeError(ctx context.Context) (*warp.Error, error)
- func (ss *Session) DecodeState(ctx context.Context) (*warp.State, error)
- func (ss *Session) GetMode(user string) (*warp.Mode, error)
- func (ss *Session) HostCanReceiveWrite() bool
- func (ss *Session) Modes() map[string]warp.Mode
- func (ss *Session) ProtocolState() warp.State
- func (ss *Session) SendHostUpdate(ctx context.Context, update warp.HostUpdate) error
- func (ss *Session) Session() warp.Session
- func (ss *Session) SetMode(user string, mode warp.Mode) error
- func (ss *Session) TearDown()
- func (ss *Session) TornDown() bool
- func (ss *Session) UpdateState(state warp.State, hosting bool) error
- func (ss *Session) Warp() string
- func (ss *Session) WindowSize() warp.Size
- func (ss *Session) WriteDataC(data []byte)
- type Shell
- type Srv
- type UserState
- type WarpState
- func (w *WarpState) GetMode(user string) (*warp.Mode, error)
- func (w *WarpState) HostCanReceiveWrite() bool
- func (w *WarpState) Modes() map[string]warp.Mode
- func (w *WarpState) ProtocolState() warp.State
- func (w *WarpState) SetMode(user string, mode warp.Mode) error
- func (w *WarpState) Update(state warp.State, hosting bool) error
- func (w *WarpState) WindowSize() warp.Size
Constants ¶
This section is empty.
Variables ¶
var Registrar = map[CmdName](func() Command){}
Registrar is used to register command generators within the module.
Functions ¶
func CheckEnvWarp ¶ added in v0.0.3
CheckWarpEnv checks that the warp.EnvWarp env variable is set. If not it returns an error after displaying an helpful message.
func ConfigPath ¶ added in v0.0.3
ConfigPath returns the crendentials path for the current environment.
func RunLocalCommand ¶
RunLocalCommand runs a local in-warp command and returns the result. If an error is returned as part of the result, it formats a human readable error that can be safely returned top the user.
Types ¶
type Cli ¶
Cli represents a cli instance.
type Command ¶
type Command interface { // Name returns the command name. Name() CmdName // Help prints out the help message for the command. Help(context.Context) // Parse the arguments and flags passed to the command. Parse(context.Context, []string, map[string]string) error // Execute the command or return a human-friendly error. Execute(context.Context) error }
Command is the interface for a cli command.
type Config ¶ added in v0.0.3
type Config struct {
Credentials Credentials `json:"credentials"`
}
Config represents the local configuration for warp.
func GenerateConfig ¶ added in v0.0.3
GenerateConfig generates a new config and store it. As part of it, it generates a new set of credentials.
func RetrieveConfig ¶ added in v0.0.3
RetrieveConfig retrieves the current user config by reading ConfigPath.
type Credentials ¶ added in v0.0.3
Credentials repesents the credentials of the currently logged in user.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session represents a session to warpd as part of a client or a host. All methods are thread-safe except the Decode* methods.
func NewSession ¶
func NewSession( ctx context.Context, session warp.Session, w string, sessionType warp.SessionType, username string, cancel func(), conn net.Conn, ) (*Session, error)
NewSession sets up a session, opens the associated channels and return a Session object.
func (*Session) DataC ¶
DataC returns the data channel. Using the dataC is not thread-safe and should happen from only one go routine for reading only. Writing should go through thread-safe WriteDataC.
func (*Session) DecodeError ¶
DecodeError attempts to decode an error from the errorC. This method is not thread-safe.
func (*Session) DecodeState ¶
DecodeState attempts to decode state from the sateC. This method is not thread-safe.
func (*Session) HostCanReceiveWrite ¶ added in v0.0.3
HostCanReceiverWrite retruns whether the host can receive write from any shell client.
func (*Session) ProtocolState ¶ added in v0.0.3
State returns the session warp state.
func (*Session) SendHostUpdate ¶
SendHostUpdate is used to safely concurrently sending host updates.
func (*Session) TearDown ¶
func (ss *Session) TearDown()
TearDown tears down a session, closing and reclaiming channels.
func (*Session) UpdateState ¶ added in v0.0.3
UpdateState updates the session state with a received warp.State.
func (*Session) WindowSize ¶ added in v0.0.3
WindowSizse returns the current window size.
func (*Session) WriteDataC ¶ added in v0.0.3
WriteData writes to dataC in a thread-safe way, checking that the session is not torn down.
type Srv ¶
type Srv struct {
// contains filtered or unexported fields
}
func (*Srv) SetSession ¶ added in v0.0.3
SetSession sets the session the srv should use. It is set to nil if the warp is currently disconnected. The write to the session variable is protected by a mutex that is locked when comands are executed (to avoid accessing a niled out session).
type UserState ¶
type UserState struct {
// contains filtered or unexported fields
}
UserState represents the state of a user as seen client-side.
func (*UserState) ProtocolUser ¶ added in v0.0.3
User returns a warp.User from the current UserState.
type WarpState ¶ added in v0.0.3
type WarpState struct {
// contains filtered or unexported fields
}
WarpState repreents the state of a warp client side. The warp state method are not thread-safe and access to it should be protected by the associated session lock.
func NewWarpState ¶ added in v0.0.3
func NewWarpState( hello warp.SessionHello, ) *WarpState
Returns a new warp state initialized by a hello message.
func (*WarpState) HostCanReceiveWrite ¶ added in v0.0.3
HostCanReceiveWrite computes whether the host can receive write from the shell clients. This is used as defense in depth to prevent any write if that's not the case.
func (*WarpState) ProtocolState ¶ added in v0.0.3
ProtocolState computes a warp.State from the current warp. It acquires the warp lock.
func (*WarpState) Update ¶ added in v0.0.3
Update the warp state given a warp.State received over the wire.
If preserveModes is true the modes are preserved (used from the host session as the server is not trusted with modes). If the state includes an unknown user, the default secure modes are used (~read-only).
func (*WarpState) WindowSize ¶ added in v0.0.3
WindowSizse returns the current window size.