Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@

jobs:
test:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: '1.25.0'
go-version-file: go.mod
- run: yarn install --frozen-lockfile
- run: yarn lint
- run: yarn cucumber
- run: go test ./...
env:
DOCKER_HOST: unix:///var/run/docker.sock
build:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.25.1-alpine@sha256:b6ed3fd0452c0e9bcdef5597f29cc1418f61672e9d3a2f55bf02e7222c014abd AS builder
FROM golang:1.26.2-alpine@sha256:f85330846cde1e57ca9ec309382da3b8e6ae3ab943d2739500e08c86393a21b1 AS builder

WORKDIR /netlib

Expand Down
21 changes: 19 additions & 2 deletions cmd/testproxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,16 @@ func main() {
interrupts := make(map[string]bool)
http.HandleFunc("/create", func(w http.ResponseWriter, r *http.Request) {
id := r.FormValue("id")
host := r.FormValue("host")
if host == "" {
host = "127.0.0.1"
}
port := r.FormValue("port")
laddr, err := net.ResolveUDPAddr("udp", "127.0.0.1:0")
if err != nil {
panic(err)
}
raddr, err := net.ResolveUDPAddr("udp", "127.0.0.1:"+port)
raddr, err := net.ResolveUDPAddr("udp", net.JoinHostPort(host, port))
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -113,7 +117,7 @@ func main() {
addr := util.Getenv("ADDR", ":8080")
server := &http.Server{
Addr: addr,
Handler: http.DefaultServeMux,
Handler: withCORS(http.DefaultServeMux),
}
go func() {
if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
Expand All @@ -130,3 +134,16 @@ func main() {
logger.Fatal("failed to shutdown server", zap.Error(err))
}
}

func withCORS(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, OPTIONS")
w.Header().Set("Access-Control-Allow-Headers", "Content-Type")
if r.Method == http.MethodOptions {
w.WriteHeader(http.StatusNoContent)
return
}
next.ServeHTTP(w, r)
})
}
Loading
Loading