mirror of https://github.com/PiyushXCoder/lupt.git
dotenv
This commit is contained in:
parent
e8396d0634
commit
f5e56c5c0c
|
|
@ -1 +1,2 @@
|
||||||
/target
|
/target
|
||||||
|
/.env
|
||||||
|
|
@ -715,6 +715,12 @@ version = "1.0.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0"
|
checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dotenv"
|
||||||
|
version = "0.15.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dtoa"
|
name = "dtoa"
|
||||||
version = "0.4.8"
|
version = "0.4.8"
|
||||||
|
|
@ -1204,8 +1210,10 @@ dependencies = [
|
||||||
"actix-web-actors",
|
"actix-web-actors",
|
||||||
"base64",
|
"base64",
|
||||||
"clap",
|
"clap",
|
||||||
|
"dotenv",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"futures",
|
"futures",
|
||||||
|
"lazy_static",
|
||||||
"openssl",
|
"openssl",
|
||||||
"rand 0.8.3",
|
"rand 0.8.3",
|
||||||
"serde",
|
"serde",
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,14 @@ actix-ratelimit = "0.3.1"
|
||||||
env_logger = "0.8.3"
|
env_logger = "0.8.3"
|
||||||
openssl = "0.10.28"
|
openssl = "0.10.28"
|
||||||
|
|
||||||
|
dotenv = "0.15.0"
|
||||||
clap = "2.33.3"
|
clap = "2.33.3"
|
||||||
|
lazy_static = "1.4.0"
|
||||||
|
|
||||||
serde = "1.0.123"
|
serde = "1.0.123"
|
||||||
serde_json = "1.0.62"
|
serde_json = "1.0.62"
|
||||||
rand = "0.8.3"
|
rand = "0.8.3"
|
||||||
futures = "0.3.12"
|
futures = "0.3.12"
|
||||||
|
|
||||||
sha1 = "0.6.0"
|
sha1 = "0.6.0"
|
||||||
base64 = "0.13.0"
|
base64 = "0.13.0"
|
||||||
|
|
|
||||||
13
src/main.rs
13
src/main.rs
|
|
@ -8,6 +8,10 @@
|
||||||
//! |--> ws_sansad3 <---- /
|
//! |--> ws_sansad3 <---- /
|
||||||
//! |--> ws_sansad4 <----/
|
//! |--> ws_sansad4 <----/
|
||||||
//!
|
//!
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
extern crate lazy_static;
|
||||||
|
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
App, Error, HttpRequest, HttpResponse, HttpServer, middleware::Logger, web,
|
App, Error, HttpRequest, HttpResponse, HttpServer, middleware::Logger, web,
|
||||||
client::{Client, Connector}
|
client::{Client, Connector}
|
||||||
|
|
@ -24,8 +28,15 @@ mod broker_messages;
|
||||||
mod ws_sansad;
|
mod ws_sansad;
|
||||||
mod chat_pinnd;
|
mod chat_pinnd;
|
||||||
mod validator;
|
mod validator;
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
pub static ref SALT: String = std::env::var("SALT").unwrap();
|
||||||
|
pub static ref TENOR_API_KEY: String = std::env::var("TENOR_API_KEY").unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[actix_web::main]
|
#[actix_web::main]
|
||||||
async fn main() -> std::io::Result<()> {
|
async fn main() -> std::io::Result<()> {
|
||||||
|
dotenv::dotenv().ok();
|
||||||
std::env::set_var("RUST_LOG", "actix_web=info");
|
std::env::set_var("RUST_LOG", "actix_web=info");
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
let store = MemoryStore::new();
|
let store = MemoryStore::new();
|
||||||
|
|
@ -63,7 +74,7 @@ async fn gif(req: HttpRequest) -> Result<HttpResponse, Error> {
|
||||||
.finish();
|
.finish();
|
||||||
|
|
||||||
|
|
||||||
let url = format!("https://g.tenor.com/v1/search?q={}&key=LIVDSRZULELA&limit=20&media_filter=tinygif", name);
|
let url = format!("https://g.tenor.com/v1/search?q={}&key={}&limit=20&media_filter=tinygif", name, TENOR_API_KEY.to_owned());
|
||||||
let response = client.get(url)
|
let response = client.get(url)
|
||||||
.header("User-Agent", "actix-web/3.0")
|
.header("User-Agent", "actix-web/3.0")
|
||||||
.send()
|
.send()
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ impl WsSansad {
|
||||||
// kunjika to hash and base64
|
// kunjika to hash and base64
|
||||||
let mut m = sha1::Sha1::new();
|
let mut m = sha1::Sha1::new();
|
||||||
m.update(format!("{}{}",kunjika,
|
m.update(format!("{}{}",kunjika,
|
||||||
std::env::var("SALT").unwrap_or("".to_owned())).as_bytes());
|
crate::SALT.to_owned()).as_bytes());
|
||||||
let kunjika = base64::encode(m.digest().bytes())[..8].to_owned();
|
let kunjika = base64::encode(m.digest().bytes())[..8].to_owned();
|
||||||
|
|
||||||
let name = match val.get("name") {
|
let name = match val.get("name") {
|
||||||
|
|
@ -139,7 +139,7 @@ impl WsSansad {
|
||||||
// kunjika to hash and base64
|
// kunjika to hash and base64
|
||||||
let mut m = sha1::Sha1::new();
|
let mut m = sha1::Sha1::new();
|
||||||
m.update(format!("{}{}",kunjika,
|
m.update(format!("{}{}",kunjika,
|
||||||
std::env::var("SALT").unwrap_or("".to_owned())).as_bytes());
|
crate::SALT.to_owned()).as_bytes());
|
||||||
let kunjika = base64::encode(m.digest().bytes())[..8].to_owned();
|
let kunjika = base64::encode(m.digest().bytes())[..8].to_owned();
|
||||||
|
|
||||||
let name = match val.get("name") {
|
let name = match val.get("name") {
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@
|
||||||
<div>
|
<div>
|
||||||
<label>Your kunjika(your id)</label>
|
<label>Your kunjika(your id)</label>
|
||||||
<input name="kunjika" type="text" placeholder="Your kunjika (Don't share it)">
|
<input name="kunjika" type="text" placeholder="Your kunjika (Don't share it)">
|
||||||
<small class="text-grey">Pick a random kunjika(id)<br><b>Don't share it</b></small>
|
<small class="text-grey">Pick a random kunjika(id). <b>Don't share it</b></small>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label>Your name</label>
|
<label>Your name</label>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue