Debian Codegraph @

README.md

raw
1 [![Build Status](https://travis-ci.org/etix/mirrorbits.svg?branch=master)](https://travis-ci.org/etix/mirrorbits)
2 [![Go Report Card](https://goreportcard.com/badge/github.com/etix/mirrorbits)](https://goreportcard.com/report/github.com/etix/mirrorbits)
3
4 Mirrorbits
5 ===========
6
7 Mirrorbits is a geographical download redirector written in [Go](https://golang.org) for distributing files efficiently across a set of mirrors. It offers a simple and economic way to create a Content Delivery Network layer using a pure software stack. It is primarily designed for the distribution of large-scale Open-Source projects with a lot of traffic.
8
9 ![mirrorbits_screenshot](https://cloud.githubusercontent.com/assets/38853/3636687/ab6bba38-0fd8-11e4-9d69-01543ed2531a.png)
10
11 ## Main Features
12
13 * Blazing fast, can reach 8K QPS on a single laptop
14 * Easy to deploy and maintain, everything is packed in a single binary
15 * Automatic synchronization with the mirrors over **rsync** or **FTP**
16 * Response can be either JSON or HTTP redirect
17 * Support partial repositories
18 * Complete checksum / size control
19 * Realtime monitoring and reports
20 * Disable misbehaving mirrors without human intervention
21 * Realtime decision making based on location, AS number and defined rules
22 * Smart load-balancing over multiple mirrors in the same area to avoid hotspots
23 * Ability to adjust the weight of each mirror
24 * Limit access to a country, region or ASN for any mirror
25 * Clustering (multiple mirrorbits instances)
26 * High-availability using redis-sentinel
27 * Automatically fix timezone offsets for broken mirrors
28 * Realtime statistics per file / mirror / date
29 * Realtime reconfiguration
30 * Seamless binary upgrade (aka zero downtime upgrade)
31 * [Mirmon](http://www.staff.science.uu.nl/~penni101/mirmon/) support
32 * Full **IPv6** support
33 * If-Modified-Since (RFC-7232) support
34 * more...
35
36 ## Is it production ready?
37
38 **Yes!** Mirrorbits has served **billions** of files already and is known to be running in production at:
39 * [CarbonROM](https://carbonrom.org/)
40 * [Chaos Computer Club](https://media.ccc.de/) to distribute media
41 * [Jellyfin](https://jellyfin.org/) since [April 2021](https://jellyfin.org/posts/mirrorbits-cdn/)
42 * [Jenkins](https://www.jenkins.io/) to distribute Jenkins releases since [February 2020](https://github.com/jenkins-infra/docker-mirrorbits)
43 * [Kali Linux](https://www.kali.org/) to distribute packages and images since [December 2023](https://www.kali.org/blog/kali-linux-2023-4-release/#enters-mirrorbits)
44 * [Kodi](http://kodi.tv/) (previously XBMC) since [July 2015](https://forum.kodi.tv/showthread.php?tid=233824)
45 * [LineageOS](http://lineageos.org/) (previously CyanogenMod) since January 2017
46 * [MariaDB](https://mariadb.org/) to distribute packages (deb/rpm) for Linux distributions since [December 2021](https://mariadb.org/mirrorbits/)
47 * [OSMC](https://osmc.tv)
48 * [VideoLAN](http://www.videolan.org/) to distribute [VLC media player](http://www.videolan.org/vlc/) since [April 2014](https://blog.l0cal.com/2014/07/11/mirrorbits-is-now-on-github/)
49 * [Endless OS](https://endlessos.org/os)
50 * [MSYS2](https://www.msys2.org/) to distribute packages since [June 2021](https://github.com/msys2/msys2-main-server/commit/6a212b9ac76913f96)
51
52 Yet some things might change before the 1.0 release. If you intend to deploy Mirrorbits in a production system it is advised to notify the author first so we can help you to make any transition as seamless as possible!
53
54 _Previous projects which have used Mirrorbits:_
55 * [Parrot OS](https://www.parrotsec.org)
56 * [Popcorn Time](https://popcorntime.io)
57 * [SuperRepo](https://superrepo.org)
58
59 # Quick start
60
61 ## Prerequisites
62
63 * Go 1.18 or later
64 * Protobuf (protoc)
65 * Redis 3.2 or later (with [persistence](https://redis.io/topics/persistence) enabled)
66 * GeoIP2 databases from [Maxmind](https://dev.maxmind.com/geoip/geoip2/geolite2/) (preferably updated regularly)
67
68 :warning: **GeoIP-legacy is not supported anymore, please use the new GeoIP2 mmdb databases!**
69
70 **Optional:**
71
72 * redis-sentinel (for high-availability support)
73
74 ## Upgrading
75
76 Before upgrading to the latest version, please check [this guide](https://github.com/etix/mirrorbits/wiki/Upgrade-Guide).
77
78 ## Installation
79
80 You can either get a [prebuilt version](https://github.com/etix/mirrorbits/releases) or choose to build it yourself.
81
82 ### Docker
83
84 A docker "quick start" can be found [on the wiki](https://github.com/etix/mirrorbits/wiki/Running-within-Docker).
85
86 ### Manual build
87
88 ```
89 $ git clone https://github.com/etix/mirrorbits.git
90 $ cd mirrorbits
91 $ sudo make install
92 ```
93
94 The resulting executable should now live in your */usr/local/bin* directory. You can also specify a `PREFIX` or `DESTDIR` if necessary:
95 ```
96 sudo make install PREFIX=/usr
97 ```
98
99 ## Configuration
100
101 A sample configuration file can be found [here](mirrorbits.conf).
102
103 ## Running
104
105 Mirrorbits is a self-contained application and can act, at the same time, as the server and the cli.
106
107 To run the server:
108 ```
109 mirrorbits daemon
110 ```
111 Additional options can be found with ```mirrorbits -help```.
112
113 To run the cli:
114 ```
115 mirrorbits help
116 ```
117
118 Add a mirror:
119 ```
120 mirrorbits add -ftp="ftp://ftp.mirrors.example/myproject/" -http="http://ftp.mirrors.example/myproject/" mirrors.example
121 ```
122
123 Enable the mirror:
124 ```
125 mirrorbits enable mirrors.example
126 ```
127
128 ### Realtime file availability
129
130 By appending `?mirrorlist` to any file served by mirrorbits, you'll be able to get some useful realtime informations about the given file. You can see a [live example here](https://get.videolan.org/vlc/2.2.4/win32/vlc-2.2.4-win32.exe?mirrorlist).
131
132 ### Realtime mirrors statistics
133
134 Mirror statistics are available by querying mirrorbits with the `?mirrorstats` argument. You can see a [live example here](https://get.videolan.org/?mirrorstats).
135
136 ## Clustering / High availability
137
138 Multiple instances of mirrorbits can be started simultaneously on different servers, discovery of other nodes should be automatic as long as all the instances are connected to the same redis server. In addition to the clustering it is advised to use redis-sentinel to monitor the database and gracefully handle failover.
139
140 ## Upgrading
141
142 Mirrorbits has a mode called *seamless binary upgrade* to upgrade the server executable at runtime without service disruption. Once the binary has been replaced on the filesystem just issue the following command in the cli:
143 ```
144 mirrorbits upgrade
145 ```
146
147 ## Considerations
148
149 * When configured in redirect mode, Mirrorbits can easily serve client requests directly but it is usually recommended to set it behind a reverse proxy like nginx. In this case take care to pass the IP address of the client within a X-Forwarded-For header:
150 ```
151 proxy_set_header X-Forwarded-For $remote_addr;
152 ```
153 * It is advised to never cache requests intended for Mirrorbits since each request is supposed to be unique, caching the result might have unexpected consequences.
154
155 # We're social!
156
157 The best place to discuss about mirrorbits is to join the [#VideoLAN IRC channel on Libera.chat](https://www.videolan.org/webirc/).
158 For the latest news, you can follow [@mirrorbits](http://twitter.com/mirrorbits) on Twitter.
159
160 # License MIT
161
162 > Permission is hereby granted, free of charge, to any person obtaining a copy
163 > of this software and associated documentation files (the "Software"), to deal
164 > in the Software without restriction, including without limitation the rights
165 > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
166 > copies of the Software, and to permit persons to whom the Software is
167 > furnished to do so, subject to the following conditions:
168 >
169 > The above copyright notice and this permission notice shall be included in
170 > all copies or substantial portions of the Software.
171 >
172 > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
173 > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
174 > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
175 > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
176 > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
177 > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
178 > THE SOFTWARE.