Compare commits
3 Commits
2025021901
...
2025022201
Author | SHA1 | Date | |
---|---|---|---|
27634d016b | |||
ab852a6520 | |||
18bdc4f54e |
@ -8,13 +8,19 @@ env:
|
||||
|
||||
jobs:
|
||||
build-container:
|
||||
runs-on: bookworm
|
||||
runs-on: docker
|
||||
steps:
|
||||
- name: Setup apt mirror
|
||||
run: sed -i "s,deb.debian.org,${{ vars.DEBIAN_MIRROR }},g" ${{ vars.DEBIAN_APT_SOURCES }}
|
||||
if: ${{ vars.DEBIAN_MIRROR && vars.DEBIAN_APT_SOURCES }}
|
||||
- name: Setup debian environment
|
||||
run: apt update && apt install -y podman podman-compose nodejs
|
||||
- name: Setup cache for podman
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
/var/lib/containers
|
||||
key: podman-storage
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
- name: Build container
|
||||
|
@ -7,22 +7,33 @@ on:
|
||||
- go.mod
|
||||
- go.lock
|
||||
- go.work
|
||||
- .gitea/workflows/go-test.yaml
|
||||
env:
|
||||
GOPROXY: ${{ vars.GOPROXY }}
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: bookworm
|
||||
runs-on: docker
|
||||
steps:
|
||||
- name: Setup apt mirror
|
||||
run: sed -i "s,deb.debian.org,${{ vars.DEBIAN_MIRROR }},g" ${{ vars.DEBIAN_APT_SOURCES }}
|
||||
if: ${{ vars.DEBIAN_MIRROR && vars.DEBIAN_APT_SOURCES }}
|
||||
- name: Setup Debian environment
|
||||
run: apt update && apt install -y nodejs
|
||||
- name: Setup cache for golang toolchain
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
/opt/hostedtoolcache/go
|
||||
/root/go/pkg/mod
|
||||
/root/.cache/go-build
|
||||
key: ${{ runner.os }}-golang
|
||||
- name: Setup Golang
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: 1.24.0
|
||||
cache-dependency-path: |
|
||||
go.sum
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
- name: Run tests
|
||||
|
26
server.go
26
server.go
@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -332,7 +333,30 @@ func (server *Server) streamOnline(w http.ResponseWriter, r *http.Request, mtime
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
slog.With("error", err, "upstreamIdx", selectedIdx).Error("something happened during download. will not cache this response")
|
||||
logger := slog.With("upstreamIdx", selectedIdx)
|
||||
logger.Error("something happened during download. will not cache this response. setting lingering to reset the connection.")
|
||||
hijacker, ok := w.(http.Hijacker)
|
||||
if !ok {
|
||||
logger.Warn("response writer is not a hijacker. failed to set lingering")
|
||||
return
|
||||
}
|
||||
conn, _, err := hijacker.Hijack()
|
||||
if err != nil {
|
||||
logger.With("error", err).Warn("hijack failed. failed to set lingering")
|
||||
return
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
tcpConn, ok := conn.(*net.TCPConn)
|
||||
if !ok {
|
||||
logger.With("error", err).Warn("connection is not a *net.TCPConn. failed to set lingering")
|
||||
return
|
||||
}
|
||||
if err := tcpConn.SetLinger(0); err != nil {
|
||||
logger.With("error", err).Warn("failed to set lingering")
|
||||
return
|
||||
}
|
||||
logger.Debug("connection set to linger. it will be reset once the conn.Close is called")
|
||||
}
|
||||
go func() {
|
||||
defer func() {
|
||||
|
Reference in New Issue
Block a user