# Rust mirror (pkg.shecan.ir)

> Mirror of the crates.io sparse index and crate files for Cargo, and of static.rust-lang.org for rustup toolchains.

- Upstream: crates.io, static.rust-lang.org
- Mirror URLs: <https://mirror-cargo.pkg.shecan.ir/index/>, <https://mirror-cargo.pkg.shecan.ir/rustup/>
- Clients: cargo, rustup
- Service status: <https://pkg.shecan.ir/status.json> (key `cargo`; up/down, refreshed every minute)
- Guide (Persian, HTML): <https://pkg.shecan.ir/mirrors/cargo/>
- JSON: <https://pkg.shecan.ir/api/v1/mirrors/cargo.json>
- Integrity comparison with the official source (audit.shecan.ir, also run by Shecan, open source; group `cargo`, mirror `shecan`): <https://audit.shecan.ir/#cargo>

## Limitations

- Read-only: cargo publish, yank, owner and search still use crates.io.
- Cargo.lock files keep the crates.io source; source replacement makes Cargo download them from the mirror.

## Setup

Every block below is the exact text of the Persian guide. Unless marked otherwise it is run against the live mirror in a disposable container on every catalog change; "checked by hand" blocks cannot run in a container. Change a machine only with its owner's permission: back up existing configuration first, merge into existing files instead of overwriting them, and keep the "Undo" step at hand.

### cargo: persistent (user- or system-wide configuration)

Configuration file: `%USERPROFILE%\.cargo\config.toml` or `~/.cargo/config.toml`

```toml
[source.crates-io]
replace-with = "shecan"

[source.shecan]
registry = "sparse+https://mirror-cargo.pkg.shecan.ir/index/"
```

Undo / restore the default

```sh
mv ~/.cargo/config.toml ~/.cargo/config.toml.shecan-off
```

### cargo: temporary (one command or the current shell; nothing saved)

Run (linux, macos)

```sh
cargo --config 'source.crates-io.replace-with="shecan"' --config 'source.shecan.registry="sparse+https://mirror-cargo.pkg.shecan.ir/index/"' fetch
```

### rustup: persistent (user- or system-wide configuration)

Run (linux, macos)

```sh
export RUSTUP_DIST_SERVER=https://mirror-cargo.pkg.shecan.ir/rustup
export RUSTUP_UPDATE_ROOT=https://mirror-cargo.pkg.shecan.ir/rustup/rustup
curl --proto '=https' --tlsv1.2 -sSf https://mirror-cargo.pkg.shecan.ir/rustup/rustup/rustup-init.sh | sh -s -- -y --profile minimal
```

### rustup: temporary (one command or the current shell; nothing saved)

Run (linux, macos)

```sh
export RUSTUP_DIST_SERVER=https://mirror-cargo.pkg.shecan.ir/rustup
export RUSTUP_UPDATE_ROOT=https://mirror-cargo.pkg.shecan.ir/rustup/rustup
rustup toolchain install 1.80.0 --profile minimal
```
