Skip to content

Commit

Permalink
Make the spellchecker happy
Browse files Browse the repository at this point in the history
This commit fixes typos to make the spellchecker happy
  • Loading branch information
tkw1536 committed Apr 21, 2024
1 parent 037e01d commit ba8adef
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 18 deletions.
12 changes: 7 additions & 5 deletions cmd/akhttpd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@
//
// -api-timeout duration
//
// When interacting with the GitHub API, akhttp uses a default timeout of 1s.
// When interacting with the GitHub API, akhttpd uses a default timeout of 1s.
// After this timeout expires, any response is considered invalid and an HTTP 500 is returned to the client.
// Use this flag to change the default timeout.
//
// -cache-age duration, -cache-size bytes
//
// To avoid unneccessary GitHub API requests, akhttpd caches responses.
// Respones are cached for 1h by default, with a maximum cache size of 25kb.
// To avoid unnecessary GitHub API requests, akhttpd caches responses.
// Responses are cached for 1h by default, with a maximum cache size of 25kb.
// Use these flags to change the defaults.
//
// -akpath path
Expand Down Expand Up @@ -107,11 +107,13 @@
//
// LEGAL_BLOCK=user1,user2
//
// For legal reasons it might be neccessary to block specific users from being served using this service.
// For legal reasons it might be necessary to block specific users from being served using this service.
// To block a specific user, use the LEGAL_BLOCK variable.
// It contains a comma-seperated list of users to be blocked.
// It contains a comma-separated list of users to be blocked.
package main

// spellchecker:words akhttpd akpath

import (
"flag"
"fmt"
Expand Down
8 changes: 5 additions & 3 deletions countwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package akhttpd

import "io"

// spellchecker:words akhttpd

// CountWriter is an io.Writer that wraps an underlying writer.
// It is not safe for concurrent writing.
//
// It counts the the total number of bytes written.
// Furthermore, once a single write fails, all future writes are silently supressed.
// Furthermore, once a single write fails, all future writes are silently suppressed.
type CountWriter struct {
Writer io.Writer

Expand All @@ -26,12 +28,12 @@ func (w *CountWriter) Write(b []byte) (int, error) {
return n, err
}

// State returns the first error that occured within the writer and the total number of bytes written up to that point.
// State returns the first error that occurred within the writer and the total number of bytes written up to that point.
func (w CountWriter) State() (int, error) {
return w.StateWith(nil)
}

// StateWith returns the first error that occured within the writer and the total number of bytes written up to that point.
// StateWith returns the first error that occurred within the writer and the total number of bytes written up to that point.
// When err is not nil, returns the provided error instead of the internal error.
func (w CountWriter) StateWith(err error) (int, error) {
if err == nil {
Expand Down
6 changes: 4 additions & 2 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import (
"github.com/tkw1536/akhttpd/pkg/repo"
)

// Handler is the main akhttp Server Handler.
// spellchecker:words akhttpd

// Handler is the main akhttpd Server Handler.
// It implements http.Handler, see the ServerHTTP method.
type Handler struct {
repo.KeyRepository
Expand Down Expand Up @@ -106,7 +108,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
h.WriteSuffix(w)
case path == "/robots.txt":
handlePathOrFallback(w, h.RobotsTXTPath, defaultRobotsTXT, "text/plain")
case path == "/favicon.ico": // performance optimization as webbrowsers frequently request this
case path == "/favicon.ico": // performance optimization as web browsers frequently request this
http.NotFound(w, r)

case handlerPath.MatchString(path): // the main route, where the bulk of handling takes place
Expand Down
4 changes: 3 additions & 1 deletion handler_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"path/filepath"
)

// spellchecker:words akhttpd

// handlePathOrFallback sends filepath to w with the provided content type
//
// When filepath does not exist (or is the empty string), returns fallbackBytes.
Expand All @@ -26,7 +28,7 @@ func handlePathOrFallback(w http.ResponseWriter, filepath string, fallbackBytes
err = nil
}

// other unknown error occured; something went wrong!
// other unknown error occurred; something went wrong!
if err != nil {
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
return err
Expand Down
2 changes: 2 additions & 0 deletions legal/docs.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Package legal contains legal notices of packages used by akhttpd.
package legal

// spellchecker:words akhttpd gogenlicense

//go:generate gogenlicense -p legal -n Notices -d notices.go github.com/tkw1536/akhttpd
2 changes: 2 additions & 0 deletions pkg/format/authorized_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"golang.org/x/crypto/ssh"
)

// spellchecker:words akhttpd

// AuthorizedKeys is a struct that formats ssh keys as an authorized_keys file.
// It implements Formatter.
type AuthorizedKeys struct{}
Expand Down
2 changes: 2 additions & 0 deletions pkg/format/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/mpolden/echoip/useragent"
)

// spellchecker:words akhttpd mpolden echoip httpie libfetch ddclient Mikrotik

// Formatter is an object that can write ssh keys to an http.ResponseWriter.
type Formatter interface {
// WriteTo writes the ssh keys, which are associated with the given user, into w.
Expand Down
2 changes: 2 additions & 0 deletions pkg/format/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"golang.org/x/crypto/ssh"
)

// spellchecker:words akhttpd

// FormatterShellScript is a zero-size struct that formats ssh keys as a user-facing html page.
// It implements Formatter.
type HTML struct {
Expand Down
2 changes: 2 additions & 0 deletions pkg/format/shellscript.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"golang.org/x/crypto/ssh"
)

// spellchecker:words akhttpd

// ShellScript is a zero-size struct that formats ssh keys as a shell script updating an authorized_keys file.
// It implements Formatter.
type ShellScript struct{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/repo/combo.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func (c Combo) GetKeys(context context.Context, username string) (source string,
for _, r := range c {
source, keys, err = r.GetKeys(context, username)

// upon encountering a regular (not not-found error) or nil error, we can immediatly return
// upon encountering a regular (not not-found error) or nil error, we can immediately return
if _, isNotFound := err.(UserNotFoundError); err == nil || !isNotFound {
break
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/repo/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
"golang.org/x/oauth2"
)

// spellchecker:words lrucache gregjones httpcache

// GitHubKeys is an object that allows fetching ssh keys for GitHub Users using the GitHub API.
// It implements KeyRepository.
//
Expand All @@ -31,7 +33,7 @@ type GitHubKeysOptions struct {
Token string

// Timeout is the Timeout for requests to GitHub.
// The zero value indiciates no timeout.
// The zero value indicates no timeout.
Timeout time.Duration

// MaxCacheSize is the maximum size of an internally used cache in bytes.
Expand Down
2 changes: 1 addition & 1 deletion pkg/repo/repo.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package repo provides keyrepo
// Package repo provides KeyRepository
package repo

import (
Expand Down
10 changes: 6 additions & 4 deletions pkg/repo/uploadable.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
_ "embed"
)

// spellchecker:words akhttpd wshandler userkeys

// UploadableKeys is an object that allows callers to upload keys to the server temporarily.
type UploadableKeys struct {
Prefix string // Prefix is the prefix for new users
Expand Down Expand Up @@ -117,8 +119,8 @@ func (uk *UploadableKeys) ServeHTTP(w http.ResponseWriter, r *http.Request) {

// if an upgrade to the websocket was requested, serve a websocket!
if r.Header.Get("Upgrade") == "websocket" {
wshandler.Handle(w, r, func(messager wshandler.WebSocket) {
key, ok := messager.Read() // wait for any kind of message
wshandler.Handle(w, r, func(messenger wshandler.WebSocket) {
key, ok := messenger.Read() // wait for any kind of message
if !ok {
return
}
Expand All @@ -134,11 +136,11 @@ func (uk *UploadableKeys) ServeHTTP(w http.ResponseWriter, r *http.Request) {
defer cleanup()

// write the username back!
if !messager.Write(username) {
if !messenger.Write(username) {
return
}

messager.Wait()
messenger.Wait()
})
return
}
Expand Down

0 comments on commit ba8adef

Please sign in to comment.