File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package config
22
33import (
4- "fmt"
5- "log"
64 "os"
75 "path/filepath"
86
@@ -224,7 +222,6 @@ func LoadConfig(filePath string) (*Config, error) {
224222 }
225223 var config Config
226224 ext := filepath .Ext (filePath )
227- log .Printf ("Loading config from %s with extension %s" , filePath , ext )
228225 if ext == ".wanf" {
229226 if err := wanf .DecodeFile (filePath , & config ); err != nil {
230227 return nil , err
@@ -247,7 +244,6 @@ func (c *Config) WriteConfig(filePath string) error {
247244 defer file .Close ()
248245
249246 ext := filepath .Ext (filePath )
250- fmt .Printf ("%s" , ext )
251247 if ext == ".wanf" {
252248 err := wanf .NewStreamEncoder (file ).Encode (c )
253249 if err != nil {
Original file line number Diff line number Diff line change 44 "bytes"
55 "context"
66 "fmt"
7- "log"
87 "net/http"
98 "net/url"
109 "strconv"
5453// 处理路径各种情况
5554func OciWithImageRouting (cfg * config.Config ) touka.HandlerFunc {
5655 return func (c * touka.Context ) {
56+ if ! cfg .Docker .Enabled {
57+ ErrorPage (c , NewErrorWithStatusLookup (403 , "Docker proxy is not enabled" ))
58+ return
59+ }
5760 var (
5861 p1 string
5962 p2 string
@@ -83,13 +86,10 @@ func OciWithImageRouting(cfg *config.Config) touka.HandlerFunc {
8386 }
8487
8588 // 根据/分割 /:target/:user/:repo/*ext
86- log .Print (ociPath )
87-
8889 ociPath = ociPath [1 :]
8990 i := strings .IndexByte (ociPath , '/' )
9091 if i <= 0 {
9192 ErrorPage (c , NewErrorWithStatusLookup (404 , "Not Found" ))
92- log .Print (1 )
9393 return
9494 }
9595 p1 = ociPath [:i ]
@@ -120,7 +120,6 @@ func OciWithImageRouting(cfg *config.Config) touka.HandlerFunc {
120120 i = strings .IndexByte (ociPath , '/' )
121121 if i <= 0 {
122122 ErrorPage (c , NewErrorWithStatusLookup (404 , "Not Found" ))
123- log .Print (2 )
124123 return
125124 }
126125 p2 = ociPath [:i ]
@@ -151,7 +150,6 @@ func OciWithImageRouting(cfg *config.Config) touka.HandlerFunc {
151150 i = strings .IndexByte (ociPath , '/' )
152151 if i <= 0 {
153152 ErrorPage (c , NewErrorWithStatusLookup (404 , "Not Found" ))
154- log .Print (3 )
155153 return
156154 }
157155 p3 = ociPath [:i ]
You can’t perform that action at this time.
0 commit comments