mirror of
https://git.ethanthesleepy.one/ethanaobrien/ew.git
synced 2025-05-13 11:37:33 -05:00
Gree working
This commit is contained in:
parent
5c420184ac
commit
2fc7a17d4f
5 changed files with 83 additions and 9 deletions
16
src/main.rs
16
src/main.rs
|
@ -15,6 +15,18 @@ async fn gree_init(req: HttpRequest, body: String) -> HttpResponse { router::gre
|
|||
#[get("/v1.0/auth/x_uid")]
|
||||
async fn gree_uid(req: HttpRequest) -> HttpResponse { router::gree::uid(req) }
|
||||
|
||||
#[get("/v1.0/payment/productlist")]
|
||||
async fn gree_payment(req: HttpRequest) -> HttpResponse { router::gree::payment(req) }
|
||||
|
||||
#[get("/v1.0/payment/subscription/productlist")]
|
||||
async fn gree_payment_sub(req: HttpRequest) -> HttpResponse { router::gree::payment(req) }
|
||||
|
||||
#[get("/v1.0/payment/ticket/status")]
|
||||
async fn gree_payment_ticket(req: HttpRequest) -> HttpResponse { router::gree::payment_ticket(req) }
|
||||
|
||||
#[get("/v1.0/moderate/keywordlist")]
|
||||
async fn gree_moderate_keyword(req: HttpRequest) -> HttpResponse { router::gree::moderate_keyword(req) }
|
||||
|
||||
#[post("/v1.0/auth/authorize")]
|
||||
async fn gree_authorize(req: HttpRequest, body: String) -> HttpResponse { router::gree::authorize(req, body) }
|
||||
|
||||
|
@ -145,6 +157,10 @@ async fn main() -> std::io::Result<()> {
|
|||
.service(gree_init)
|
||||
.service(gree_uid)
|
||||
.service(gree_authorize)
|
||||
.service(gree_payment)
|
||||
.service(gree_payment_ticket)
|
||||
.service(gree_payment_sub)
|
||||
.service(gree_moderate_keyword)
|
||||
.service(debug_error)
|
||||
.service(login_bonus)
|
||||
.service(reward)
|
||||
|
|
1
src/router/chat_missions.json
Normal file
1
src/router/chat_missions.json
Normal file
File diff suppressed because one or more lines are too long
|
@ -26,7 +26,8 @@ pub fn get_login(headers: &HeaderMap) -> String {
|
|||
let token = parts[1..parts.len() - 1].join("-");
|
||||
return token.to_string();
|
||||
}
|
||||
let key = headers.get("f19c72ba").unwrap_or(&blank_header).to_str().unwrap_or("");
|
||||
//only jp should error?
|
||||
let key = headers.get("aoharu-user-id").unwrap_or(&blank_header).to_str().unwrap_or("");
|
||||
key.to_string()
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@ use json::object;
|
|||
use hmac::{Hmac, Mac};
|
||||
use crate::router::userdata;
|
||||
|
||||
pub fn initialize(req: HttpRequest, _body: String) -> HttpResponse {
|
||||
pub fn initialize(req: HttpRequest, body: String) -> HttpResponse {
|
||||
//println!("{}", body);
|
||||
let app_id = "232610769078541";
|
||||
let resp = object!{
|
||||
result: "OK",
|
||||
|
@ -28,6 +29,7 @@ pub fn initialize(req: HttpRequest, _body: String) -> HttpResponse {
|
|||
}
|
||||
|
||||
pub fn authorize(req: HttpRequest, _body: String) -> HttpResponse {
|
||||
|
||||
let resp = object!{
|
||||
result: "OK"
|
||||
};
|
||||
|
@ -41,6 +43,25 @@ pub fn authorize(req: HttpRequest, _body: String) -> HttpResponse {
|
|||
.body(json::stringify(resp))
|
||||
}
|
||||
|
||||
pub fn moderate_keyword(req: HttpRequest) -> HttpResponse {
|
||||
|
||||
let resp = object!{
|
||||
result: "OK",
|
||||
entry: {
|
||||
timestamp: global::timestamp(),
|
||||
keywords: [{"id":"1","type":"0","keyword":"oink","rank":"0"}]
|
||||
}
|
||||
};
|
||||
HttpResponse::Ok()
|
||||
.insert_header(ContentType::json())
|
||||
.insert_header(("Expires", "-1"))
|
||||
.insert_header(("Pragma", "no-cache"))
|
||||
.insert_header(("Cache-Control", "must-revalidate, no-cache, no-store, private"))
|
||||
.insert_header(("Vary", "Authorization,Accept-Encoding"))
|
||||
.insert_header(("X-GREE-Authorization", gree_authorize(&req)))
|
||||
.body(json::stringify(resp))
|
||||
}
|
||||
|
||||
pub fn uid(req: HttpRequest) -> HttpResponse {
|
||||
let app_id = "232610769078541";
|
||||
|
||||
|
@ -54,14 +75,15 @@ pub fn uid(req: HttpRequest) -> HttpResponse {
|
|||
uid = uid_str.to_string();
|
||||
}
|
||||
}
|
||||
//println!("{}", auth_header);
|
||||
|
||||
let key = uid.substring(app_id.len(), uid.len());
|
||||
let user = userdata::get_acc(&key);
|
||||
|
||||
let resp = object!{
|
||||
result: "OK",
|
||||
x_app_id: "100900301",
|
||||
x_uid: user["user"]["id"].to_string()
|
||||
x_uid: user["user"]["id"].to_string(),
|
||||
x_app_id: "100900301"
|
||||
};
|
||||
|
||||
HttpResponse::Ok()
|
||||
|
@ -69,7 +91,41 @@ pub fn uid(req: HttpRequest) -> HttpResponse {
|
|||
.insert_header(("Expires", "-1"))
|
||||
.insert_header(("Pragma", "no-cache"))
|
||||
.insert_header(("Cache-Control", "must-revalidate, no-cache, no-store, private"))
|
||||
.insert_header(("Vary", "Authorization,Accept-Encoding"))
|
||||
.insert_header(("Vary", "Authorization"))
|
||||
.insert_header(("X-GREE-Authorization", gree_authorize(&req)))
|
||||
.body(json::stringify(resp))
|
||||
}
|
||||
|
||||
pub fn payment(req: HttpRequest) -> HttpResponse {
|
||||
let resp = object!{
|
||||
result: "OK",
|
||||
entry: {
|
||||
products :[],
|
||||
welcome: "0"
|
||||
}
|
||||
};
|
||||
|
||||
HttpResponse::Ok()
|
||||
.insert_header(ContentType::json())
|
||||
.insert_header(("Expires", "-1"))
|
||||
.insert_header(("Pragma", "no-cache"))
|
||||
.insert_header(("Cache-Control", "must-revalidate, no-cache, no-store, private"))
|
||||
.insert_header(("Vary", "Authorization"))
|
||||
.insert_header(("X-GREE-Authorization", gree_authorize(&req)))
|
||||
.body(json::stringify(resp))
|
||||
}
|
||||
pub fn payment_ticket(req: HttpRequest) -> HttpResponse {
|
||||
let resp = object!{
|
||||
result: "OK",
|
||||
entry: []
|
||||
};
|
||||
|
||||
HttpResponse::Ok()
|
||||
.insert_header(ContentType::json())
|
||||
.insert_header(("Expires", "-1"))
|
||||
.insert_header(("Pragma", "no-cache"))
|
||||
.insert_header(("Cache-Control", "must-revalidate, no-cache, no-store, private"))
|
||||
.insert_header(("Vary", "Authorization"))
|
||||
.insert_header(("X-GREE-Authorization", gree_authorize(&req)))
|
||||
.body(json::stringify(resp))
|
||||
}
|
||||
|
@ -95,13 +151,13 @@ fn gree_authorize(req: &HttpRequest) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
let current_url = format!("http://127.0.0.1:8080{}", req.path());
|
||||
let hostname = req.headers().get("host").unwrap_or(&blank_header).to_str().unwrap_or("");
|
||||
let current_url = format!("http://{}{}", hostname, req.path());
|
||||
let nonce = format!("{:x}", md5::compute((global::timestamp() * 1000).to_string()));
|
||||
let timestamp = global::timestamp().to_string();
|
||||
let method = "HMAC-SHA1";
|
||||
let validate_data = format!("{}&{}&{}",
|
||||
"POST",
|
||||
req.method(),
|
||||
urlencoding::encode(¤t_url),
|
||||
urlencoding::encode(&format!("oauth_body_hash={}&oauth_consumer_key={}&oauth_nonce={}&oauth_signature_method={}&oauth_timestamp={}&oauth_version=1.0",
|
||||
header_data.get("oauth_body_hash").unwrap_or(&String::new()),
|
||||
|
|
|
@ -12,7 +12,7 @@ pub fn mission(req: HttpRequest) -> HttpResponse {
|
|||
"code": 0,
|
||||
"server_time": global::timestamp(),
|
||||
"data": {
|
||||
"mission_list": user["live_mission_list"].clone()
|
||||
"mission_list": []
|
||||
}
|
||||
};
|
||||
global::send(resp)
|
||||
|
|
Loading…
Add table
Reference in a new issue