Skip to content

Commit

Permalink
fix: move to base32
Browse files Browse the repository at this point in the history
  • Loading branch information
lostb1t committed Nov 2, 2023
1 parent 077d47f commit 4f217de
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ multimap = "0.9.0"
rhai = { version = "1.15.1", features = ["serde"] }
serde_path_to_error = "0.1.14"
uncased = "0.9.9"
base64 = "0.21.5"
data-encoding = "2.4.0"
#format_serde_error = "0.3"

[dev-dependencies]
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ Remix your plex recommendations.

## Test server

There is a test server available, you can use it by base64 encoding your plex url and put it in front of replex.stream as a subdomain.
There is a test server available, you can use it by base32 encoding your plex url and put it in front of replex.stream as a subdomain.

Example:

http://56.29.34.34:32400 -> aHR0cDovLzU2LjI5LjM0LjM0OjMyNDAwIA==
your test url would be: https://aHR0cDovLzU2LjI5LjM0LjM0OjMyNDAwIA==.replex.stream
http://56.29.34.34:32400 -> NB2HI4B2F4XTKNROGI4S4MZUFYZTIORTGI2DAMA=
your test url would be: https://NB2HI4B2F4XTKNROGI4S4MZUFYZTIORTGI2DAMA=.replex.stream

Add the url to the "Custom server access URLs" in plex under network and disable remote access.
Continue with [Mixed Rows](#mixed-rows) to continue setting up.

Base64 online encoding tool: https://emn178.github.io/online-tools/base64_encode.html
Base32 online encoding tool: https://emn178.github.io/online-tools/base32_encode.html

## Installation

Expand Down
18 changes: 15 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,27 @@ impl Config {

pub fn dynamic(req: &salvo::Request) -> Figment {
// dbg!(&req);
use base64::{Engine as _, alphabet, engine::{self, general_purpose}};
// use base64::{Engine as _, alphabet, engine::{self, general_purpose}};
// use base32::{decode, CrockfordBase32};
// use crockford::decode;
let host = req.headers().get("HOST").unwrap().to_str().unwrap();
let mut config = Config::figment();
if host.contains("replex.stream") {
use data_encoding::BASE32;
let val: Vec<&str> = host.split(".replex.stream").collect();
let owned_val = val[0].to_ascii_uppercase().to_owned();
// dbg!(&val);
// let mut decoded_host: String = String::new();
let decoded_host = general_purpose::STANDARD
.decode(val[0]).unwrap();
// let decoded_host = general_purpose::STANDARD
// .decode(val[0]).unwrap();
// let decoded_host = decode(CrockfordBase32, &owned_val[..]);
// let decoded_host: String = crockford::decode(val[0].to_uppercase()).unwrap().to_string();
let mut output = vec![0; BASE32.decode_len(owned_val.len()).unwrap()];
let len = BASE32.decode_mut(owned_val.as_bytes(), &mut output).unwrap();
// dbg!(std::str::from_utf8(&output[0 .. len]).unwrap());
config = config.join(("host", std::str::from_utf8(&decoded_host).unwrap()));
// config = config.join(("host", decoded_host));

}
config
// Figment::new().merge(Env::prefixed("REPLEX_"))
Expand Down

0 comments on commit 4f217de

Please sign in to comment.