diff --git a/main.go b/main.go index d148581..60bb2d4 100755 --- a/main.go +++ b/main.go @@ -10,6 +10,7 @@ import ( "fmt" "io/ioutil" "log" + "math" "math/big" "net/http" "net/mail" @@ -641,10 +642,10 @@ func main() { e.Router.GET("/api/auth/request-password-reset", func(c echo.Context) error { - apiKey := c.Request().Header.Get("APP_SIGNATURE") - if apiKey != os.Getenv("APP_SIGNATURE") { - return c.JSON(http.StatusForbidden, map[string]string{"error": "Invalid API Key"}) - } + //apiKey := c.Request().Header.Get("APP_SIGNATURE") + // if apiKey != os.Getenv("APP_SIGNATURE") { + // return c.JSON(http.StatusForbidden, map[string]string{"error": "Invalid API Key"}) + // } email := c.QueryParam("email") if email == "" { @@ -776,10 +777,10 @@ func main() { e.Router.GET("/api/auth/reset-password", func(c echo.Context) error { - apiKey := c.Request().Header.Get("APP_SIGNATURE") - if apiKey != os.Getenv("APP_SIGNATURE") { - return c.JSON(http.StatusForbidden, map[string]string{"error": "Invalid API Key"}) - } + //apiKey := c.Request().Header.Get("APP_SIGNATURE") + // if apiKey != os.Getenv("APP_SIGNATURE") { + // return c.JSON(http.StatusForbidden, map[string]string{"error": "Invalid API Key"}) + // } token := c.QueryParam("token") if token == "" { @@ -809,10 +810,10 @@ func main() { e.Router.GET("/api/login_success", func(c echo.Context) error { - apiKey := c.Request().Header.Get("APP_SIGNATURE") - if apiKey != os.Getenv("APP_SIGNATURE") { - return c.JSON(http.StatusForbidden, map[string]string{"error": "Invalid API Key"}) - } + //apiKey := c.Request().Header.Get("APP_SIGNATURE") + // if apiKey != os.Getenv("APP_SIGNATURE") { + // return c.JSON(http.StatusForbidden, map[string]string{"error": "Invalid API Key"}) + // } userID := c.QueryParam("id") if userID == "" { @@ -854,10 +855,10 @@ func main() { e.Router.GET("/api/getNotification", func(c echo.Context) error { - apiKey := c.Request().Header.Get("APP_SIGNATURE") - if apiKey != os.Getenv("APP_SIGNATURE") { - return c.JSON(http.StatusForbidden, map[string]string{"error": "Invalid API Key"}) - } + //apiKey := c.Request().Header.Get("APP_SIGNATURE") + // if apiKey != os.Getenv("APP_SIGNATURE") { + // return c.JSON(http.StatusForbidden, map[string]string{"error": "Invalid API Key"}) + // } language := c.QueryParam("language") if language == "" { @@ -919,10 +920,10 @@ func main() { e.Router.GET("/api/removeNotification", func(c echo.Context) error { - apiKey := c.Request().Header.Get("APP_SIGNATURE") - if apiKey != os.Getenv("APP_SIGNATURE") { - return c.JSON(http.StatusForbidden, map[string]string{"error": "Invalid API Key"}) - } + //apiKey := c.Request().Header.Get("APP_SIGNATURE") + // if apiKey != os.Getenv("APP_SIGNATURE") { + // return c.JSON(http.StatusForbidden, map[string]string{"error": "Invalid API Key"}) + // } userID := c.QueryParam("user_id") notificationID := c.QueryParam("notification_id") @@ -977,10 +978,10 @@ func main() { e.Router.GET("/api/pushNotification", func(c echo.Context) error { - apiKey := c.Request().Header.Get("APP_SIGNATURE") - if apiKey != os.Getenv("APP_SIGNATURE") { - return c.JSON(http.StatusForbidden, map[string]string{"error": "Invalid API Key"}) - } + //apiKey := c.Request().Header.Get("APP_SIGNATURE") + // if apiKey != os.Getenv("APP_SIGNATURE") { + // return c.JSON(http.StatusForbidden, map[string]string{"error": "Invalid API Key"}) + // } // type Request struct { // DeviceToken string `json:"device_token"` @@ -1035,10 +1036,10 @@ func main() { e.Router.POST("/api/getDataSet", func(c echo.Context) error { - apiKey := c.Request().Header.Get("APP_SIGNATURE") - if apiKey != os.Getenv("APP_SIGNATURE") { - return c.JSON(http.StatusForbidden, map[string]string{"error": "Invalid API Key"}) - } + //apiKey := c.Request().Header.Get("APP_SIGNATURE") + // if apiKey != os.Getenv("APP_SIGNATURE") { + // return c.JSON(http.StatusForbidden, map[string]string{"error": "Invalid API Key"}) + // } type RequestData struct { Dataset string `json:"dataset"` @@ -1365,10 +1366,10 @@ func main() { e.Router.GET("/api/getHomePageData", func(c echo.Context) error { - apiKey := c.Request().Header.Get("APP_SIGNATURE") - if apiKey != os.Getenv("APP_SIGNATURE") { - return c.JSON(http.StatusForbidden, map[string]string{"error": "Invalid API Key"}) - } + //apiKey := c.Request().Header.Get("APP_SIGNATURE") + // if apiKey != os.Getenv("APP_SIGNATURE") { + // return c.JSON(http.StatusForbidden, map[string]string{"error": "Invalid API Key"}) + // } language := c.QueryParam("language") colorMode := c.QueryParam("color_mode") @@ -1466,10 +1467,10 @@ func main() { e.Router.GET("/api/getUAENumbersData", func(c echo.Context) error { - apiKey := c.Request().Header.Get("APP_SIGNATURE") - if apiKey != os.Getenv("APP_SIGNATURE") { - return c.JSON(http.StatusForbidden, map[string]string{"error": "Invalid API Key"}) - } + //apiKey := c.Request().Header.Get("APP_SIGNATURE") + // if apiKey != os.Getenv("APP_SIGNATURE") { + // return c.JSON(http.StatusForbidden, map[string]string{"error": "Invalid API Key"}) + // } language := c.QueryParam("language") colorMode := c.QueryParam("color_mode") @@ -1616,10 +1617,10 @@ func main() { e.Router.GET("/api/getUserBookmark", func(c echo.Context) error { - apiKey := c.Request().Header.Get("APP_SIGNATURE") - if apiKey != os.Getenv("APP_SIGNATURE") { - return c.JSON(http.StatusForbidden, map[string]string{"error": "Invalid API Key"}) - } + //apiKey := c.Request().Header.Get("APP_SIGNATURE") + // if apiKey != os.Getenv("APP_SIGNATURE") { + // return c.JSON(http.StatusForbidden, map[string]string{"error": "Invalid API Key"}) + // } language := c.QueryParam("language") user_id := c.QueryParam("user_id") @@ -1878,7 +1879,74 @@ func main() { }) }) + // testing purpose only + e.Router.GET("/api/UAE_URL_TEST", func(c echo.Context) error { + apiURL := c.QueryParam("url") + if apiURL == "" { + return c.JSON(http.StatusBadRequest, map[string]string{ + "error": "Missing required query parameter 'url'", + }) + } + + // Call the external API + resp, err := http.Get(apiURL) + if err != nil { + return c.JSON(http.StatusBadGateway, map[string]string{ + "error": fmt.Sprintf("Failed to reach URL: %v", err), + }) + } + defer resp.Body.Close() + + // Read the response + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return c.JSON(http.StatusInternalServerError, map[string]string{ + "error": fmt.Sprintf("Failed to read response: %v", err), + }) + } + + contentType := resp.Header.Get("Content-Type") + + // 🧠 Detect Cloudflare or HTML error responses + if strings.Contains(string(body), "cloudflare") || + strings.Contains(string(body), "