mirror of
https://github.com/octoleo/syncthing.git
synced 2025-02-02 11:58:28 +00:00
Add support for header holding IP address
This commit is contained in:
parent
8b3f5fda07
commit
925f60d9c3
@ -67,6 +67,7 @@ var (
|
|||||||
getLimit time.Duration
|
getLimit time.Duration
|
||||||
postLimit time.Duration
|
postLimit time.Duration
|
||||||
permRelaysFile string
|
permRelaysFile string
|
||||||
|
ipHeader string
|
||||||
|
|
||||||
getMut sync.RWMutex = sync.NewRWMutex()
|
getMut sync.RWMutex = sync.NewRWMutex()
|
||||||
getLRUCache *lru.Cache
|
getLRUCache *lru.Cache
|
||||||
@ -94,6 +95,7 @@ func main() {
|
|||||||
flag.IntVar(&postLimitAvg, "post-limit-avg", 2, "Allowed average post request rate, per minute")
|
flag.IntVar(&postLimitAvg, "post-limit-avg", 2, "Allowed average post request rate, per minute")
|
||||||
flag.Int64Var(&postLimitBurst, "post-limit-burst", postLimitBurst, "Allowed burst post requests")
|
flag.Int64Var(&postLimitBurst, "post-limit-burst", postLimitBurst, "Allowed burst post requests")
|
||||||
flag.StringVar(&permRelaysFile, "perm-relays", "", "Path to list of permanent relays")
|
flag.StringVar(&permRelaysFile, "perm-relays", "", "Path to list of permanent relays")
|
||||||
|
flag.StringVar(&ipHeader, "ip-header", "", "Name of header which holds clients ip:port. Only meaningful when running behind a reverse proxy.")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
@ -236,6 +238,9 @@ func mimeTypeForFile(file string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func handleRequest(w http.ResponseWriter, r *http.Request) {
|
func handleRequest(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if ipHeader != "" {
|
||||||
|
r.RemoteAddr = r.Header.Get(ipHeader)
|
||||||
|
}
|
||||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||||
switch r.Method {
|
switch r.Method {
|
||||||
case "GET":
|
case "GET":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user