|
| 1 | +diff --git a/Dockerfile b/Dockerfile |
| 2 | +index a4e3f4a..aa0fde4 100644 |
| 3 | +--- a/Dockerfile |
| 4 | ++++ b/Dockerfile |
| 5 | +@@ -1,7 +1,7 @@ |
| 6 | + ARG GOLANG="1.11.5" |
| 7 | + FROM golang:${GOLANG} as builder |
| 8 | + |
| 9 | +-ARG IMAGINARY_VERSION="dev" |
| 10 | ++ARG IMAGINARY_VERSION="1.1.1" |
| 11 | + ARG LIBVIPS_VERSION="8.7.4" |
| 12 | + ARG GOLANG |
| 13 | + |
| 14 | +@@ -60,7 +60,7 @@ FROM debian:stretch-slim |
| 15 | + |
| 16 | + ARG IMAGINARY_VERSION |
| 17 | + |
| 18 | +-LABEL maintainer="[email protected]" \ |
| 19 | ++LABEL maintainer="[email protected]" \ |
| 20 | + org.label-schema.description="Fast, simple, scalable HTTP microservice for high-level image processing with first-class Docker support" \ |
| 21 | + org.label-schema.schema-version="1.0" \ |
| 22 | + org.label-schema.url="https://github.com/h2non/imaginary" \ |
| 23 | +diff --git a/Makefile b/Makefile |
| 24 | +index be99809..e79cf3b 100644 |
| 25 | +--- a/Makefile |
| 26 | ++++ b/Makefile |
| 27 | +@@ -16,11 +16,11 @@ benchmark: build |
| 28 | + |
| 29 | + docker-build: |
| 30 | + @echo "$(OK_COLOR)==> Building Docker image$(NO_COLOR)" |
| 31 | +- docker build --no-cache=true -t h2non/imaginary:$(VERSION) . |
| 32 | ++ docker build --no-cache=true -t pslurp/imaginary:$(VERSION) . |
| 33 | + |
| 34 | + docker-push: |
| 35 | + @echo "$(OK_COLOR)==> Pushing Docker image v$(VERSION) $(NO_COLOR)" |
| 36 | +- docker push h2non/imaginary:$(VERSION) |
| 37 | ++ docker push pslurp/imaginary:$(VERSION) |
| 38 | + |
| 39 | + docker: docker-build docker-push |
| 40 | + |
| 41 | +diff --git a/imaginary.go b/imaginary.go |
| 42 | +index f38da13..0760a8f 100644 |
| 43 | +--- a/imaginary.go |
| 44 | ++++ b/imaginary.go |
| 45 | +@@ -48,6 +48,8 @@ var ( |
| 46 | + aBurst = flag.Int("burst", 100, "Throttle burst max cache size") |
| 47 | + aMRelease = flag.Int("mrelease", 30, "OS memory release interval in seconds") |
| 48 | + aCpus = flag.Int("cpus", runtime.GOMAXPROCS(-1), "Number of cpu cores to use") |
| 49 | ++ aIgnoreCertErrors = flag.Bool("ignore-cert-errors", false, "Disables certificate checks for remote images") |
| 50 | ++ aUserAgent = flag.String("user-agent", "imaginary/"+Version, "User-Agent to send to remote sources") |
| 51 | + ) |
| 52 | + |
| 53 | + const usage = `imaginary %s |
| 54 | +@@ -100,6 +102,8 @@ Options: |
| 55 | + -mrelease <num> OS memory release interval in seconds [default: 30] |
| 56 | + -cpus <num> Number of used cpu cores. |
| 57 | + (default for current machine is %d cores) |
| 58 | ++ -ignore-cert-errors Disables certificate checks for remote images |
| 59 | ++ -user-agent User-Agent to send to remote sources |
| 60 | + ` |
| 61 | + |
| 62 | + type URLSignature struct { |
| 63 | +@@ -149,6 +153,8 @@ func main() { |
| 64 | + ForwardHeaders: parseForwardHeaders(*aForwardHeaders), |
| 65 | + AllowedOrigins: parseOrigins(*aAllowedOrigins), |
| 66 | + MaxAllowedSize: *aMaxAllowedSize, |
| 67 | ++ IgnoreCertErrors: *aIgnoreCertErrors, |
| 68 | ++ UserAgent: *aUserAgent, |
| 69 | + } |
| 70 | + |
| 71 | + // Show warning if gzip flag is passed |
| 72 | +diff --git a/server.go b/server.go |
| 73 | +index 6e35ca9..729d3ad 100644 |
| 74 | +--- a/server.go |
| 75 | ++++ b/server.go |
| 76 | +@@ -37,6 +37,8 @@ type ServerOptions struct { |
| 77 | + PlaceholderImage []byte |
| 78 | + Endpoints Endpoints |
| 79 | + AllowedOrigins []*url.URL |
| 80 | ++ IgnoreCertErrors bool |
| 81 | ++ UserAgent string |
| 82 | + } |
| 83 | + |
| 84 | + // Endpoints represents a list of endpoint names to disable. |
| 85 | +diff --git a/source.go b/source.go |
| 86 | +index 572e6aa..72b73e5 100644 |
| 87 | +--- a/source.go |
| 88 | ++++ b/source.go |
| 89 | +@@ -16,6 +16,8 @@ type SourceConfig struct { |
| 90 | + ForwardHeaders []string |
| 91 | + AllowedOrigins []*url.URL |
| 92 | + MaxAllowedSize int |
| 93 | ++ IgnoreCertErrors bool |
| 94 | ++ UserAgent string |
| 95 | + } |
| 96 | + |
| 97 | + var imageSourceMap = make(map[ImageSourceType]ImageSource) |
| 98 | +@@ -40,6 +42,8 @@ func LoadSources(o ServerOptions) { |
| 99 | + AllowedOrigins: o.AllowedOrigins, |
| 100 | + MaxAllowedSize: o.MaxAllowedSize, |
| 101 | + ForwardHeaders: o.ForwardHeaders, |
| 102 | ++ IgnoreCertErrors: o.IgnoreCertErrors, |
| 103 | ++ UserAgent: o.UserAgent, |
| 104 | + }) |
| 105 | + } |
| 106 | + } |
| 107 | +diff --git a/source_http.go b/source_http.go |
| 108 | +index 6cdbbd5..409c132 100644 |
| 109 | +--- a/source_http.go |
| 110 | ++++ b/source_http.go |
| 111 | +@@ -5,6 +5,7 @@ import ( |
| 112 | + "io/ioutil" |
| 113 | + "net/http" |
| 114 | + "net/url" |
| 115 | ++ "crypto/tls" |
| 116 | + "strconv" |
| 117 | + "strings" |
| 118 | + ) |
| 119 | +@@ -39,7 +40,14 @@ func (s *HTTPImageSource) fetchImage(url *url.URL, ireq *http.Request) ([]byte, |
| 120 | + // Check remote image size by fetching HTTP Headers |
| 121 | + if s.Config.MaxAllowedSize > 0 { |
| 122 | + req := newHTTPRequest(s, ireq, http.MethodHead, url) |
| 123 | +- res, err := http.DefaultClient.Do(req) |
| 124 | ++ client := *http.DefaultClient |
| 125 | ++ if s.Config.IgnoreCertErrors { |
| 126 | ++ tr := &http.Transport{ |
| 127 | ++ TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, |
| 128 | ++ } |
| 129 | ++ client = http.Client{Transport: tr} |
| 130 | ++ } |
| 131 | ++ res, err := client.Do(req) |
| 132 | + if err != nil { |
| 133 | + return nil, fmt.Errorf("error fetching image http headers: %v", err) |
| 134 | + } |
| 135 | +@@ -56,7 +64,14 @@ func (s *HTTPImageSource) fetchImage(url *url.URL, ireq *http.Request) ([]byte, |
| 136 | + |
| 137 | + // Perform the request using the default client |
| 138 | + req := newHTTPRequest(s, ireq, http.MethodGet, url) |
| 139 | +- res, err := http.DefaultClient.Do(req) |
| 140 | ++ client := *http.DefaultClient |
| 141 | ++ if s.Config.IgnoreCertErrors { |
| 142 | ++ tr := &http.Transport{ |
| 143 | ++ TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, |
| 144 | ++ } |
| 145 | ++ client = http.Client{Transport: tr} |
| 146 | ++ } |
| 147 | ++ res, err := client.Do(req) |
| 148 | + if err != nil { |
| 149 | + return nil, fmt.Errorf("error downloading image: %v", err) |
| 150 | + } |
| 151 | +@@ -101,7 +116,7 @@ func parseURL(request *http.Request) (*url.URL, error) { |
| 152 | + |
| 153 | + func newHTTPRequest(s *HTTPImageSource, ireq *http.Request, method string, url *url.URL) *http.Request { |
| 154 | + req, _ := http.NewRequest(method, url.String(), nil) |
| 155 | +- req.Header.Set("User-Agent", "imaginary/"+Version) |
| 156 | ++ req.Header.Set("User-Agent", s.Config.UserAgent) |
| 157 | + req.URL = url |
| 158 | + |
| 159 | + if len(s.Config.ForwardHeaders) != 0 { |
| 160 | +diff --git a/version.go b/version.go |
| 161 | +index 75eb4f7..5491fa2 100644 |
| 162 | +--- a/version.go |
| 163 | ++++ b/version.go |
| 164 | +@@ -1,7 +1,7 @@ |
| 165 | + package main |
| 166 | + |
| 167 | + // Version stores the current package semantic version |
| 168 | +-var Version = "dev" |
| 169 | ++var Version = "1.1.1" |
| 170 | + |
| 171 | + // Versions represents the used versions for several significant dependencies |
| 172 | + type Versions struct { |
0 commit comments