diff --git a/VERSION b/VERSION index 3a3cd8c..26aaba0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.3.1 +1.2.0 diff --git a/src/cmd/collerd/README.md b/src/cmd/collerd/README.md index a8936e4..9c0aae1 100644 --- a/src/cmd/collerd/README.md +++ b/src/cmd/collerd/README.md @@ -41,11 +41,9 @@ The file format is **JSON**: * **tls_key_file** (string): Path to TLS key file to enable HTTPS * **ace_directory** (string): Serve [Ace](hhttps://ace.c9.io/) assets from this local directory (ex: "./node_modules/ace-builds"). See **Dependencies** for details. * **bootstrap_directory** (string): Serve [Bootstrap](https://getbootstrap.com/) assets from this local directory (ex: "./node_modules/bootstrap/dist"). See **Dependencies** for details. -* **clients_base_directory** (string): Serve clients binaries from this local base directory (ex: "./releases"). The version will be append to the directory. Ignored if `show_version` is disabled. -* **clients_base_url** (string): Define the base URL to download clients (default "https://git.riou.xyz/jriou/coller/releases/download"). The version (or "latest") will be append. * **disable_editor** (bool): Disable Ace editor. -The configuration file is optional. +The configuration file is not required but the service might not be exposed to the public. ## API diff --git a/src/server/config.go b/src/server/config.go index 9e41bd8..bb27bd2 100644 --- a/src/server/config.go +++ b/src/server/config.go @@ -34,8 +34,6 @@ type Config struct { AceDirectory string `json:"ace_directory"` BootstrapDirectory string `json:"bootstrap_directory"` DisableEditor bool `json:"disable_editor"` - ClientsBaseURL string `json:"clients_base_url"` - ClientsBaseDirectory string `json:"clients_base_directory"` } func NewConfig() *Config { @@ -82,7 +80,6 @@ func NewConfig() *Config { Language: "text", EnableUploadFileButton: true, EnablePasswordProtection: true, - ClientsBaseURL: "https://git.riou.xyz/jriou/coller/releases/download", } } diff --git a/src/server/handlers_api.go b/src/server/handlers_api.go index 56b2451..74000b3 100644 --- a/src/server/handlers_api.go +++ b/src/server/handlers_api.go @@ -232,10 +232,8 @@ func (h *GetProtectedNoteHandler) ServeHTTP(w http.ResponseWriter, r *http.Reque } type ClientHandler struct { - logger *slog.Logger - version string - baseURL string - baseDirectory string + logger *slog.Logger + version string } func (h *ClientHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { @@ -250,19 +248,10 @@ func (h *ClientHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } - // No disclosure of the version running on the server - if h.version == "" { - http.Redirect(w, r, fmt.Sprintf("%s/%s/%s-%s-%s", h.baseURL, "latest", clientName, os, arch), http.StatusMovedPermanently) - return + version := h.version + if version == "" { + version = "latest" } - if h.baseDirectory != "" { - // Serve file locally - // Example: ./releases/1.2.0/coller-linux-amd64 - http.ServeFile(w, r, fmt.Sprintf("%s/%s/%s-%s-%s", h.baseDirectory, h.version, clientName, os, arch)) - } else { - // Redirect to a download link - // Example: https://git.riou.xyz/jriou/coller/releases/download/1.2.0/coller-linux-amd64 - http.Redirect(w, r, fmt.Sprintf("%s/%s/%s-%s-%s", h.baseURL, h.version, clientName, os, arch), http.StatusMovedPermanently) - } + http.Redirect(w, r, fmt.Sprintf("https://git.riou.xyz/jriou/%s/releases/download/%s/%s-%s-%s", clientName, version, clientName, os, arch), http.StatusMovedPermanently) } diff --git a/src/server/handlers_web.go b/src/server/handlers_web.go index a3c018d..c1a38ac 100644 --- a/src/server/handlers_web.go +++ b/src/server/handlers_web.go @@ -147,12 +147,10 @@ func (h *CreateNoteWithFormHandler) ServeHTTP(w http.ResponseWriter, r *http.Req if !h.PageData.AllowNoEncryption && noEncryption != "" { h.WebError(w, logger, ErrEncryptionRequired, nil) - return } if !h.PageData.AllowClientEncryptionKey && encryptionKey != "" { h.WebError(w, logger, ErrClientEncryptionKeyNotAllowed, nil) - return } if !h.PageData.AllowClientEncryptionKey && encryptionKey == "" && noEncryption == "" { diff --git a/src/server/server.go b/src/server/server.go index 77950a1..df86710 100644 --- a/src/server/server.go +++ b/src/server/server.go @@ -133,10 +133,8 @@ func (s *Server) Start() error { r.Path("/clients.html").Handler(clientsHandler).Methods("GET") clientHandler := &ClientHandler{ - logger: s.logger, - version: p.Version, - baseURL: s.config.ClientsBaseURL, - baseDirectory: s.config.ClientsBaseDirectory, + logger: s.logger, + version: p.Version, } r.Path("/clients/{os:[a-z]+}-{arch:[a-z0-9]+}/{clientName:[a-z]+}").Handler(clientHandler).Methods("GET") @@ -179,9 +177,7 @@ func (s *Server) Start() error { } if s.config.BootstrapDirectory != "" { - r.HandleFunc("/static/bootstrap/css/bootstrap.min.css", func(w http.ResponseWriter, r *http.Request) { - http.ServeFile(w, r, s.config.BootstrapDirectory+"/css/bootstrap.min.css") - }) + r.PathPrefix("/static/bootstrap/").Handler(http.StripPrefix("/static/bootstrap/", http.FileServer(http.Dir(s.config.BootstrapDirectory)))) } r.Path("/").Handler(&HomeHandler{Templates: templates, PageData: p}).Methods("GET") diff --git a/src/server/templates/note.html b/src/server/templates/note.html index 03aca94..498aea2 100644 --- a/src/server/templates/note.html +++ b/src/server/templates/note.html @@ -48,7 +48,7 @@ if (encryptionKey != "") { copierCommand += "#" + encryptionKey; } - document.getElementById("copierCommand").innerText = copierCommand; + document.getElementById("copierCommand").innerHTML = copierCommand; document.getElementById("copier").addEventListener("click", () => { document.getElementById("copierContainer").style.display = ""; }); @@ -77,7 +77,7 @@ curlCommand += " -XPOST -d '" + payload + "'"; } curlCommand += " " + window.location.origin + "/api/note/{{ .Note.ID }}"; - document.getElementById("curlCommand").innerText = curlCommand; + document.getElementById("curlCommand").innerHTML = curlCommand; document.getElementById("curl").addEventListener("click", () => { document.getElementById("curlContainer").style.display = ""; });