Sync latest from hotfix3
This commit is contained in:
15
.github/workflows/build.yml
vendored
15
.github/workflows/build.yml
vendored
@@ -26,6 +26,13 @@ jobs:
|
|||||||
- name: Check out code
|
- name: Check out code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Generate build variables
|
||||||
|
id: prep
|
||||||
|
run: |
|
||||||
|
echo "built_at=$(date +%Y-%m-%dT%H:%M:%S)" >> $GITHUB_OUTPUT
|
||||||
|
echo "go_version=$(go version | cut -d ' ' -f 3)" >> $GITHUB_OUTPUT
|
||||||
|
echo "git_commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Cross-compile with xgo
|
- name: Cross-compile with xgo
|
||||||
uses: crazy-max/ghaction-xgo@v3
|
uses: crazy-max/ghaction-xgo@v3
|
||||||
with:
|
with:
|
||||||
@@ -40,10 +47,10 @@ jobs:
|
|||||||
race: false
|
race: false
|
||||||
ldflags: >
|
ldflags: >
|
||||||
-s -w
|
-s -w
|
||||||
-X 'github.com/debridmediamanager/zurg/internal/version.BuiltAt=$(date +%Y-%m-%dT%H:%M:%S)'
|
-X 'github.com/debridmediamanager/zurg/internal.BuiltAt=${{ steps.prep.outputs.built_at }}'
|
||||||
-X 'github.com/debridmediamanager/zurg/internal/version.GoVersion=$(go version | cut -d " " -f 3)'
|
-X 'github.com/debridmediamanager/zurg/internal.GoVersion=${{ steps.prep.outputs.go_version }}'
|
||||||
-X 'github.com/debridmediamanager/zurg/internal/version.GitCommit=$(git rev-parse HEAD)'
|
-X 'github.com/debridmediamanager/zurg/internal.GitCommit=${{ steps.prep.outputs.git_commit }}'
|
||||||
-X 'github.com/debridmediamanager/zurg/internal/version.Version=${{ steps.version.outputs.version }}'
|
-X 'github.com/debridmediamanager/zurg/internal.Version=${{ steps.version.outputs.version }}'
|
||||||
buildmode: default
|
buildmode: default
|
||||||
trimpath: true
|
trimpath: true
|
||||||
|
|
||||||
|
|||||||
13
.github/workflows/build_docker.yml
vendored
13
.github/workflows/build_docker.yml
vendored
@@ -45,6 +45,13 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
images: ghcr.io/${{ github.repository }}
|
images: ghcr.io/${{ github.repository }}
|
||||||
|
|
||||||
|
- name: Generate build variables
|
||||||
|
id: prep
|
||||||
|
run: |
|
||||||
|
echo "built_at=$(date +%Y-%m-%dT%H:%M:%S)" >> $GITHUB_OUTPUT
|
||||||
|
echo "go_version=$(go version | cut -d ' ' -f 3)" >> $GITHUB_OUTPUT
|
||||||
|
echo "git_commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
@@ -56,9 +63,9 @@ jobs:
|
|||||||
cache-from: type=local,src=/tmp/.buildx-cache
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||||
build-args: |
|
build-args: |
|
||||||
BuiltAt=$(date +%Y-%m-%dT%H:%M:%S)
|
BuiltAt=${{ steps.prep.outputs.built_at }}
|
||||||
GoVersion=$(go version)
|
GoVersion=${{ steps.prep.outputs.go_version }}
|
||||||
GitCommit=$(git rev-parse HEAD)
|
GitCommit=${{ steps.prep.outputs.git_commit }}
|
||||||
Version=${{ steps.version.outputs.version }}
|
Version=${{ steps.version.outputs.version }}
|
||||||
|
|
||||||
- name: Extract metadata (tags, labels) for Docker
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ ARG Version
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN apk add --no-cache bash git go gcc musl-dev curl fuse
|
RUN apk add --no-cache bash git go gcc musl-dev curl fuse
|
||||||
RUN go build -ldflags "-s -w -X github.com/debridmediamanager/zurg/internal/version.BuiltAt=$BuiltAt -X github.com/debridmediamanager/zurg/internal/version.GoVersion=$GoVersion -X github.com/debridmediamanager/zurg/internal/version.GitCommit=$GitCommit -X github.com/debridmediamanager/zurg/internal/version.Version=$Version" -o zurg ./cmd/zurg
|
RUN go build -ldflags "-s -w -X 'github.com/debridmediamanager/zurg/internal.BuiltAt=$BuiltAt' -X 'github.com/debridmediamanager/zurg/internal.GoVersion=$GoVersion' -X 'github.com/debridmediamanager/zurg/internal.GitCommit=$GitCommit' -X 'github.com/debridmediamanager/zurg/internal.Version=$Version'" -o zurg ./cmd/zurg
|
||||||
|
|
||||||
# Obfuscation stage
|
# Obfuscation stage
|
||||||
FROM alpine:3 AS obfuscator
|
FROM alpine:3 AS obfuscator
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ type HTTPClient struct {
|
|||||||
getRetryIncr func(resp *http.Response, err error) int
|
getRetryIncr func(resp *http.Response, err error) int
|
||||||
bearerToken string
|
bearerToken string
|
||||||
cfg config.ConfigInterface
|
cfg config.ConfigInterface
|
||||||
ipv6 cmap.ConcurrentMap[string, net.IP]
|
ipv6 cmap.ConcurrentMap[string, string]
|
||||||
log *zap.SugaredLogger
|
log *zap.SugaredLogger
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,26 +60,32 @@ func NewHTTPClient(token string, maxRetries int, timeoutSecs int, cfg config.Con
|
|||||||
return RATE_LIMIT_FACTOR // retry and increment attempt
|
return RATE_LIMIT_FACTOR // retry and increment attempt
|
||||||
},
|
},
|
||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
ipv6: cmap.New[net.IP](),
|
ipv6: cmap.New[string](),
|
||||||
log: log,
|
log: log,
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg.ShouldForceIPv6() {
|
if cfg.ShouldForceIPv6() {
|
||||||
dialer := &net.Dialer{}
|
dialer := &net.Dialer{}
|
||||||
|
|
||||||
dialContext := func(ctx context.Context, network, address string) (net.Conn, error) {
|
dialContext := func(ctx context.Context, network, address string) (net.Conn, error) {
|
||||||
ips, err := net.DefaultResolver.LookupIPAddr(ctx, address)
|
host, port, _ := net.SplitHostPort(address)
|
||||||
|
if ipv6Address, ok := client.ipv6.Get(address); ok {
|
||||||
|
return dialer.DialContext(ctx, network, ipv6Address)
|
||||||
|
}
|
||||||
|
|
||||||
|
ips, err := net.DefaultResolver.LookupIPAddr(ctx, host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, ip := range ips {
|
for _, ip := range ips {
|
||||||
if ip.IP.To4() == nil { // IPv6 address found
|
if ip.IP.To4() == nil { // IPv6 address found
|
||||||
ipv6Address := "[" + ip.IP.String() + "]"
|
ip6Host := ip.IP.String()
|
||||||
|
ipv6Address := net.JoinHostPort(ip6Host, port)
|
||||||
|
client.ipv6.Set(address, ipv6Address)
|
||||||
return dialer.DialContext(ctx, network, ipv6Address)
|
return dialer.DialContext(ctx, network, ipv6Address)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, net.UnknownNetworkError("no IPv6 address found")
|
return dialer.DialContext(ctx, network, address)
|
||||||
}
|
}
|
||||||
|
|
||||||
transport := &http.Transport{
|
transport := &http.Transport{
|
||||||
|
|||||||
Reference in New Issue
Block a user