This commit is contained in:
40
backend/Cargo.lock
generated
40
backend/Cargo.lock
generated
@ -642,26 +642,6 @@ dependencies = [
|
||||
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gitache"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"actix-files 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"actix-web 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"awc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mime_guess 1.8.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pretty_env_logger 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"structopt 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time-cache 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "h2"
|
||||
version = "0.1.25"
|
||||
@ -1966,6 +1946,26 @@ dependencies = [
|
||||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "yagcdn"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"actix-files 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"actix-web 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"awc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mime_guess 1.8.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pretty_env_logger 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"structopt 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time-cache 0.1.0",
|
||||
]
|
||||
|
||||
[metadata]
|
||||
"checksum actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9f2c11af4b06dc935d8e1b1491dad56bfb32febc49096a91e773f8535c176453"
|
||||
"checksum actix-connect 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d161322a26e6b76d6598f48654afbdcfee644c900d4368e9962ec68abd0713b"
|
||||
|
@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "gitache"
|
||||
name = "yagcdn"
|
||||
version = "0.1.0"
|
||||
authors = ["Valentin Brandl <vbrandl@riseup.net>"]
|
||||
edition = "2018"
|
||||
|
@ -1,37 +0,0 @@
|
||||
# Gitache
|
||||
|
||||
Gitache is a web service that serves raw files from GitHub, GitLab and Bitbucket
|
||||
with the proper `Content-Type` headers. Requests to a branch will be redirected
|
||||
to the branches `HEAD`. Requests to a specific commit will also set long time
|
||||
cache headers, so the service can be put behind a CDN like Cloudflare.
|
||||
|
||||
The endpoints follow the pattern `/<service>/<user>/<repo>/<gitref>/<file>`
|
||||
where `<service>` is one of `github`, `gitlab` or `bitbucket`, `<gitref>` is the
|
||||
name of the branch or a commit hash.
|
||||
|
||||
## Building and Running
|
||||
|
||||
The code can be built natively using `cargo build --release` or as a Docker
|
||||
image using `docker build .`
|
||||
|
||||
The easiest way to run the service is by using `docker-compose up -d` and
|
||||
exposing port `8080`.
|
||||
|
||||
|
||||
## API Limits
|
||||
|
||||
To get the `HEAD` of a requested branch, Gitache sends a request to the
|
||||
requested service's API. To prevent running into rate limiting issues with the
|
||||
GitHub API, an OAuth2 App should be created and the client ID and secret can be
|
||||
set via the `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET` environment variables.
|
||||
|
||||
## Variables
|
||||
|
||||
| Environment Variable | CLI Flag | Description |
|
||||
| --- | --- | --- |
|
||||
| `GITHUB_CLIENT_SECRET` | `--gh-secret` | GitHub OAuth2 secret (optional) |
|
||||
| `GITHUB_CLIENT_ID` | `--gh-id` | GH OAuth2 Client ID (optional) |
|
||||
| `CF_ZONE_IDENT` | `--cf-zone` | Cloudflare Zone identifier |
|
||||
| `CF_AUTH_USER` | `--cf-auth-user` | CF API User (`X-Auth-Email`) |
|
||||
| `CF_AUTH_KEY` | `--cf-auth-key` | CF API Key (`X-Auth-Key`) |
|
||||
| `HOSTNAME` | `--hostname` | Hostname (default: `gitcdn.tk`) |
|
@ -6,7 +6,7 @@ const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
pub(crate) const REDIRECT_AGE: Duration = Duration::from_secs(5 * 60);
|
||||
pub(crate) const FAVICON: &[u8] = include_bytes!("../static/favicon32.png");
|
||||
lazy_static! {
|
||||
pub(crate) static ref USER_AGENT: String = format!("gitache/{}", VERSION);
|
||||
pub(crate) static ref USER_AGENT: String = format!("yagcdn/{}", VERSION);
|
||||
pub(crate) static ref OPT: Opt = Opt::from_args();
|
||||
pub(crate) static ref GITHUB_AUTH_QUERY: String = Github::auth_query().unwrap_or_default();
|
||||
pub(crate) static ref CF_ZONE_IDENT: String = OPT
|
||||
@ -27,8 +27,8 @@ lazy_static! {
|
||||
pub(crate) static ref HOSTNAME: String = OPT
|
||||
.hostname
|
||||
.clone()
|
||||
.or_else(|| load_env_var("GITACHE_HOSTNAME"))
|
||||
.unwrap_or_else(|| "gitcdn.tk".to_string());
|
||||
.or_else(|| load_env_var("YAGCDN_HOSTNAME"))
|
||||
.unwrap_or_else(|| "yagcdn.tk".to_string());
|
||||
}
|
||||
|
||||
pub(crate) fn load_env_var(key: &str) -> Option<String> {
|
||||
|
Reference in New Issue
Block a user