mirror of
https://github.com/rclone/rclone.git
synced 2024-11-26 02:14:42 +01:00
rcd: disable duplicate log
if running `rclone rcd --rc-user=admin --rc-pass=admin --rc-allow-origin="*"`, lots of duplicate warnings apperent in log Warning: Allow origin set to *. This can cause serious security problems. Warning: Allow origin set to *. This can cause serious security problems. .... This is not conducive to analyzing debugging info. Therefore, let's show it only once.
This commit is contained in:
parent
bdc91eda0f
commit
d119bfd934
@ -14,6 +14,7 @@ import (
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@ -34,6 +35,7 @@ import (
|
||||
)
|
||||
|
||||
var promHandler http.Handler
|
||||
var onlyOnceWarningAllowOrigin sync.Once
|
||||
|
||||
func init() {
|
||||
rcloneCollector := accounting.NewRcloneCollector()
|
||||
@ -187,9 +189,11 @@ func (s *Server) handler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
allowOrigin := rcflags.Opt.AccessControlAllowOrigin
|
||||
if allowOrigin != "" {
|
||||
if allowOrigin == "*" {
|
||||
fs.Logf(nil, "Warning: Allow origin set to *. This can cause serious security problems.")
|
||||
}
|
||||
onlyOnceWarningAllowOrigin.Do(func() {
|
||||
if allowOrigin == "*" {
|
||||
fs.Logf(nil, "Warning: Allow origin set to *. This can cause serious security problems.")
|
||||
}
|
||||
})
|
||||
w.Header().Add("Access-Control-Allow-Origin", allowOrigin)
|
||||
} else {
|
||||
w.Header().Add("Access-Control-Allow-Origin", s.URL())
|
||||
|
Loading…
Reference in New Issue
Block a user