2018-03-06 05:15:18 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net"
|
|
|
|
"net/http"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
2022-09-03 11:49:54 -04:00
|
|
|
"time"
|
2018-03-06 05:15:18 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
p, err := filepath.Abs(filepath.Join("run", "docker", "plugins"))
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
if err := os.MkdirAll(p, 0755); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
l, err := net.Listen("unix", filepath.Join(p, "basic.sock"))
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
mux := http.NewServeMux()
|
|
|
|
server := http.Server{
|
2022-09-03 11:49:54 -04:00
|
|
|
Addr: l.Addr().String(),
|
|
|
|
Handler: http.NewServeMux(),
|
|
|
|
ReadHeaderTimeout: 2 * time.Second, // G112: Potential Slowloris Attack because ReadHeaderTimeout is not configured in the http.Server
|
2018-03-06 05:15:18 -05:00
|
|
|
}
|
|
|
|
mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1.1+json")
|
|
|
|
fmt.Println(w, `{"Implements": ["dummy"]}`)
|
|
|
|
})
|
|
|
|
server.Serve(l)
|
|
|
|
}
|