# Install cargo-build-deps
RUN cargo install --git https://github.com/romac/cargo-build-deps.git
WORKDIR /app/server
-RUN mkdir -p lemmy_db/src/ lemmy_utils/src/
+RUN mkdir -p lemmy_db/src/ \
+ lemmy_utils/src/ \
+ lemmy_api_structs/src/ \
+ lemmy_rate_limit/src/ \
+ lemmy
# Copy the cargo tomls
COPY server/Cargo.toml server/Cargo.lock ./
COPY server/lemmy_db/Cargo.toml ./lemmy_db/
COPY server/lemmy_utils/Cargo.toml ./lemmy_utils/
+COPY server/lemmy_api_structs/Cargo.toml ./lemmy_api_structs/
+COPY server/lemmy_rate_limit/Cargo.toml ./lemmy_rate_limit/
# Cache the deps
RUN cargo build-deps
COPY server/src ./src/
COPY server/lemmy_db/src ./lemmy_db/src/
COPY server/lemmy_utils/src/ ./lemmy_utils/src/
+COPY server/lemmy_api_structs/src/ ./lemmy_api_structs/src/
+COPY server/lemmy_rate_limit/src/ ./lemmy_rate_limit/src/
COPY server/migrations ./migrations/
# Build for debug
COPY server/Cargo.toml server/Cargo.lock ./
COPY server/lemmy_db ./lemmy_db
COPY server/lemmy_utils ./lemmy_utils
+COPY server/lemmy_api_structs ./lemmy_api_structs
+COPY server/lemmy_rate_limit ./lemmy_rate_limit
RUN mkdir -p ./src/bin \
&& echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs
RUN cargo build --release
"lemmy_utils",
"lemmy_db",
"lemmy_api_structs",
+ "lemmy_rate_limit",
]
[dependencies]
authors = ["Felix Ableitner <me@nutomic.com>"]
edition = "2018"
+[lib]
+name = "lemmy_api_structs"
+path = "src/lib.rs"
+
[dependencies]
lemmy_db = { path = "../lemmy_db" }
serde = { version = "1.0.105", features = ["derive"] }
authors = ["Felix Ableitner <me@nutomic.com>"]
edition = "2018"
+[lib]
+name = "lemmy_rate_limit"
+path = "src/lib.rs"
+
[dependencies]
lemmy_utils = { path = "../lemmy_utils" }
lemmy_api_structs = { path = "../lemmy_api_structs" }
#[macro_use]
pub extern crate strum_macros;
-pub extern crate tokio;
-pub extern crate futures;
pub extern crate actix_web;
+pub extern crate futures;
pub extern crate log;
+pub extern crate tokio;
use actix_web::dev::{Service, ServiceRequest, ServiceResponse, Transform};
use futures::future::{ok, Ready};
-use lemmy_utils::settings::{RateLimitConfig, Settings};
+use lemmy_utils::{
+ get_ip,
+ settings::{RateLimitConfig, Settings},
+ LemmyError,
+};
use rate_limiter::{RateLimitType, RateLimiter};
use std::{
future::Future,
task::{Context, Poll},
};
use tokio::sync::Mutex;
-use lemmy_utils::get_ip;
-use lemmy_utils::LemmyError;
pub mod rate_limiter;
-use lemmy_utils::IPAddr;
-use lemmy_utils::LemmyError;
use lemmy_api_structs::APIError;
+use lemmy_utils::{IPAddr, LemmyError};
use log::debug;
use std::{collections::HashMap, time::SystemTime};
use strum::IntoEnumIterator;
#[macro_use]
pub extern crate lazy_static;
+pub extern crate actix_web;
+pub extern crate anyhow;
pub extern crate comrak;
pub extern crate lettre;
pub extern crate lettre_email;
pub extern crate regex;
pub extern crate serde_json;
pub extern crate url;
-pub extern crate actix_web;
-pub extern crate anyhow;
pub mod settings;
use crate::settings::Settings;
+use actix_web::dev::ConnectionInfo;
use chrono::{DateTime, FixedOffset, Local, NaiveDateTime};
use itertools::Itertools;
use lettre::{
use regex::{Regex, RegexBuilder};
use std::io::{Error, ErrorKind};
use url::Url;
-use actix_web::dev::ConnectionInfo;
pub type ConnectionId = usize;
pub type PostId = i32;
}
impl<T> From<T> for LemmyError
- where
- T: Into<anyhow::Error>,
+where
+ T: Into<anyhow::Error>,
{
fn from(t: T) -> Self {
LemmyError { inner: t.into() }
.next()
.unwrap_or("127.0.0.1")
.to_string()
-}
\ No newline at end of file
+}