Documentation ¶
Overview ¶
Package winsession provides windows session management functions.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var Local = local
Local represents the local host.
Functions ¶
This section is empty.
Types ¶
type ClientInfo ¶
type ClientInfo struct { ComputerName string ComputerDomain string EncryptionLevel encryptionlevel.Value AddressFamily uint32 Address string HRes uint16 // Horizontal resolution (pixels) VRes uint16 // Vertical resolution (pixels) ColorDepth colordepth.Value BuildNumber uint32 }
ClientInfo holds detailed information about a remote client connected to a windows session via RDP.
func (ClientInfo) Computer ¶
func (info ClientInfo) Computer() string
Computer returns the client computer in the form DOMAIN\NAME.
func (ClientInfo) IsZero ¶
func (info ClientInfo) IsZero() bool
IsZero returns true if the client info is unset.
type Collection ¶
type Collection struct { Host *Host Sessions []Session Excluded []bool // Excluded[i] corresponds to Sessions[i] }
Collection holds interim processing information while collecting sessions.
type CollectionOption ¶
type CollectionOption interface {
Apply(*Collection)
}
A CollectionOption is capable of applying its settings to a collection.
type Collector ¶
type Collector int
A Collector is a collection option that collects additional information about a session.
Information will only be collected for sessions that have not been excluded by previous filtering options.
func (Collector) Apply ¶
func (c Collector) Apply(col *Collection)
Apply applies the collector to the collection.
func (Collector) Merge ¶
func (c Collector) Merge(next CollectionOption) (merged CollectionOption, ok bool)
Merge attempts to merge the collector with the next option. It returns true if successful.
type Exclude ¶
type Exclude Filter
Exclude is an exclusion filter.
func (Exclude) Apply ¶
func (exclude Exclude) Apply(col *Collection)
Apply applies the exclusion filter to the collection.
type Filter ¶
A Filter returns true if it matches a session.
func EqualsUser ¶
EqualsUser returns a filter that matches a session user name case-insensitively.
func MatchAll ¶
MatchAll returns true if all of the filters match the session.
MatchAll returns true if no filters are provided.
func MatchAny ¶
MatchAny returns true if any of the filters match the session.
MatchAny returns true if no filters are provided.
func MatchState ¶
MatchState returns a filter that matches any of the given states.
func MatchUser ¶
func MatchUser(matcher StringMatcher) Filter
MatchUser returns a filter that matches a session user name.
type Host ¶
type Host struct {
// contains filtered or unexported fields
}
Host is an open connection to a local or remote computer. It manages an open system handle internally.
Each server must be closed when it is no longer needed.
func Open ¶
Open opens a connection to the server with the given address. If addr is empty a connection to the local server will be established.
func (*Host) Sessions ¶
func (host *Host) Sessions(options ...CollectionOption) ([]Session, error)
Sessions returns a list of windows sessions from host.
Collection options can be provided to filter the list and collect additional session information. Options will be evaluated in order.
If a filter relies on session information gathered by one or more collector options, those options must be included before the filter.
Example ¶
package main import ( "fmt" "github.com/gentlemanautomaton/winsession" ) func main() { sessions, err := winsession.Local.Sessions( winsession.Include(winsession.MatchID(0)), winsession.CollectSessionInfo) if err != nil { fmt.Printf("Failed to retrieve session list: %v\n", err) return } for _, session := range sessions { fmt.Printf("Session %d: %s (%s)\n", session.ID, session.WindowStation, session.Info.LockState) } }
Output: Session 0: Services (Unlocked)
type Include ¶
type Include Filter
Include is an inclusion filter.
func (Include) Apply ¶
func (include Include) Apply(col *Collection)
Apply applies the inclusion filter to the collection.
type MergableCollectionOption ¶
type MergableCollectionOption interface {
Merge(next CollectionOption) (merged CollectionOption, ok bool)
}
A MergableCollectionOption is capable of merging with the next option in the list. Some options implement this interface when bulk operations can be performed more efficiently.
type Session ¶
type Session struct { ID ID WindowStation string State connstate.Value Info SessionInfo Client ClientInfo }
Session holds information about a windows session.
type SessionInfo ¶
type SessionInfo struct { LockState lockstate.Value WindowStation string UserName string UserDomain string LogonTime time.Time ConnectTime time.Time DisconnectTime time.Time LastInputTime time.Time CurrentTime time.Time }
SessionInfo holds detailed information about a windows session.
func (SessionInfo) IsZero ¶
func (info SessionInfo) IsZero() bool
IsZero returns true if the session info is unset.
func (SessionInfo) User ¶
func (info SessionInfo) User() string
User returns the session's user in the form DOMAIN\USER.
type StringMatcher ¶
A StringMatcher is a function that matches strings
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
Package wtsapi provides low-level access to the Remote Desktop Services API.
|
Package wtsapi provides low-level access to the Remote Desktop Services API. |