github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/cli/e2e/plugin/basic/basic.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "net" 6 "net/http" 7 "os" 8 "path/filepath" 9 "time" 10 ) 11 12 func main() { 13 p, err := filepath.Abs(filepath.Join("run", "docker", "plugins")) 14 if err != nil { 15 panic(err) 16 } 17 if err := os.MkdirAll(p, 0755); err != nil { 18 panic(err) 19 } 20 l, err := net.Listen("unix", filepath.Join(p, "basic.sock")) 21 if err != nil { 22 panic(err) 23 } 24 25 mux := http.NewServeMux() 26 server := http.Server{ 27 Addr: l.Addr().String(), 28 Handler: http.NewServeMux(), 29 ReadHeaderTimeout: 2 * time.Second, // G112: Potential Slowloris Attack because ReadHeaderTimeout is not configured in the http.Server 30 } 31 mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) { 32 w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1.1+json") 33 fmt.Println(w, `{"Implements": ["dummy"]}`) 34 }) 35 server.Serve(l) 36 }