diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index d7c720d29..4cd91413f 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -111,7 +111,7 @@ Note that plugin documentation is not hosted by the Caddy website, other than ba ## Collaborator Instructions -Collabators have push rights to the repository. We grant this permission after one or more successful, high-quality PRs are merged! We thank them for their help.The expectations we have of collaborators are: +Collaborators have push rights to the repository. We grant this permission after one or more successful, high-quality PRs are merged! We thank them for their help.The expectations we have of collaborators are: - **Help review pull requests.** Be meticulous, but also kind. We love our contributors, but we critique the contribution to make it better. Multiple, thorough reviews make for the best contributions! Here are some questions to consider: - Can the change be made more elegant? diff --git a/caddyfile/parse_test.go b/caddyfile/parse_test.go index 741dbcbf7..10beb5b56 100644 --- a/caddyfile/parse_test.go +++ b/caddyfile/parse_test.go @@ -421,7 +421,7 @@ func TestDirectiveImport(t *testing.T) { t.Error("directive import failed") } - // import from nonexisting file + // import from nonexistent file _, err = testParseOne(`localhost dir1 proxy { diff --git a/caddyhttp/browse/browse.go b/caddyhttp/browse/browse.go index f265710e0..8a7b72973 100644 --- a/caddyhttp/browse/browse.go +++ b/caddyhttp/browse/browse.go @@ -186,7 +186,7 @@ func (l bySize) Less(i, j int) bool { iSize, jSize := l.Items[i].Size, l.Items[j].Size // Directory sizes depend on the filesystem implementation, - // which is opaque to a visitor, and should indeed does not change if the operator choses to change the fs. + // which is opaque to a visitor, and should indeed does not change if the operator chooses to change the fs. // For a consistent user experience directories are pulled to the front… if l.Items[i].IsDir { iSize = directoryOffset diff --git a/caddyhttp/browse/browse_test.go b/caddyhttp/browse/browse_test.go index 39c00299c..fd89127a6 100644 --- a/caddyhttp/browse/browse_test.go +++ b/caddyhttp/browse/browse_test.go @@ -366,25 +366,25 @@ func TestBrowseJson(t *testing.T) { } actualJSONResponse := rec.Body.String() - copyOflisting := listing + copyOfListing := listing if test.SortBy == "" { - copyOflisting.Sort = "name" + copyOfListing.Sort = "name" } else { - copyOflisting.Sort = test.SortBy + copyOfListing.Sort = test.SortBy } if test.OrderBy == "" { - copyOflisting.Order = "asc" + copyOfListing.Order = "asc" } else { - copyOflisting.Order = test.OrderBy + copyOfListing.Order = test.OrderBy } - copyOflisting.applySort() + copyOfListing.applySort() limit := test.Limit - if limit <= len(copyOflisting.Items) && limit > 0 { - marsh, err = json.Marshal(copyOflisting.Items[:limit]) + if limit <= len(copyOfListing.Items) && limit > 0 { + marsh, err = json.Marshal(copyOfListing.Items[:limit]) } else { // if the 'limit' query is empty, or has the wrong value, list everything - marsh, err = json.Marshal(copyOflisting.Items) + marsh, err = json.Marshal(copyOfListing.Items) } if err != nil { diff --git a/caddyhttp/browse/setup_test.go b/caddyhttp/browse/setup_test.go index 8f7d56141..93d3d0879 100644 --- a/caddyhttp/browse/setup_test.go +++ b/caddyhttp/browse/setup_test.go @@ -53,7 +53,7 @@ func TestSetup(t *testing.T) { // test case #1 tests instantiation of Config with default values {"browse /", []string{"/"}, false}, - // test case #2 tests detectaction of custom template + // test case #2 tests detection of custom template {"browse . " + tempTemplatePath, []string{"."}, false}, // test case #3 tests detection of non-existent template diff --git a/caddyhttp/fastcgi/fcgiclient.go b/caddyhttp/fastcgi/fcgiclient.go index b5fd1d9ea..4f1044854 100644 --- a/caddyhttp/fastcgi/fcgiclient.go +++ b/caddyhttp/fastcgi/fcgiclient.go @@ -216,7 +216,7 @@ func Dial(network, address string) (fcgi *FCGIClient, err error) { return DialContext(context.Background(), network, address) } -// Close closes fcgi connnection +// Close closes fcgi connection func (c *FCGIClient) Close() { c.rwc.Close() } diff --git a/caddyhttp/fastcgi/fcgiclient_test.go b/caddyhttp/fastcgi/fcgiclient_test.go index 9c5237f20..6c02840be 100644 --- a/caddyhttp/fastcgi/fcgiclient_test.go +++ b/caddyhttp/fastcgi/fcgiclient_test.go @@ -44,7 +44,7 @@ import ( // test fcgi protocol includes: // Get, Post, Post in multipart/form-data, and Post with files // each key should be the md5 of the value or the file uploaded -// sepicify remote fcgi responer ip:port to test with php +// specify remote fcgi responder ip:port to test with php // test failed if the remote fcgi(script) failed md5 verification // and output "FAILED" in response const ( diff --git a/caddyhttp/gzip/gzip.go b/caddyhttp/gzip/gzip.go index 62e1d5ed1..619a1d579 100644 --- a/caddyhttp/gzip/gzip.go +++ b/caddyhttp/gzip/gzip.go @@ -114,7 +114,7 @@ outer: return g.Next.ServeHTTP(w, r) } -// gzipResponeWriter wraps the underlying Write method +// gzipResponseWriter wraps the underlying Write method // with a gzip.Writer to compress the output. type gzipResponseWriter struct { internalWriter io.Writer diff --git a/caddyhttp/httpserver/condition.go b/caddyhttp/httpserver/condition.go index 314cee519..0b329092b 100644 --- a/caddyhttp/httpserver/condition.go +++ b/caddyhttp/httpserver/condition.go @@ -191,7 +191,7 @@ func (m IfMatcher) Or(r *http.Request) bool { } // IfMatcherKeyword checks if the next value in the dispenser is a keyword for 'if' config block. -// If true, remaining arguments in the dispinser are cleard to keep the dispenser valid for use. +// If true, remaining arguments in the dispenser are cleared to keep the dispenser valid for use. func IfMatcherKeyword(c *caddy.Controller) bool { if c.Val() == "if" || c.Val() == "if_op" { // clear remaining args diff --git a/caddyhttp/httpserver/mitm_test.go b/caddyhttp/httpserver/mitm_test.go index b83c6bb04..8f0f0d597 100644 --- a/caddyhttp/httpserver/mitm_test.go +++ b/caddyhttp/httpserver/mitm_test.go @@ -335,7 +335,7 @@ func TestHeuristicFunctionsAndHandler(t *testing.T) { // in other words, if one returns true, the others // should return false, with as little logic as possible, // but with enough logic to force TLS proxies to do a - // good job preserving characterstics of the handshake. + // good job preserving characteristics of the handshake. if (isChrome && (isFirefox || isSafari || isEdge || isTor)) || (isFirefox && (isChrome || isSafari || isEdge || isTor)) || (isSafari && (isChrome || isFirefox || isEdge || isTor)) || diff --git a/caddyhttp/httpserver/plugin.go b/caddyhttp/httpserver/plugin.go index d14011f7f..3015476b6 100644 --- a/caddyhttp/httpserver/plugin.go +++ b/caddyhttp/httpserver/plugin.go @@ -228,7 +228,7 @@ func (h *httpContext) MakeServers() ([]caddy.Server, error) { // make a rough estimate as to whether we're in a "production // environment/system" - start by assuming that most production // servers will set their default CA endpoint to a public, - // trusted CA (obviously not a perfect hueristic) + // trusted CA (obviously not a perfect heuristic) var looksLikeProductionCA bool for _, publicCAEndpoint := range caddytls.KnownACMECAs { if strings.Contains(certmagic.CA, publicCAEndpoint) { diff --git a/caddyhttp/httpserver/recorder.go b/caddyhttp/httpserver/recorder.go index f903f924d..e59b5c288 100644 --- a/caddyhttp/httpserver/recorder.go +++ b/caddyhttp/httpserver/recorder.go @@ -217,7 +217,7 @@ func (rb *ResponseBuffer) ReadFrom(src io.Reader) (int64, error) { // https://go-review.googlesource.com/c/22134#message-ff351762308fe05f6b72a487d6842e3988916486 buf := respBufPool.Get().([]byte) n, err := io.CopyBuffer(rb.ResponseWriterWrapper, src, buf) - respBufPool.Put(buf) // defer'ing this slowed down benchmarks a smidgin, I think + respBufPool.Put(buf) // deferring this slowed down benchmarks a smidgin, I think return n, err } return rb.Buffer.ReadFrom(src) diff --git a/caddyhttp/httpserver/replacer_test.go b/caddyhttp/httpserver/replacer_test.go index 9159ee643..6b696601c 100644 --- a/caddyhttp/httpserver/replacer_test.go +++ b/caddyhttp/httpserver/replacer_test.go @@ -76,7 +76,7 @@ func TestReplace(t *testing.T) { request.Header.Set("CustomAdd", "caddy") request.Header.Set("Cookie", "foo=bar; taste=delicious") - // add some respons headers + // add some response headers recordRequest.Header().Set("Custom", "CustomResponseHeader") hostname, err := os.Hostname() @@ -303,7 +303,7 @@ func BenchmarkReplace(b *testing.B) { request.Header.Set("CustomAdd", "caddy") request.Header.Set("Cookie", "foo=bar; taste=delicious") - // add some respons headers + // add some response headers recordRequest.Header().Set("Custom", "CustomResponseHeader") now = func() time.Time { @@ -336,7 +336,7 @@ func BenchmarkReplaceEscaped(b *testing.B) { request.Header.Set("CustomAdd", "caddy") request.Header.Set("Cookie", "foo=bar; taste=delicious") - // add some respons headers + // add some response headers recordRequest.Header().Set("Custom", "CustomResponseHeader") now = func() time.Time { @@ -473,7 +473,7 @@ func TestRound(t *testing.T) { } } -func TestMillisecondConverstion(t *testing.T) { +func TestMillisecondConversion(t *testing.T) { var testCases = map[time.Duration]int64{ 2 * time.Second: 2000, 9039492 * time.Nanosecond: 9, diff --git a/caddyhttp/httpserver/siteconfig.go b/caddyhttp/httpserver/siteconfig.go index 3b29f911a..069a4a106 100644 --- a/caddyhttp/httpserver/siteconfig.go +++ b/caddyhttp/httpserver/siteconfig.go @@ -86,7 +86,7 @@ type SiteConfig struct { } // Timeouts specify various timeouts for a server to use. -// If the assocated bool field is true, then the duration +// If the associated bool field is true, then the duration // value should be treated literally (i.e. a zero-value // duration would mean "no timeout"). If false, the duration // was left unset, so a zero-value duration would mean to diff --git a/caddyhttp/httpserver/tplcontext_test.go b/caddyhttp/httpserver/tplcontext_test.go index 8a76baf37..8fb3f58aa 100644 --- a/caddyhttp/httpserver/tplcontext_test.go +++ b/caddyhttp/httpserver/tplcontext_test.go @@ -101,7 +101,7 @@ func TestInclude(t *testing.T) { for i, test := range tests { testPrefix := getTestPrefix(i) - // WriteFile truncates the contentt + // WriteFile truncates the content err := ioutil.WriteFile(absInFilePath, []byte(test.fileContent), os.ModePerm) if err != nil { t.Fatal(testPrefix+"Failed to create test file. Error was: %v", err) @@ -162,7 +162,7 @@ func TestMarkdown(t *testing.T) { for i, test := range tests { testPrefix := getTestPrefix(i) - // WriteFile truncates the contentt + // WriteFile truncates the content err := ioutil.WriteFile(absInFilePath, []byte(test.fileContent), os.ModePerm) if err != nil { t.Fatal(testPrefix+"Failed to create test file. Error was: %v", err) diff --git a/caddyhttp/log/setup_test.go b/caddyhttp/log/setup_test.go index a1e1b9100..ede552b7e 100644 --- a/caddyhttp/log/setup_test.go +++ b/caddyhttp/log/setup_test.go @@ -336,7 +336,7 @@ func TestLogParse(t *testing.T) { {`log access.log { rotate_size }`, true, nil}, {`log access.log { ipmask }`, true, nil}, {`log access.log { invalid_option 1 }`, true, nil}, - {`log / acccess.log "{remote} - [{when}] "{method} {port}" {scheme} {mitm} "`, true, nil}, + {`log / access.log "{remote} - [{when}] "{method} {port}" {scheme} {mitm} "`, true, nil}, } for i, test := range tests { c := caddy.NewTestController("http", test.inputLogRules) diff --git a/caddyhttp/markdown/metadata/metadata_none.go b/caddyhttp/markdown/metadata/metadata_none.go index 63da0d04e..e25e15dd0 100644 --- a/caddyhttp/markdown/metadata/metadata_none.go +++ b/caddyhttp/markdown/metadata/metadata_none.go @@ -29,7 +29,7 @@ func (n *NoneParser) Type() string { return "None" } -// Init prepases and parses the metadata and markdown file +// Init preparses and parses the metadata and markdown file func (n *NoneParser) Init(b *bytes.Buffer) bool { m := make(map[string]interface{}) n.metadata = NewMetadata(m) diff --git a/caddyhttp/markdown/summary/render.go b/caddyhttp/markdown/summary/render.go index f4a80d7f8..95e375105 100644 --- a/caddyhttp/markdown/summary/render.go +++ b/caddyhttp/markdown/summary/render.go @@ -122,7 +122,7 @@ func (r renderer) Image(out *bytes.Buffer, link []byte, title []byte, alt []byte // LineBreak is the line break tag callback. func (r renderer) LineBreak(out *bytes.Buffer) {} -// Link is the link tag callback. Outputs a sipmle plain-text version +// Link is the link tag callback. Outputs a simple plain-text version // of the input. func (r renderer) Link(out *bytes.Buffer, link []byte, title []byte, content []byte) { out.Write(content) diff --git a/caddyhttp/proxy/proxy.go b/caddyhttp/proxy/proxy.go index aeff1b8f3..fdd642dc8 100644 --- a/caddyhttp/proxy/proxy.go +++ b/caddyhttp/proxy/proxy.go @@ -303,7 +303,7 @@ func (p Proxy) match(r *http.Request) Upstream { return u } -// createUpstremRequest shallow-copies r into a new request +// createUpstreamRequest shallow-copies r into a new request // that can be sent upstream. // // Derived from reverseproxy.go in the standard Go httputil package. diff --git a/caddyhttp/proxy/proxy_test.go b/caddyhttp/proxy/proxy_test.go index 1342b2bea..213647af2 100644 --- a/caddyhttp/proxy/proxy_test.go +++ b/caddyhttp/proxy/proxy_test.go @@ -104,7 +104,7 @@ func TestReverseProxy(t *testing.T) { // Set headers. copyHeader(w.Header(), testHeaders) - // Only announce one of the trailers to test wether + // Only announce one of the trailers to test whether // unannounced trailers are proxied correctly. for k := range testTrailers { w.Header().Set("Trailer", k) @@ -127,7 +127,7 @@ func TestReverseProxy(t *testing.T) { // Create the fake request body. // This will copy "trailersToSet" to r.Trailer right before it is closed and - // thus test for us wether unannounced client trailers are proxied correctly. + // thus test for us whether unannounced client trailers are proxied correctly. body := &trailerTestStringReader{ Reader: *strings.NewReader("test"), trailersToSet: testTrailers, @@ -140,7 +140,7 @@ func TestReverseProxy(t *testing.T) { copyHeader(r.Header, testHeaders) - // Only announce one of the trailers to test wether + // Only announce one of the trailers to test whether // unannounced trailers are proxied correctly. for k, v := range testTrailers { r.Trailer[k] = v @@ -262,7 +262,7 @@ func TestReverseProxyMaxConnLimit(t *testing.T) { } else if code != 0 { t.Errorf("Bad return code for request %d: %d", i, code) } else if w.Code != 200 { - t.Errorf("Bad statuc code for request %d: %d", i, w.Code) + t.Errorf("Bad status code for request %d: %d", i, w.Code) } }(i) } @@ -1037,7 +1037,7 @@ func TestBasicAuth(t *testing.T) { }{ {"Nil Both", nil, nil}, {"Nil Upstream User", nil, url.UserPassword("username", "password")}, - {"Nil Client User", url.UserPassword("usename", "password"), nil}, + {"Nil Client User", url.UserPassword("username", "password"), nil}, {"Both Provided", url.UserPassword("unused", "unused"), url.UserPassword("username", "password")}, } diff --git a/caddyhttp/proxy/reverseproxy.go b/caddyhttp/proxy/reverseproxy.go index d58de620e..452225704 100644 --- a/caddyhttp/proxy/reverseproxy.go +++ b/caddyhttp/proxy/reverseproxy.go @@ -456,7 +456,7 @@ func (rp *ReverseProxy) ServeHTTP(rw http.ResponseWriter, outreq *http.Request, closeBody() // Since Go does not remove keys from res.Trailer we - // can safely do a length comparison to check wether + // can safely do a length comparison to check whether // we received further, unannounced trailers. // // Most of the time forceSetTrailers should be false. diff --git a/caddyhttp/root/root_test.go b/caddyhttp/root/root_test.go index c44e2dc5d..fcfb1bb02 100644 --- a/caddyhttp/root/root_test.go +++ b/caddyhttp/root/root_test.go @@ -36,7 +36,7 @@ func TestRoot(t *testing.T) { t.Fatalf("BeforeTest: Failed to find an existing directory for testing! Error was: %v", err) } - nonExistingDir := filepath.Join(existingDirPath, "highly_unlikely_to_exist_dir") + nonexistentDir := filepath.Join(existingDirPath, "highly_unlikely_to_exist_dir") existingFile, err := ioutil.TempFile("", "root_test") if err != nil { @@ -57,7 +57,7 @@ func TestRoot(t *testing.T) { }{ // positive { - fmt.Sprintf(`root %s`, nonExistingDir), false, nonExistingDir, "", + fmt.Sprintf(`root %s`, nonexistentDir), false, nonexistentDir, "", }, { fmt.Sprintf(`root %s`, existingDirPath), false, existingDirPath, "", diff --git a/caddytls/config.go b/caddytls/config.go index 8b32c4424..ec1b93c06 100644 --- a/caddytls/config.go +++ b/caddytls/config.go @@ -414,7 +414,7 @@ func GetSupportedProtocolName(protocol uint16) (string, error) { } } - return "", fmt.Errorf("name: unsuported protocol") + return "", fmt.Errorf("name: unsupported protocol") } // SupportedCiphersMap has supported ciphers, used only for parsing config. @@ -452,7 +452,7 @@ func GetSupportedCipherName(cipher uint16) (string, error) { } } - return "", fmt.Errorf("name: unsuported cipher") + return "", fmt.Errorf("name: unsupported cipher") } // List of all the ciphers we want to use by default diff --git a/commands_test.go b/commands_test.go index ea5808614..cdee64237 100644 --- a/commands_test.go +++ b/commands_test.go @@ -125,7 +125,7 @@ func TestParseWindowsCommand(t *testing.T) { input: `cmd "a ""quoted value"`, expected: []string{`cmd`, `a "quoted value`}, }, - // TODO - see how many quotes are dislayed if we use "", """, """"""" + // TODO - see how many quotes are displayed if we use "", """, """"""" { // 9 - two quotes outside an inQuote element input: `cmd a ""quoted value`, expected: []string{`cmd`, `a`, `"quoted`, `value`}, diff --git a/onevent/hook/hook_test.go b/onevent/hook/hook_test.go index e473a37f6..a67abf0f7 100644 --- a/onevent/hook/hook_test.go +++ b/onevent/hook/hook_test.go @@ -20,8 +20,8 @@ func TestHook(t *testing.T) { time.Sleep(500 * time.Millisecond) os.RemoveAll(testDir) }() - osSenitiveTestDir := filepath.FromSlash(testDir) - os.RemoveAll(osSenitiveTestDir) // start with a clean slate + osSensitiveTestDir := filepath.FromSlash(testDir) + os.RemoveAll(osSensitiveTestDir) // start with a clean slate tests := []struct { name string @@ -31,8 +31,8 @@ func TestHook(t *testing.T) { shouldErr bool shouldRemoveErr bool }{ - {name: "blocking", event: caddy.InstanceStartupEvent, command: "mkdir", args: []string{osSenitiveTestDir}, shouldErr: false, shouldRemoveErr: false}, - {name: "nonBlocking", event: caddy.ShutdownEvent, command: "mkdir", args: []string{osSenitiveTestDir, "&"}, shouldErr: false, shouldRemoveErr: true}, + {name: "blocking", event: caddy.InstanceStartupEvent, command: "mkdir", args: []string{osSensitiveTestDir}, shouldErr: false, shouldRemoveErr: false}, + {name: "nonBlocking", event: caddy.ShutdownEvent, command: "mkdir", args: []string{osSensitiveTestDir, "&"}, shouldErr: false, shouldRemoveErr: true}, {name: "nonBlocking2", event: caddy.ShutdownEvent, command: "echo", args: []string{"&"}, shouldErr: false, shouldRemoveErr: true}, {name: "nonExistent", event: caddy.CertRenewEvent, command: strconv.Itoa(int(time.Now().UnixNano())), shouldErr: true, shouldRemoveErr: true}, } @@ -52,7 +52,7 @@ func TestHook(t *testing.T) { t.Errorf("Test errored, but it shouldn't have; got '%v'", err) } - err = os.Remove(osSenitiveTestDir) + err = os.Remove(osSensitiveTestDir) if err != nil && !test.shouldRemoveErr { t.Errorf("Test received an error of:\n%v", err) } diff --git a/plugins.go b/plugins.go index 67282bb9c..56f3679af 100644 --- a/plugins.go +++ b/plugins.go @@ -109,7 +109,7 @@ func ListPlugins() map[string][]string { // cluster plugins in registration order for name := range clusterProviders { - p["clustering"] = append(p["clsutering"], name) + p["clustering"] = append(p["clustering"], name) } // List the event hook plugins diff --git a/telemetry/telemetry.go b/telemetry/telemetry.go index 59ab75be2..2aab30b88 100644 --- a/telemetry/telemetry.go +++ b/telemetry/telemetry.go @@ -391,7 +391,7 @@ var ( // If the value is true, it may be removed if // the metric is re-enabled remotely later. If // the value is false, it is permanent - // (presumably becaues the user explicitly + // (presumably because the user explicitly // disabled it) and can only be re-enabled // with user consent. disabledMetrics = make(map[string]bool) diff --git a/upgrade.go b/upgrade.go index 8214937b9..c35f9b1cc 100644 --- a/upgrade.go +++ b/upgrade.go @@ -181,7 +181,7 @@ func getCurrentCaddyfile() (Input, *Instance, error) { currentCaddyfile := inst.caddyfileInput if currentCaddyfile == nil { - // hmm, did spawing process forget to close stdin? Anyhow, this is unusual. + // hmm, did spawning process forget to close stdin? Anyhow, this is unusual. return nil, inst, fmt.Errorf("no Caddyfile to reload (was stdin left open?)") } return currentCaddyfile, inst, nil