Compare commits
3 Commits
2025021901
...
2025022201
Author | SHA1 | Date | |
---|---|---|---|
27634d016b | |||
ab852a6520 | |||
18bdc4f54e |
@ -8,13 +8,19 @@ env:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-container:
|
build-container:
|
||||||
runs-on: bookworm
|
runs-on: docker
|
||||||
steps:
|
steps:
|
||||||
- name: Setup apt mirror
|
- name: Setup apt mirror
|
||||||
run: sed -i "s,deb.debian.org,${{ vars.DEBIAN_MIRROR }},g" ${{ vars.DEBIAN_APT_SOURCES }}
|
run: sed -i "s,deb.debian.org,${{ vars.DEBIAN_MIRROR }},g" ${{ vars.DEBIAN_APT_SOURCES }}
|
||||||
if: ${{ vars.DEBIAN_MIRROR && vars.DEBIAN_APT_SOURCES }}
|
if: ${{ vars.DEBIAN_MIRROR && vars.DEBIAN_APT_SOURCES }}
|
||||||
- name: Setup debian environment
|
- name: Setup debian environment
|
||||||
run: apt update && apt install -y podman podman-compose nodejs
|
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
|
- name: Check out repository code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Build container
|
- name: Build container
|
||||||
|
@ -7,22 +7,33 @@ on:
|
|||||||
- go.mod
|
- go.mod
|
||||||
- go.lock
|
- go.lock
|
||||||
- go.work
|
- go.work
|
||||||
|
- .gitea/workflows/go-test.yaml
|
||||||
env:
|
env:
|
||||||
GOPROXY: ${{ vars.GOPROXY }}
|
GOPROXY: ${{ vars.GOPROXY }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: bookworm
|
runs-on: docker
|
||||||
steps:
|
steps:
|
||||||
- name: Setup apt mirror
|
- name: Setup apt mirror
|
||||||
run: sed -i "s,deb.debian.org,${{ vars.DEBIAN_MIRROR }},g" ${{ vars.DEBIAN_APT_SOURCES }}
|
run: sed -i "s,deb.debian.org,${{ vars.DEBIAN_MIRROR }},g" ${{ vars.DEBIAN_APT_SOURCES }}
|
||||||
if: ${{ vars.DEBIAN_MIRROR && vars.DEBIAN_APT_SOURCES }}
|
if: ${{ vars.DEBIAN_MIRROR && vars.DEBIAN_APT_SOURCES }}
|
||||||
- name: Setup Debian environment
|
- name: Setup Debian environment
|
||||||
run: apt update && apt install -y nodejs
|
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
|
- name: Setup Golang
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: 1.24.0
|
go-version: 1.24.0
|
||||||
|
cache-dependency-path: |
|
||||||
|
go.sum
|
||||||
- name: Check out repository code
|
- name: Check out repository code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
|
26
server.go
26
server.go
@ -7,6 +7,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -332,7 +333,30 @@ func (server *Server) streamOnline(w http.ResponseWriter, r *http.Request, mtime
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
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() {
|
go func() {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
Reference in New Issue
Block a user