File tree 3 files changed +16
-1
lines changed
3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -13,3 +13,8 @@ GITHUB_CLIENT_SECRET=
13
13
# Discord
14
14
15
15
DISCORD_WEBHOOK_URL =
16
+
17
+ # Config
18
+
19
+ # Globally disables download counting, in the event of abuse
20
+ DISABLE_DOWNLOAD_COUNTS = 0
Original file line number Diff line number Diff line change @@ -189,6 +189,13 @@ pub async fn download_version(
189
189
} ;
190
190
let url = mod_version. download_link ;
191
191
192
+ if data. disable_downloads {
193
+ // whatever
194
+ return Ok ( HttpResponse :: Found ( )
195
+ . append_header ( ( "Location" , url) )
196
+ . finish ( ) ) ;
197
+ }
198
+
192
199
let ip = match info. realip_remote_addr ( ) {
193
200
None => return Err ( ApiError :: InternalError ) ,
194
201
Some ( i) => i,
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ pub struct AppData {
26
26
github_client_id : String ,
27
27
github_client_secret : String ,
28
28
webhook_url : String ,
29
+ disable_downloads : bool ,
29
30
}
30
31
31
32
#[ derive( Debug , Parser ) ]
@@ -65,13 +66,15 @@ async fn main() -> anyhow::Result<()> {
65
66
let github_client = dotenvy:: var ( "GITHUB_CLIENT_ID" ) . unwrap_or ( "" . to_string ( ) ) ;
66
67
let github_secret = dotenvy:: var ( "GITHUB_CLIENT_SECRET" ) . unwrap_or ( "" . to_string ( ) ) ;
67
68
let webhook_url = dotenvy:: var ( "DISCORD_WEBHOOK_URL" ) . unwrap_or ( "" . to_string ( ) ) ;
69
+ let disable_downloads = dotenvy:: var ( "DISABLE_DOWNLOAD_COUNTS" ) . unwrap_or ( "0" . to_string ( ) ) == "1" ;
68
70
69
71
let app_data = AppData {
70
72
db : pool. clone ( ) ,
71
73
app_url : app_url. clone ( ) ,
72
74
github_client_id : github_client. clone ( ) ,
73
75
github_client_secret : github_secret. clone ( ) ,
74
- webhook_url : webhook_url. clone ( )
76
+ webhook_url : webhook_url. clone ( ) ,
77
+ disable_downloads,
75
78
} ;
76
79
77
80
let args = Args :: parse ( ) ;
You can’t perform that action at this time.
0 commit comments