소스 검색

Fixed rate limit error on default site

Toby Chui 8 달 전
부모
커밋
5ea17b50c9
7개의 변경된 파일359개의 추가작업 그리고 92개의 파일을 삭제
  1. 20 17
      reverseproxy.go
  2. 88 27
      www/templates/blacklist.html
  3. 32 21
      www/templates/notfound.html
  4. 88 27
      www/templates/whitelist.html
  5. 47 0
      www/templates_uwu/blacklist.html
  6. 37 0
      www/templates_uwu/notfound.html
  7. 47 0
      www/templates_uwu/whitelist.html

+ 20 - 17
reverseproxy.go

@@ -225,7 +225,7 @@ func ReverseProxyHandleAddEndpoint(w http.ResponseWriter, r *http.Request) {
 		return
 	}
 
-	//Require basic auth?
+	// Require basic auth?
 	rba, _ := utils.PostPara(r, "bauth")
 	if rba == "" {
 		rba = "false"
@@ -234,23 +234,26 @@ func ReverseProxyHandleAddEndpoint(w http.ResponseWriter, r *http.Request) {
 	requireBasicAuth := (rba == "true")
 
 	// Require Rate Limiting?
-	rl, _ := utils.PostPara(r, "rate")
-	if rl == "" {
-		rl = "false"
-	}
-	requireRateLimit := (rl == "true")
-	rlnum, _ := utils.PostPara(r, "ratenum")
-	if rlnum == "" {
-		rlnum = "0"
-	}
-	proxyRateLimit, err := strconv.ParseInt(rlnum, 10, 64)
+	requireRateLimit := false
+	proxyRateLimit := 1000
+
+	requireRateLimit, err = utils.PostBool(r, "rate")
 	if err != nil {
-		utils.SendErrorResponse(w, "invalid rate limit number")
-		return
+		requireRateLimit = false
 	}
-	if proxyRateLimit <= 0 {
-		utils.SendErrorResponse(w, "rate limit number must be greater than 0")
-		return
+	if requireRateLimit {
+		proxyRateLimit, err = utils.PostInt(r, "ratenum")
+		if err != nil {
+			proxyRateLimit = 0
+		}
+		if err != nil {
+			utils.SendErrorResponse(w, "invalid rate limit number")
+			return
+		}
+		if proxyRateLimit <= 0 {
+			utils.SendErrorResponse(w, "rate limit number must be greater than 0")
+			return
+		}
 	}
 
 	// Bypass WebSocket Origin Check
@@ -335,7 +338,7 @@ func ReverseProxyHandleAddEndpoint(w http.ResponseWriter, r *http.Request) {
 			DefaultSiteValue:        "",
 			// Rate Limit
 			RequireRateLimit: requireRateLimit,
-			RateLimit:        proxyRateLimit,
+			RateLimit:        int64(proxyRateLimit),
 		}
 
 		preparedEndpoint, err := dynamicProxyRouter.PrepareProxyRoute(&thisProxyEndpoint)

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 88 - 27
www/templates/blacklist.html


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 32 - 21
www/templates/notfound.html


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 88 - 27
www/templates/whitelist.html


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 47 - 0
www/templates_uwu/blacklist.html


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 37 - 0
www/templates_uwu/notfound.html


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 47 - 0
www/templates_uwu/whitelist.html


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.