Skip to content

debian and debian-security folders are not handled #29

@athoune

Description

@athoune

Debian uses two folders : /debian and /debian-security

Here is an ugly patch to handle that :

diff --git a/define/debian.go b/define/debian.go
index 286149c..a275f41 100644
--- a/define/debian.go
+++ b/define/debian.go
@@ -6,7 +6,7 @@ const (
 	DEBIAN_BENCHMAKR_URL = "dists/bullseye/main/binary-amd64/Release"
 )

-var DEBIAN_HOST_PATTERN = regexp.MustCompile(`/debian/(.+)$`)
+var DEBIAN_HOST_PATTERN = regexp.MustCompile(`/debian(-security)?/(.+)$`)

 // https://www.debian.org/mirror/list 2022.11.19
 // Sites that contain protocol headers, restrict access to resources using that protocol
diff --git a/internal/rewriter/rewriter.go b/internal/rewriter/rewriter.go
index 0526507..2f3cfbe 100644
--- a/internal/rewriter/rewriter.go
+++ b/internal/rewriter/rewriter.go
@@ -5,6 +5,7 @@ import (
 	"net/http"
 	"net/url"
 	"regexp"
+	"strings"
 	"sync"

 	"github.com/soulteary/apt-proxy/define"
@@ -171,6 +172,13 @@ func RewriteRequestByMode(r *http.Request, rewriters *URLRewriters, mode int) {

 	r.URL.Scheme = rewriter.mirror.Scheme
 	r.URL.Host = rewriter.mirror.Host
+	if mode == define.TYPE_LINUX_DISTROS_DEBIAN {
+		slugs_query := strings.Split(r.URL.Path, "/")
+		slugs_mirror := strings.Split(rewriter.mirror.Path, "/")
+		slugs_mirror[0] = slugs_query[0]
+		r.URL.Path = strings.Join(slugs_query, "/")
+		return
+	}
 	r.URL.Path = rewriter.mirror.Path + unescapedQuery
 }

Do you want a pull request ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions