viadown

command module
v0.0.0-...-885df39 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2022 License: MIT Imports: 27 Imported by: 0

README

Build Status

viadown

Download mirroring tool

Suppose you are running the same Linux distribution on a number of computers. Every time an update is run, each of these machines will try and download packages from distribution mirrors. To save bandwidth and time, you could setup a local mirror, but why download all of packages instead of just the few that are needed? You could setup a caching proxy, but what about those package managers that do not play well with proxies?

viadown is a proxying/mirroring tool that downloads data to its local cache while serving the same data to whoever requested it. Unline a regular HTTP proxy, viadown, does not implement the actual PROXY protocol. Instead it provides a method of on-demand mirroring.

Principle of operation is illustrated below:

  1. uncached response
         (request)   +---------+  (forwarded)
        -----------> |         | ------------->
 client              | viadown |                upstream
        <----------- |         | <-------------
         (stream     +---------+   (reply)
          data)             |
                            |
                            | (store to local cache)
                            v
                     +---------+
                     | cache   |
                     +---------+
  1. cached response
         (request)   +---------+
        -----------> |         |
 client              | viadown | .............. upstream
        <----------- |         |  (no traffic)
         (stream     +---------+
          data)        ^
                       |
                       | (stream from local cache)
                       |
                     +---------+
                     | cache   |
                     +---------+

Building

go get -v github.com/mjibson/esc
go get -v github.com/bboozzoo/viadown
go generate github.com/bboozzoo/viadown/...
go build github.com/bboozzoo/viadown

If you wish to deploy viadown to a NAS or a similar always-on device but running a non-x86 CPU, you will need to cross compile. For instance, to build viadown for BeagleBone run:

GOARCH=arm GOARM=7 go build -v

Using make to build viadown will also embed current version information into the binary.

Configuration

Configuration is passed through command line arguments. See -help for details.

Usage of viadown:
  -cache-root string
        Cache directory path (default "./tmp")
  -client-timeout duration
        Forward request timeout (default 15s)
  -debug
        Enable debug logging
  -listen string
        Listen address (default ":8080")
  -mirrors string
        Mirror list file
  -syslog
        Enable logging to syslog
  -version
        Show version

Mirror list

Mirror list is a plain text file with a mirror address in every line. Empty lines, or lines starting with # are skipped.

Example

Assume that I have an ArchLinux installation and viadown is deployed to a NAS, reachable at address 192.168.1.10, port 9999.

Add the following entry to /etc/pacman.d/mirrorlist

# NAS
Server = http://192.168.1.10:9999/$repo/os/$arch
...
# original entries
Server = http://mirror.js-webcoding.de/pub/archlinux/$repo/os/$arch
Server = http://mirror.de.leaseweb.net/archlinux/$repo/os/$arch
Server = http://archlinux.my-universe.com/$repo/os/$arch

Then your mirrorlist file for viadown should look like this:

http://mirror.de.leaseweb.net/archlinux/
http://mirror.js-webcoding.de/pub/archlinux/
http://archlinux.my-universe.com/

TODO

  • Range requests support
  • minimal usable dashboard, http://localhost:9999/_viadown
  • expvar for cache/hit miss, seen clients etc?
  • make sure to allow only GET requests
  • old file cleanup, github.com/robfig/cron maybe?
  • graceful shutdown on signal (SIGINT/SIGTERM)

Documentation

Overview

The MIT License (MIT)

Copyright (c) 2016 Maciek Borzecki <maciek.borzecki@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

The MIT License (MIT)

Copyright (c) 2019 Maciek Borzecki <maciek.borzecki@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

The MIT License (MIT)

Copyright (c) 2016 Maciek Borzecki <maciek.borzecki@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

The MIT License (MIT)

Copyright (c) 2016 Maciek Borzecki <maciek.borzecki@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

The MIT License (MIT)

Copyright (c) 2016 Maciek Borzecki <maciek.borzecki@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

The MIT License (MIT)

Copyright (c) 2016 Maciek Borzecki <maciek.borzecki@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL