finger

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: Unlicense Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ForwardingDenied = errors.New("Finger forwarding service denied.")

ForwardingDenied is returned in response to requests for forwarding service.

View Source
var ListingDenied = errors.New("Finger online user list denied.")

ListingDenied is returned to reject online user listing requests.

Functions

func Error

func Error(msg string) *types.Response

Error produces a finger Response containing the error message and Status 1.

func NewServer

func NewServer(
	ctx context.Context,
	hostname string,
	network string,
	address string,
	handler types.Handler,
	baseLog logging.Logger,
) (types.Server, error)

NewServer builds a finger server.

func NewTLSServer added in v1.5.0

func NewTLSServer(
	ctx context.Context,
	hostname string,
	network string,
	address string,
	handler types.Handler,
	baseLog logging.Logger,
	tlsConfig *tls.Config,
) (types.Server, error)

func ParseRequest

func ParseRequest(rdr io.Reader) (*types.Request, error)

ParseRequest builds a sliderule.Request by reading a finger protocol request.

At the time of writing, there is no firm standard on how to represent finger queries as URLs (the finger protocol itself predates URLs entirely), but there are a few helpful resources to go from.

As this function builds a *sliderule.Request (which is mostly a wrapper around a URL) from nothing but an io.Reader, it doesn't have the context of the hostname which the receiving server was hosting. So it only has the host component if it arrived in the body of the query in the form username@hostname. Bear in mind that in sliderule handlers, request objects will also carry a reference to the server so that hostname is always available as request.Server.Hostname().

The primary deviation from the IETF draft is that a query-specified host becomes the Host section of the URL, rather than remaining in the Path. Where the IETF draft would consider a query of "tjp@ctrl-c.club\r\n" to be "finger:/tjp@ctrl-c.club", this function will parse it into "finger://ctrl-c.club/tjp". This decision to separate the query-specified host from the username is intended to make it easier to avoid inadvertently acting as a jump host for example with: `exec.Command("/usr/bin/finger", request.Path[1:])`.

Consistent with the IETF draft, the /W whois switch is dropped and not represented in the URL at all.

In accordance with the recommendation of RFC 1288 section 3.2.1 (https://datatracker.ietf.org/doc/html/rfc1288#section-3.2.1), any queries which include a jump-host (user@host1@host2) are rejected with the ForwardingDenied error.

func Success

func Success(body io.Reader) *types.Response

Success produces a finger response with a Status of 0.

func SystemFinger

func SystemFinger(allowListings bool) types.Handler

SystemFinger handles finger requests by invoking the finger(1) command-line utility.

Types

type Client added in v1.1.0

type Client struct{}

Client is used for sending finger requests and reading responses.

It carries no state and is reusable simultaneously by multiple goroutines.

The zero value is immediately usable.

func (Client) Fetch added in v1.1.0

func (c Client) Fetch(ctx context.Context, query string) (*types.Response, error)

Fetch resolves a finger query.

func (Client) IsRedirect added in v1.1.0

func (c Client) IsRedirect(_ *types.Response) bool

func (Client) RoundTrip added in v1.1.0

func (c Client) RoundTrip(ctx context.Context, request *types.Request) (*types.Response, error)

RoundTrip sends a single finger request and returns its response.

Jump to

Keyboard shortcuts

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