mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-07 02:21:23 +00:00
wip
This commit is contained in:
1 parent
d4473b852c
commit
82952e240e
2 files changed
+32
-15
No files matched your search
+20
-15
@@ -1,4 +1,5 @@
|
||||
use std::ops::Deref;
|
||||
use std::time::Duration;
|
||||
use log::info;
|
||||
use tokio::io::AsyncReadExt;
|
||||
use wreq::Client;
|
||||
@@ -11,6 +12,7 @@ use crate::error::grok_generic_api_error::GrokGenericApiError;
|
||||
|
||||
const WEBSOCKET_URL: &str = "wss://grok.com/ws/imagine/listen";
|
||||
//const WEBSOCKET_URL: &str = "https://grok.com/ws/imagine/listen";
|
||||
//const TASKS_URL: &str = "https://grok.com/rest/tasks";
|
||||
|
||||
pub struct CreateListenWebsocketArgs<'a> {
|
||||
pub cookies: &'a str,
|
||||
@@ -21,7 +23,9 @@ pub async fn create_listen_websocket(args: CreateListenWebsocketArgs<'_>) -> Res
|
||||
info!("Building client...");
|
||||
|
||||
let client = Client::builder()
|
||||
.emulation(Emulation::Firefox139)
|
||||
.emulation(Emulation::Safari26)
|
||||
.cert_verification(false)
|
||||
.connect_timeout(Duration::from_secs(10))
|
||||
.build()
|
||||
.map_err(|err| GrokClientError::WreqClientError(err))?;
|
||||
|
||||
@@ -36,22 +40,23 @@ pub async fn create_listen_websocket(args: CreateListenWebsocketArgs<'_>) -> Res
|
||||
.header("Accept", "*/*")
|
||||
.header("Accept-Language", "en-US,en;q=0.5")
|
||||
.header("Accept-Encoding", "gzip, deflate, br, zstd")
|
||||
.header("Sec-WebSocket-Version", "13")
|
||||
//.header("Sec-WebSocket-Version", "13")
|
||||
.header("Origin", "https://grok.com")
|
||||
.header("Sec-WebSocket-Extensions", "permessage-deflate")
|
||||
.header("Sec-WebSocket-Key", "BhBXbFSG6/1xcZVq4ySxcg==") // TODO
|
||||
.header("Sec-GPC", "1")
|
||||
.header("Connection", "keep-alive, Upgrade")
|
||||
//.header("Sec-WebSocket-Extensions", "permessage-deflate")
|
||||
//.header("Sec-WebSocket-Key", "BhBXbFSG6/1xcZVq4ySxcg==") // TODO
|
||||
//.header("Sec-GPC", "1")
|
||||
//.header("Connection", "keep-alive, Upgrade")
|
||||
.header("Cookie", cookies)
|
||||
.header("Sec-Fetch-Dest", "empty")
|
||||
.header("Sec-Fetch-Mode", "websocket")
|
||||
.header("Sec-Fetch-Site", "same-origin")
|
||||
.header("Pragma", "no-cache")
|
||||
.header("Cache-Control", "no-cache")
|
||||
.header("Upgrade", "websocket")
|
||||
//.header("Sec-Fetch-Dest", "empty")
|
||||
//.header("Sec-Fetch-Mode", "websocket")
|
||||
//.header("Sec-Fetch-Site", "same-origin")
|
||||
//.header("Pragma", "no-cache")
|
||||
//.header("Cache-Control", "no-cache")
|
||||
//.header("Upgrade", "websocket")
|
||||
.header("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:144.0) Gecko/20100101 Firefox/144.0")
|
||||
.read_buffer_size(1024 * 1024)
|
||||
.write_buffer_size(1024 * 1024);
|
||||
//.read_buffer_size(1024 * 1024)
|
||||
//.write_buffer_size(1024 * 1024)
|
||||
;
|
||||
|
||||
println!("Sending...");
|
||||
info!("Sending...");
|
||||
@@ -81,7 +86,6 @@ pub async fn create_listen_websocket(args: CreateListenWebsocketArgs<'_>) -> Res
|
||||
println!("Into websocket...");
|
||||
info!("Into websocket...");
|
||||
|
||||
/*
|
||||
// ApiGeneric(WreqError(wreq::Error { kind: Upgrade, source: "unexpected status code: 403 Forbidden" }))
|
||||
let mut websocket = response.into_websocket()
|
||||
.await
|
||||
@@ -91,6 +95,7 @@ pub async fn create_listen_websocket(args: CreateListenWebsocketArgs<'_>) -> Res
|
||||
println!("WebSocket subprotocol: {:?}", protocol);
|
||||
}
|
||||
|
||||
/*
|
||||
let message = r#"
|
||||
{"type":"conversation.item.create","timestamp":1760673207293,"item":{"type":"message","content":[{"requestId":"3cedf20e-f51f-da5d-a124-ccec05faedf1","text":"A pirannah","type":"input_text","properties":{"section_count":0,"is_kids_mode":false,"enable_nsfw":true,"skip_upsampler":false,"is_initial":false}}]}}
|
||||
"#.trim().to_string();
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
curl 'wss://grok.com/ws/imagine/listen' \
|
||||
-H 'Upgrade: websocket' \
|
||||
-H 'Origin: https://grok.com' \
|
||||
-H 'Cache-Control: no-cache' \
|
||||
-H 'Accept-Language: en-US,en;q=0.9' \
|
||||
-H 'Pragma: no-cache' \
|
||||
-b 'cf_clearance=o10zUU.x20fFOkj6tPIzI73QFT.kG3rLwdtt5P9KNzI-1760710012-1.2.1.1-q0vgGudZ42zQLs1EEEdVDkqeJGaJxkL0m60w05izUQ4NVtFNawTmElVUNYS5gOXSRnCjQkTmcMu0bI4yw3gkf.0EyfR9fE3McXK9zjwnMDZLC5MDsYazzaMA87sU4seMjd3G8oKfdi.r2pZ2rUzkoLSAJ11.q7IpHUvWsk8zcpxm1hLg9LcvfX0c.Sbcf.8mwY_32NVpIZT_0rzdp71FJUOZGabSOK4isjC409u7GOg; _ga=GA1.1.1232202746.1760710013; i18nextLng=en; x-anonuserid=621371fd-a877-4245-900c-1aa8db6039f2; x-challenge=2CHUrpA5J8%2FW2%2F1H8glEE3WKIXTKrbU7mMARWLT5DHzp5MS6nUk1aTHt7gqzv1vCxfnIdHTdeq4ZLYwcBj1DL%2FBptSSVT9OKi9DQDsN%2BKk0Ur3jg1uS%2BuPtwYSNZ%2B6CtuLCrDZqlDh%2FfFTzYr2sQ9nT3R72HfOyS%2FFXw0qvCgoROCtZCiGY%3D; x-signature=qPh93ojC8uCXOUvq7t0SzcwsyXKOE%2BRXH6dH26oL8lxwRIabYha6eniSt329QvpjBEeUqlekeStaek44mDpEYg%3D%3D; sso=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzZXNzaW9uX2lkIjoiOGU3MDFiNzctOTdkNC00ZjM0LWExOTctOWFmMDU1MzY3NDAwIn0.-a6x0InxbGzfTVfUlrdzxskxCnvMDI8lC90z4wHeGIk; sso-rw=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzZXNzaW9uX2lkIjoiOGU3MDFiNzctOTdkNC00ZjM0LWExOTctOWFmMDU1MzY3NDAwIn0.-a6x0InxbGzfTVfUlrdzxskxCnvMDI8lC90z4wHeGIk; stblid=b3331fc1-45d7-466b-83df-67427c0b2367; mp_ea93da913ddb66b6372b89d97b1029ac_mixpanel=%7B%22distinct_id%22%3A%2285980643-ffab-4984-a3de-59a608c47d7f%22%2C%22%24device_id%22%3A%2279ce237a-a0f3-4913-bf4b-519ac8a98263%22%2C%22%24initial_referrer%22%3A%22%24direct%22%2C%22%24initial_referring_domain%22%3A%22%24direct%22%2C%22__mps%22%3A%7B%7D%2C%22__mpso%22%3A%7B%7D%2C%22__mpus%22%3A%7B%7D%2C%22__mpa%22%3A%7B%7D%2C%22__mpu%22%3A%7B%7D%2C%22__mpr%22%3A%5B%5D%2C%22__mpap%22%3A%5B%5D%2C%22%24user_id%22%3A%2285980643-ffab-4984-a3de-59a608c47d7f%22%7D; _ga_8FEWB057YH=GS2.1.s1760710013$o1$g1$t1760710085$j60$l0$h0' \
|
||||
-H 'Connection: Upgrade' \
|
||||
-H 'Sec-WebSocket-Key: 3cx4uqFUq7dJfGvZsbsVEg==' \
|
||||
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36' \
|
||||
-H 'Sec-WebSocket-Version: 13' \
|
||||
-H 'Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits'
|
||||
Reference in new issue
Block a user