Skip to content

Commit 51b3211

Browse files
Update devcontainer.json and apply some patches
Switch to GenericWebAuth + redlib-org#509
1 parent 1b0f73c commit 51b3211

File tree

6 files changed

+17
-6
lines changed

6 files changed

+17
-6
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Rust",
3-
"image": "mcr.microsoft.com/devcontainers/rust:1.0.9-bookworm",
3+
"image": "mcr.microsoft.com/devcontainers/rust:latest",
44
"features": {
55
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
66
},

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ arc-swap = "1.7.1"
5151
serde_json_path = "0.7.1"
5252
async-recursion = "1.1.1"
5353
pulldown-cmark = { version = "0.12.0", features = ["simd", "html"], default-features = false }
54-
hyper-rustls = { version = "0.24.2", features = [ "http2" ] }
54+
hyper-tls = { version = "0.5.0" }
55+
openssl = { version = "0.10", features = ["vendored"] }
5556
tegen = "0.1.4"
5657
serde_urlencoded = "0.7.1"
5758
chrono = { version = "0.4.39", default-features = false, features = [ "std" ] }

Dockerfile.alpine

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# supported versions here: https://hub.docker.com/_/rust
2-
ARG ALPINE_VERSION=3.20
2+
ARG ALPINE_VERSION=3.22
33

44
########################
55
## builder image
66
########################
77
FROM rust:alpine${ALPINE_VERSION} AS builder
88

9-
RUN apk add --no-cache musl-dev
9+
RUN apk add --no-cache musl-dev perl make git
1010

1111
WORKDIR /redlib
1212

@@ -26,6 +26,9 @@ RUN echo "finished building redlib!"
2626
########################
2727
FROM alpine:${ALPINE_VERSION} AS release
2828

29+
# Install runtime dependencies for OpenSSL
30+
RUN apk add --no-cache ca-certificates
31+
2932
# Import redlib binary from builder
3033
COPY --from=builder /redlib/target/release/redlib /usr/local/bin/redlib
3134

Dockerfile.ubuntu

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ ARG UBUNTU_RELEASE_VERSION=noble
77
########################
88
FROM rust:${RUST_BUILDER_VERSION} AS builder
99

10+
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
11+
1012
WORKDIR /redlib
1113

1214
# download (most) dependencies in their own layer

src/client.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ use futures_lite::{future::Boxed, FutureExt};
55
use hyper::client::HttpConnector;
66
use hyper::header::HeaderValue;
77
use hyper::{body, body::Buf, header, Body, Client, Method, Request, Response, Uri};
8-
use hyper_rustls::{ConfigBuilderExt, HttpsConnector};
8+
//use hyper_rustls::{ConfigBuilderExt, HttpsConnector};
9+
use hyper_tls::HttpsConnector;
910
use libflate::gzip;
1011
use log::{error, trace, warn};
1112
use percent_encoding::{percent_encode, CONTROLS};
@@ -30,6 +31,8 @@ const REDDIT_SHORT_URL_BASE_HOST: &str = "redd.it";
3031
const ALTERNATIVE_REDDIT_URL_BASE: &str = "https://www.reddit.com";
3132
const ALTERNATIVE_REDDIT_URL_BASE_HOST: &str = "www.reddit.com";
3233

34+
pub static HTTPS_CONNECTOR: LazyLock<HttpsConnector<HttpConnector>> = LazyLock::new(HttpsConnector::new);
35+
/*
3336
pub static HTTPS_CONNECTOR: LazyLock<HttpsConnector<HttpConnector>> = LazyLock::new(|| {
3437
hyper_rustls::HttpsConnectorBuilder::new()
3538
.with_tls_config(
@@ -60,6 +63,7 @@ pub static HTTPS_CONNECTOR: LazyLock<HttpsConnector<HttpConnector>> = LazyLock::
6063
.enable_http2()
6164
.build()
6265
});
66+
*/
6367

6468
pub static CLIENT: LazyLock<Client<HttpsConnector<HttpConnector>>> = LazyLock::new(|| Client::builder().build::<_, Body>(HTTPS_CONNECTOR.clone()));
6569

src/oauth.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ impl Oauth {
7575
pub(crate) async fn new() -> Self {
7676
// Try MobileSpoofAuth first, then fall back to GenericWebAuth
7777
let mut failure_count = 0;
78-
let mut backend = OauthBackendImpl::MobileSpoof(MobileSpoofAuth::new());
78+
//let mut backend = OauthBackendImpl::MobileSpoof(MobileSpoofAuth::new());
79+
let mut backend = OauthBackendImpl::GenericWeb(GenericWebAuth::new()); // Use generic web auth
7980

8081
loop {
8182
let attempt = Self::new_with_timeout_with_backend(backend.clone()).await;

0 commit comments

Comments
 (0)