aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/nsheridan/autocert-wkfs-cache
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/nsheridan/autocert-wkfs-cache')
-rw-r--r--vendor/github.com/nsheridan/autocert-wkfs-cache/License.txt21
-rw-r--r--vendor/github.com/nsheridan/autocert-wkfs-cache/cache.go85
2 files changed, 0 insertions, 106 deletions
diff --git a/vendor/github.com/nsheridan/autocert-wkfs-cache/License.txt b/vendor/github.com/nsheridan/autocert-wkfs-cache/License.txt
deleted file mode 100644
index 09dc147..0000000
--- a/vendor/github.com/nsheridan/autocert-wkfs-cache/License.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2017 Niall Sheridan
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/vendor/github.com/nsheridan/autocert-wkfs-cache/cache.go b/vendor/github.com/nsheridan/autocert-wkfs-cache/cache.go
deleted file mode 100644
index 3b3fd47..0000000
--- a/vendor/github.com/nsheridan/autocert-wkfs-cache/cache.go
+++ /dev/null
@@ -1,85 +0,0 @@
-package wkfscache
-
-import (
- "context"
- "os"
- "path/filepath"
-
- "go4.org/wkfs"
-
- "golang.org/x/crypto/acme/autocert"
-)
-
-type Cache string
-
-// Get reads a certificate data from the specified file name.
-func (d Cache) Get(ctx context.Context, name string) ([]byte, error) {
- name = filepath.Join(string(d), name)
- var (
- data []byte
- err error
- done = make(chan struct{})
- )
- go func() {
- data, err = wkfs.ReadFile(name)
- close(done)
- }()
- select {
- case <-ctx.Done():
- return nil, ctx.Err()
- case <-done:
- }
- if os.IsNotExist(err) {
- return nil, autocert.ErrCacheMiss
- }
- return data, err
-}
-
-// Put writes the certificate data to the specified file name.
-// The file will be created with 0600 permissions.
-func (d Cache) Put(ctx context.Context, name string, data []byte) error {
- if err := wkfs.MkdirAll(string(d), 0700); err != nil {
- return err
- }
-
- done := make(chan struct{})
- var err error
- go func() {
- defer close(done)
- if err := wkfs.WriteFile(filepath.Join(string(d), name), data, 0600); err != nil {
- return
- }
- // prevent overwriting the file if the context was cancelled
- if ctx.Err() != nil {
- return // no need to set err
- }
- }()
- select {
- case <-ctx.Done():
- return ctx.Err()
- case <-done:
- }
- return err
-}
-
-// Delete removes the specified file name.
-func (d Cache) Delete(ctx context.Context, name string) error {
- name = filepath.Join(string(d), name)
- var (
- err error
- done = make(chan struct{})
- )
- go func() {
- err = wkfs.Remove(name)
- close(done)
- }()
- select {
- case <-ctx.Done():
- return ctx.Err()
- case <-done:
- }
- if err != nil && !os.IsNotExist(err) {
- return err
- }
- return nil
-}