winio

package
v0.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2024 License: MIT, MIT Imports: 14 Imported by: 0

README

trace2receiver/internal/go-winio

This directory contains a stripped down fork of Microsoft/go-winio. It only includes support for Windows named pipes; everything else has been removed.

The go-winio repository was forked so that I could use the changes proposed in my pipe: add server backlog for concurrent Accept() PR without the complications of replace statements in the go.mod files of generated custom collectors.

The go-winio repository was also forked to allow me maintain reponsibility for the maintenance and support of the named pipe routines. It avoids adding a support load from the OTEL community onto the team that nicely developed and donated this code.

I've included a brief summary of the code. Please refer to the original Microsoft/go-winio/README for complete information on this code.

trace2receiver/internal/go-winio Code Summary

This repository contains utilities for efficiently performing Win32 IO operations in Go. Currently, this is focused on accessing named pipes and other file handles, and for using named pipes as a net transport.

This code relies on IO completion ports to avoid blocking IO on system threads, allowing Go to reuse the thread to schedule another goroutine. This limits support to Windows Vista and newer operating systems. This is similar to the implementation of network sockets in Go's net package.

trace2receiver/internal/go-winio License

Please see the LICENSE file for licensing information.

trace2receiver/internal/go-winio Contributing

This project welcomes contributions and suggestions. You can contribute to the forked version of go-winio using the instructions in the trace2receiver root directory. To contribute to the upstream version of go-winio please see their contributing guidelines.

Special Thanks

Thanks to natefinch for the inspiration for this library. See npipe for another named pipe implementation.

Documentation

Rendered for windows/amd64

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFileClosed = errors.New("file has already been closed")
	ErrTimeout    = &timeoutError{}
)
View Source
var (
	// ErrPipeListenerClosed is returned for pipe operations on listeners that have been closed.
	ErrPipeListenerClosed = net.ErrClosed
)

Functions

func DialPipe

func DialPipe(path string, timeout *time.Duration) (net.Conn, error)

DialPipe connects to a named pipe by path, timing out if the connection takes longer than the specified duration. If timeout is nil, then we use a default timeout of 2 seconds. (We do not use WaitNamedPipe.)

func DialPipeAccess

func DialPipeAccess(ctx context.Context, path string, access uint32) (net.Conn, error)

DialPipeAccess attempts to connect to a named pipe by `path` with `access` until `ctx` cancellation or timeout.

func DialPipeContext

func DialPipeContext(ctx context.Context, path string) (net.Conn, error)

DialPipeContext attempts to connect to a named pipe by `path` until `ctx` cancellation or timeout.

func ListenPipe

func ListenPipe(path string, c *PipeConfig) (net.Listener, error)

ListenPipe creates a listener on a Windows named pipe path, e.g. \\.\pipe\mypipe. The pipe must not already exist.

func LookupNameBySid

func LookupNameBySid(sid string) (name string, err error)

LookupNameBySid looks up the name of an account by SID

func LookupSidByName

func LookupSidByName(name string) (sid string, err error)

LookupSidByName looks up the SID of an account by name

func MakeOpenFile deprecated

func MakeOpenFile(h syscall.Handle) (io.ReadWriteCloser, error)

Deprecated: use NewOpenFile instead.

func NewOpenFile

func NewOpenFile(h windows.Handle) (io.ReadWriteCloser, error)

func SddlToSecurityDescriptor

func SddlToSecurityDescriptor(sddl string) ([]byte, error)

func SecurityDescriptorToSddl

func SecurityDescriptorToSddl(sd []byte) (string, error)

Types

type AccountLookupError

type AccountLookupError struct {
	Name string
	Err  error
}

func (*AccountLookupError) Error

func (e *AccountLookupError) Error() string

func (*AccountLookupError) Unwrap

func (e *AccountLookupError) Unwrap() error

type PipeConfig

type PipeConfig struct {
	// SDDL contains a Windows security descriptor in SDDL format.
	SDDL string

	// MessageMode determines whether the pipe is in byte or message mode. In either
	// case the pipe is read in byte mode by default. The only practical difference in
	// this implementation is that CloseWrite() is only supported for message mode pipes;
	// CloseWrite() is implemented as a zero-byte write, but zero-byte writes are only
	// transferred to the reader (and returned as io.EOF in this implementation)
	// when the pipe is in message mode.
	MessageMode bool

	// InputBufferSize specifies the size of the input buffer, in bytes.
	InputBufferSize int32

	// OutputBufferSize specifies the size of the output buffer, in bytes.
	OutputBufferSize int32

	// QueueSize specifies the maximum number of concurrently active pipe server
	// handles to allow.  This is conceptually similar to the `backlog` argument
	// to `listen(2)` on Unix systems. Increasing this value reduces the likelyhood
	// of a connecting client receiving a `windows.ERROR_PIPE_BUSY` error.
	// (Assuming that the server is written to call `l.Accept()` using a pool of
	// application worker threads.)
	//
	// This value should be larger than your expected client arrival rate so that
	// there are always a few extra listener worker threads and (more importantly)
	// unbound server pipes in the kernel, so that a client "CreateFile()" should
	// not get a busy signal.
	QueueSize int32
}

PipeConfig contain configuration for the pipe listener.

type PipeConn

type PipeConn interface {
	net.Conn
	Disconnect() error
	Flush() error
}

type SddlConversionError

type SddlConversionError struct {
	Sddl string
	Err  error
}

func (*SddlConversionError) Error

func (e *SddlConversionError) Error() string

func (*SddlConversionError) Unwrap

func (e *SddlConversionError) Unwrap() error

Directories

Path Synopsis
internal
fs
This package contains Win32 filesystem functionality.
This package contains Win32 filesystem functionality.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL