recycleactor commited on
Commit
6076f9c
·
verified ·
1 Parent(s): 61e3a51

Upload main.rs

Browse files
Files changed (1) hide show
  1. src/main.rs +10 -5
src/main.rs CHANGED
@@ -942,6 +942,9 @@ async fn oauth_access_token(
942
 
943
  let status = r.status();
944
  let text = r.text().await.map_err(|_| "oauth:read".to_string())?;
 
 
 
945
  let v: serde_json::Value = serde_json::from_str(&text).map_err(|_| {
946
  let snip: String = text.chars().take(200).collect();
947
  format!("oauth:parse:{}:{}", status.as_u16(), snip)
@@ -1023,8 +1026,6 @@ async fn gw_light_call(
1023
  .header("X-Requested-With", "XMLHttpRequest")
1024
  .header("Accept-Language", "en-US,en;q=0.9")
1025
  .header("Content-Language", "en-US")
1026
- .header("X-User-IP", "1.1.1.1")
1027
- .header("x-deezer-client-ip", "1.1.1.1")
1028
  .header(
1029
  "User-Agent",
1030
  "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36",
@@ -1035,6 +1036,9 @@ async fn gw_light_call(
1035
 
1036
  let status = r.status();
1037
  let text = r.text().await.map_err(|_| "read".to_string())?;
 
 
 
1038
  let json: GwResp = serde_json::from_str(&text).map_err(|_| {
1039
  let snip: String = text.chars().take(200).collect();
1040
  format!("parse:{}:{}", status.as_u16(), snip)
@@ -1123,8 +1127,6 @@ async fn gw_light_call_custom(
1123
  .header("X-Requested-With", "XMLHttpRequest")
1124
  .header("Accept-Language", "en-US,en;q=0.9")
1125
  .header("Content-Language", "en-US")
1126
- .header("X-User-IP", "1.1.1.1")
1127
- .header("x-deezer-client-ip", "1.1.1.1")
1128
  .header(
1129
  "User-Agent",
1130
  "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36",
@@ -1135,6 +1137,9 @@ async fn gw_light_call_custom(
1135
 
1136
  let status = r.status();
1137
  let text = r.text().await.map_err(|_| "read".to_string())?;
 
 
 
1138
  let json: GwResp = serde_json::from_str(&text).map_err(|_| {
1139
  let snip: String = text.chars().take(200).collect();
1140
  format!("parse:{}:{}", status.as_u16(), snip)
@@ -1465,7 +1470,7 @@ async fn pair_page(Host(host): Host, headers: HeaderMap, Query(q): Query<PairPag
1465
  html.push_str(r#"<div class="muted" style="margin:10px 0 14px">Нажми кнопку, войди в Deezer и подтверди доступ. После успеха вернись на телевизор.</div>"#);
1466
  html.push_str(r#"<button id="dz-login" type="button">Войти через Deezer</button>"#);
1467
  html.push_str(r#"<div id="msg" class="muted" style="margin:12px 0 0"></div>"#);
1468
- html.push_str(r#"<div class="muted" style="margin:12px 0 8px">Если OAuth не работает (redirect_uri) — используй вход по логину/паролю ниже.</div>"#);
1469
  html.push_str(r#"<form method="POST" action="/pair/complete" autocomplete="on" style="margin:10px 0 0">"#);
1470
  html.push_str(r#"<input type="hidden" name="code" value="" id="pair-code-hidden">"#);
1471
  html.push_str(r#"<div class="row"><input name="email" type="email" placeholder="Email" autocomplete="username" required></div>"#);
 
942
 
943
  let status = r.status();
944
  let text = r.text().await.map_err(|_| "oauth:read".to_string())?;
945
+ if status.as_u16() == 403 && text.to_ascii_lowercase().contains("access denied") {
946
+ return Err("oauth:blocked:403".to_string());
947
+ }
948
  let v: serde_json::Value = serde_json::from_str(&text).map_err(|_| {
949
  let snip: String = text.chars().take(200).collect();
950
  format!("oauth:parse:{}:{}", status.as_u16(), snip)
 
1026
  .header("X-Requested-With", "XMLHttpRequest")
1027
  .header("Accept-Language", "en-US,en;q=0.9")
1028
  .header("Content-Language", "en-US")
 
 
1029
  .header(
1030
  "User-Agent",
1031
  "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36",
 
1036
 
1037
  let status = r.status();
1038
  let text = r.text().await.map_err(|_| "read".to_string())?;
1039
+ if status.as_u16() == 403 && text.to_ascii_lowercase().contains("access denied") {
1040
+ return Err("blocked:403".to_string());
1041
+ }
1042
  let json: GwResp = serde_json::from_str(&text).map_err(|_| {
1043
  let snip: String = text.chars().take(200).collect();
1044
  format!("parse:{}:{}", status.as_u16(), snip)
 
1127
  .header("X-Requested-With", "XMLHttpRequest")
1128
  .header("Accept-Language", "en-US,en;q=0.9")
1129
  .header("Content-Language", "en-US")
 
 
1130
  .header(
1131
  "User-Agent",
1132
  "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36",
 
1137
 
1138
  let status = r.status();
1139
  let text = r.text().await.map_err(|_| "read".to_string())?;
1140
+ if status.as_u16() == 403 && text.to_ascii_lowercase().contains("access denied") {
1141
+ return Err("blocked:403".to_string());
1142
+ }
1143
  let json: GwResp = serde_json::from_str(&text).map_err(|_| {
1144
  let snip: String = text.chars().take(200).collect();
1145
  format!("parse:{}:{}", status.as_u16(), snip)
 
1470
  html.push_str(r#"<div class="muted" style="margin:10px 0 14px">Нажми кнопку, войди в Deezer и подтверди доступ. После успеха вернись на телевизор.</div>"#);
1471
  html.push_str(r#"<button id="dz-login" type="button">Войти через Deezer</button>"#);
1472
  html.push_str(r#"<div id="msg" class="muted" style="margin:12px 0 0"></div>"#);
1473
+ html.push_str(r#"<div class="muted" style="margin:12px 0 8px">Рекомендуется OAuth нопка выше). Вход по логину/паролю ниже может блокироваться на некоторых прокси/хостингах (403 Access Denied).</div>"#);
1474
  html.push_str(r#"<form method="POST" action="/pair/complete" autocomplete="on" style="margin:10px 0 0">"#);
1475
  html.push_str(r#"<input type="hidden" name="code" value="" id="pair-code-hidden">"#);
1476
  html.push_str(r#"<div class="row"><input name="email" type="email" placeholder="Email" autocomplete="username" required></div>"#);