linux

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	LINUX_ALL_DISTROS    string = "all"
	LINUX_DISTROS_UBUNTU        = "ubuntu"
	LINUX_DISTROS_DEBIAN        = "debian"
)
View Source
const (
	TYPE_LINUX_ALL_DISTROS    int = 0
	TYPE_LINUX_DISTROS_UBUNTU     = 1
	TYPE_LINUX_DISTROS_DEBIAN     = 2
)
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_GEO_MIRROR_API = "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 BUILDIN_OFFICAL_DEBIAN_MIRRORS = []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 BUILDIN_OFFICAL_UBUNTU_MIRRORS = []string{
	"http://mirrors.aliyun.com/ubuntu/",
	"http://mirrors.huaweicloud.com/repository/ubuntu/",
	"http://mirror.dlut.edu.cn/ubuntu/",
	"http://mirrors.dgut.edu.cn/ubuntu/",
	"http://mirrors.njupt.edu.cn/ubuntu/",
	"https://mirrors.hit.edu.cn/ubuntu/",
	"http://mirrors.yun-idc.com/ubuntu/",
	"http://ftp.sjtu.edu.cn/ubuntu/",
	"https://mirror.nju.edu.cn/ubuntu/",
	"https://mirrors.bupt.edu.cn/ubuntu/",
	"http://mirrors.skyshe.cn/ubuntu/",
	"https://repo.huaweicloud.com/ubuntu/",
	"http://mirror.lzu.edu.cn/ubuntu/",
	"http://mirrors.cn99.com/ubuntu/",
	"http://mirrors.cqu.edu.cn/ubuntu/",
	"https://mirrors.cloud.tencent.com/ubuntu/",
	"https://mirrors.ustc.edu.cn/ubuntu/",
	"https://mirror.bjtu.edu.cn/ubuntu/",
	"http://mirrors.sohu.com/ubuntu/",
	"http://archive.ubuntu.com/ubuntu/",
}
View Source
var DEBIAN_DEFAULT_CACHE_RULES = []Rule{
	{Pattern: regexp.MustCompile(`deb$`), CacheControl: `max-age=100000`, Rewrite: true, OS: TYPE_LINUX_DISTROS_DEBIAN},
	{Pattern: regexp.MustCompile(`udeb$`), CacheControl: `max-age=100000`, Rewrite: true, OS: TYPE_LINUX_DISTROS_DEBIAN},
	{Pattern: regexp.MustCompile(`DiffIndex$`), CacheControl: `max-age=3600`, Rewrite: true, OS: TYPE_LINUX_DISTROS_DEBIAN},
	{Pattern: regexp.MustCompile(`PackagesIndex$`), CacheControl: `max-age=3600`, Rewrite: true, OS: TYPE_LINUX_DISTROS_DEBIAN},
	{Pattern: regexp.MustCompile(`Packages\.(bz2|gz|lzma)$`), CacheControl: `max-age=3600`, Rewrite: true, OS: TYPE_LINUX_DISTROS_DEBIAN},
	{Pattern: regexp.MustCompile(`SourcesIndex$`), CacheControl: `max-age=3600`, Rewrite: true, OS: TYPE_LINUX_DISTROS_DEBIAN},
	{Pattern: regexp.MustCompile(`Sources\.(bz2|gz|lzma)$`), CacheControl: `max-age=3600`, Rewrite: true, OS: TYPE_LINUX_DISTROS_DEBIAN},
	{Pattern: regexp.MustCompile(`Release(\.gpg)?$`), CacheControl: `max-age=3600`, Rewrite: true, OS: TYPE_LINUX_DISTROS_DEBIAN},
	{Pattern: regexp.MustCompile(`Translation-(en|fr)\.(gz|bz2|bzip2|lzma)$`), CacheControl: `max-age=3600`, Rewrite: true, OS: TYPE_LINUX_DISTROS_DEBIAN},

	{Pattern: regexp.MustCompile(`/by-hash/`), CacheControl: `max-age=3600`, Rewrite: true, OS: TYPE_LINUX_DISTROS_DEBIAN},
}
View Source
var DEBIAN_HOST_PATTERN = regexp.MustCompile(
	`https?://(deb|security|snapshot).debian.org/debian/(.+)$`,
)
View Source
var UBUNTU_DEFAULT_CACHE_RULES = []Rule{
	{Pattern: regexp.MustCompile(`deb$`), CacheControl: `max-age=100000`, Rewrite: true, OS: TYPE_LINUX_DISTROS_UBUNTU},
	{Pattern: regexp.MustCompile(`udeb$`), CacheControl: `max-age=100000`, Rewrite: true, OS: TYPE_LINUX_DISTROS_UBUNTU},
	{Pattern: regexp.MustCompile(`DiffIndex$`), CacheControl: `max-age=3600`, Rewrite: true, OS: TYPE_LINUX_DISTROS_UBUNTU},
	{Pattern: regexp.MustCompile(`PackagesIndex$`), CacheControl: `max-age=3600`, Rewrite: true, OS: TYPE_LINUX_DISTROS_UBUNTU},
	{Pattern: regexp.MustCompile(`Packages\.(bz2|gz|lzma)$`), CacheControl: `max-age=3600`, Rewrite: true, OS: TYPE_LINUX_DISTROS_UBUNTU},
	{Pattern: regexp.MustCompile(`SourcesIndex$`), CacheControl: `max-age=3600`, Rewrite: true, OS: TYPE_LINUX_DISTROS_UBUNTU},
	{Pattern: regexp.MustCompile(`Sources\.(bz2|gz|lzma)$`), CacheControl: `max-age=3600`, Rewrite: true, OS: TYPE_LINUX_DISTROS_UBUNTU},
	{Pattern: regexp.MustCompile(`Release(\.gpg)?$`), CacheControl: `max-age=3600`, Rewrite: true, OS: TYPE_LINUX_DISTROS_UBUNTU},
	{Pattern: regexp.MustCompile(`Translation-(en|fr)\.(gz|bz2|bzip2|lzma)$`), CacheControl: `max-age=3600`, Rewrite: true, OS: TYPE_LINUX_DISTROS_UBUNTU},

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

Functions

func RewriteRequestByMode added in v0.1.0

func RewriteRequestByMode(r *http.Request, rewriters *URLRewriters, mode int)

Types

type Rule

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

func GetRewriteRulesByMode added in v0.1.0

func GetRewriteRulesByMode(mode int) (rules []Rule)

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
}

type URLRewriters added in v0.1.0

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

func CreateNewRewriters added in v0.1.0

func CreateNewRewriters(mode int) *URLRewriters

Jump to

Keyboard shortcuts

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