mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-09-10 18:50:59 +00:00
fix: artifacts: format IP:port pair using net.JoinHostPort()
This ensures that brackets are added for IPv6 addresses. Without this, This could result in addresses like "2001:db8::1:3456", which - obviously - would break further down and prevent the server from starting. Signed-off-by: Christoph Heiss <christoph@c8h4.io>
This commit is contained in:
parent
cade5051a8
commit
92b7df3da7
3 changed files with 41 additions and 5 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -291,14 +292,14 @@ func Serve(ctx context.Context, artifactPath string, addr string, port string) c
|
|||
downloads(router, artifactPath, fsys)
|
||||
|
||||
server := &http.Server{
|
||||
Addr: fmt.Sprintf("%s:%s", addr, port),
|
||||
Addr: net.JoinHostPort(addr, port),
|
||||
ReadHeaderTimeout: 2 * time.Second,
|
||||
Handler: router,
|
||||
}
|
||||
|
||||
// run server
|
||||
go func() {
|
||||
logger.Infof("Start server on http://%s:%s", addr, port)
|
||||
logger.Infof("Start server on http://%s", server.Addr)
|
||||
if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
||||
logger.Fatalf("http listener: %v", err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue