Skip to content

Commit

Permalink
chore: Optimized for Debian acceleration
Browse files Browse the repository at this point in the history
  • Loading branch information
soulteary committed Nov 20, 2022
1 parent 0f6c69f commit 6f2a84b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions internal/define/debian.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ const (
DEBIAN_BENCHMAKR_URL = "dists/bullseye/main/binary-amd64/Release"
)

var DEBIAN_HOST_PATTERN = regexp.MustCompile(
`https?://(deb|security|snapshot).debian.org/debian/(.+)$`,
)
var DEBIAN_HOST_PATTERN = regexp.MustCompile(`/debian/(.+)$`)

// https://www.debian.org/mirror/list 2022.11.19
// Sites that contain protocol headers, restrict access to resources using that protocol
Expand Down Expand Up @@ -37,6 +35,7 @@ var BUILDIN_DEBIAN_MIRRORS = GenerateBuildInList(DEBIAN_OFFICAL_MIRRORS, DEBIAN_
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(`InRelease$`), CacheControl: `max-age=3600`, 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},
Expand Down
4 changes: 2 additions & 2 deletions internal/mirrors/mirrors.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ func GetGeoMirrorUrlsByMode(mode int) (mirrors []string) {

func GetFullMirrorURL(mirror Define.UrlWithAlias) string {
if mirror.Http {
if strings.HasSuffix(mirror.URL, "http://") {
if strings.HasPrefix(mirror.URL, "http://") {
return mirror.URL
}
return "http://" + mirror.URL
}
if mirror.Https {
if strings.HasSuffix(mirror.URL, "https://") {
if strings.HasPrefix(mirror.URL, "https://") {
return mirror.URL
}
return "https://" + mirror.URL
Expand Down

0 comments on commit 6f2a84b

Please sign in to comment.