linux

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LINUX_DISTROS_UBUNTU string = "ubuntu"
	LINUX_DISTROS_DEBIAN        = "debian"
)
View Source
const (
	BENCHMARK_MAX_TIMEOUT    = 15 // 15 seconds, detect resource timeout
	BENCHMARK_MAX_TRIES      = 3  // times, maximum number of attempts
	BENCHMARK_DETECT_TIMEOUT = 3  // 3 seconds, for select fast mirror
)
View Source
const (
	UBUNTU_MIRROR_URLS   = "http://mirrors.ubuntu.com/mirrors.txt"
	UBUNTU_BENCHMAKR_URL = "dists/jammy/main/binary-amd64/Release"
)

Ubuntu

View Source
const (
	DEBIAN_BENCHMAKR_URL = "dists/bullseye/main/binary-amd64/Release"
)

DEBIAN

Variables

View Source
var DEBIAN_DEFAULT_CACHE_RULES = []Rule{
	{Pattern: regexp.MustCompile(`deb$`), CacheControl: `max-age=100000`, Rewrite: true},
	{Pattern: regexp.MustCompile(`udeb$`), CacheControl: `max-age=100000`, Rewrite: true},
	{Pattern: regexp.MustCompile(`DiffIndex$`), CacheControl: `max-age=3600`, Rewrite: true},
	{Pattern: regexp.MustCompile(`PackagesIndex$`), CacheControl: `max-age=3600`, Rewrite: true},
	{Pattern: regexp.MustCompile(`Packages\.(bz2|gz|lzma)$`), CacheControl: `max-age=3600`, Rewrite: true},
	{Pattern: regexp.MustCompile(`SourcesIndex$`), CacheControl: `max-age=3600`, Rewrite: true},
	{Pattern: regexp.MustCompile(`Sources\.(bz2|gz|lzma)$`), CacheControl: `max-age=3600`, Rewrite: true},
	{Pattern: regexp.MustCompile(`Release(\.gpg)?$`), CacheControl: `max-age=3600`, Rewrite: true},
	{Pattern: regexp.MustCompile(`Translation-(en|fr)\.(gz|bz2|bzip2|lzma)$`), CacheControl: `max-age=3600`, Rewrite: true},

	{Pattern: regexp.MustCompile(`/by-hash/`), CacheControl: `max-age=3600`, Rewrite: true},
}
View Source
var DEBIAN_HOST_PATTERN = regexp.MustCompile(
	`https?://(deb|security|snapshot).debian.org/debian/(.+)$`,
)
View Source
var DEBIAN_MIRROR_URLS = []string{
	"http://ftp.cn.debian.org/debian/",
	"http://mirror.bjtu.edu.cn/debian/",
	"http://mirror.lzu.edu.cn/debian/",
	"http://mirror.nju.edu.cn/debian/",
	"http://mirrors.163.com/debian/",
	"http://mirrors.bfsu.edu.cn/debian/",
	"http://mirrors.hit.edu.cn/debian/",
	"http://mirrors.huaweicloud.com/debian/",
	"http://mirrors.neusoft.edu.cn/debian/",
	"http://mirrors.tuna.tsinghua.edu.cn/debian/",
	"http://mirrors.ustc.edu.cn/debian/",
}
View Source
var UBUNTU_DEFAULT_CACHE_RULES = []Rule{
	{Pattern: regexp.MustCompile(`deb$`), CacheControl: `max-age=100000`, Rewrite: true},
	{Pattern: regexp.MustCompile(`udeb$`), CacheControl: `max-age=100000`, Rewrite: true},
	{Pattern: regexp.MustCompile(`DiffIndex$`), CacheControl: `max-age=3600`, Rewrite: true},
	{Pattern: regexp.MustCompile(`PackagesIndex$`), CacheControl: `max-age=3600`, Rewrite: true},
	{Pattern: regexp.MustCompile(`Packages\.(bz2|gz|lzma)$`), CacheControl: `max-age=3600`, Rewrite: true},
	{Pattern: regexp.MustCompile(`SourcesIndex$`), CacheControl: `max-age=3600`, Rewrite: true},
	{Pattern: regexp.MustCompile(`Sources\.(bz2|gz|lzma)$`), CacheControl: `max-age=3600`, Rewrite: true},
	{Pattern: regexp.MustCompile(`Release(\.gpg)?$`), CacheControl: `max-age=3600`, Rewrite: true},
	{Pattern: regexp.MustCompile(`Translation-(en|fr)\.(gz|bz2|bzip2|lzma)$`), CacheControl: `max-age=3600`, Rewrite: true},

	{Pattern: regexp.MustCompile(`/by-hash/`), CacheControl: `max-age=3600`, Rewrite: true},
}
View Source
var UBUNTU_HOST_PATTERN = regexp.MustCompile(
	`https?://(security|archive).ubuntu.com/ubuntu/(.+)$`,
)

Functions

func Rewrite

func Rewrite(r *http.Request, rewriter *URLRewriter)

Types

type Mirrors

type Mirrors struct {
	URLs []string
}

type Rule

type Rule struct {
	Pattern      *regexp.Regexp
	CacheControl string
	Rewrite      bool
}

func MatchingRule

func MatchingRule(subject string, rules []Rule) (*Rule, bool)

func (*Rule) String

func (r *Rule) String() string

type URLRewriter

type URLRewriter struct {
	// contains filtered or unexported fields
}

func NewRewriter

func NewRewriter(mirrorUrl string, osType string) *URLRewriter

Jump to

Keyboard shortcuts

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