Browse Source

fix userinfo header

Co-Authored-By: Alireza Ahmadi <[email protected]>
MHSanaei 1 year ago
parent
commit
5ff6f4094e
2 changed files with 2 additions and 8 deletions
  1. 1 1
      web/controller/sub.go
  2. 1 7
      web/service/sub.go

+ 1 - 1
web/controller/sub.go

@@ -39,7 +39,7 @@ func (a *SUBController) subs(c *gin.Context) {
 		}
 
 		// Add subscription-userinfo
-		c.Writer.Header().Set("subscription-userinfo", header)
+		c.Writer.Header().Set("Subscription-Userinfo", header)
 
 		c.String(200, base64.StdEncoding.EncodeToString([]byte(result)))
 	}

+ 1 - 7
web/service/sub.go

@@ -66,13 +66,7 @@ func (s *SubService) GetSubs(subId string, host string) ([]string, string, error
 			}
 		}
 	}
-	header = fmt.Sprintf("upload=%d;download=%d", traffic.Up, traffic.Down)
-	if traffic.Total > 0 {
-		header = header + fmt.Sprintf(";total=%d", traffic.Total)
-	}
-	if traffic.ExpiryTime > 0 {
-		header = header + fmt.Sprintf(";expire=%d", traffic.ExpiryTime)
-	}
+	header = fmt.Sprintf("upload=%d; download=%d; total=%d; expire=%d", traffic.Up, traffic.Down, traffic.Total, traffic.ExpiryTime/1000)
 	return result, header, nil
 }