mirror of
https://github.com/thomiceli/opengist.git
synced 2026-08-07 07:14:49 +00:00
Support IPv6 literals (#749)
Go CI / Lint (push) Has been cancelled
Go CI / Check (push) Has been cancelled
Go CI / Test (mysql, 1.26, mysql:8, ubuntu-latest, 3306:3306) (push) Has been cancelled
Go CI / Test (postgres, 1.26, postgres:16, ubuntu-latest, 5432:5432) (push) Has been cancelled
Go CI / Test (sqlite, 1.26, macOS-latest) (push) Has been cancelled
Go CI / Test (sqlite, 1.26, ubuntu-latest) (push) Has been cancelled
Go CI / Build (1.26, macOS-latest) (push) Has been cancelled
Go CI / Build (1.26, ubuntu-latest) (push) Has been cancelled
Go CI / Build (1.26, windows-latest) (push) Has been cancelled
Go CI / Lint (push) Has been cancelled
Go CI / Check (push) Has been cancelled
Go CI / Test (mysql, 1.26, mysql:8, ubuntu-latest, 3306:3306) (push) Has been cancelled
Go CI / Test (postgres, 1.26, postgres:16, ubuntu-latest, 5432:5432) (push) Has been cancelled
Go CI / Test (sqlite, 1.26, macOS-latest) (push) Has been cancelled
Go CI / Test (sqlite, 1.26, ubuntu-latest) (push) Has been cancelled
Go CI / Build (1.26, macOS-latest) (push) Has been cancelled
Go CI / Build (1.26, ubuntu-latest) (push) Has been cancelled
Go CI / Build (1.26, windows-latest) (push) Has been cancelled
This commit is contained in:
+2
-1
@@ -3,6 +3,7 @@ package db
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
@@ -262,7 +263,7 @@ func setupMySQL(dbInfo databaseInfo) error {
|
||||
if dbInfo.Socket != "" {
|
||||
protocol = fmt.Sprintf("unix(%s)", dbInfo.Socket)
|
||||
} else {
|
||||
protocol = fmt.Sprintf("tcp(%s:%s)", dbInfo.Host, dbInfo.Port)
|
||||
protocol = fmt.Sprintf("tcp(%s)", net.JoinHostPort(dbInfo.Host, dbInfo.Port))
|
||||
}
|
||||
dsn := fmt.Sprintf("%s:%s@%s/%s?charset=utf8mb4&parseTime=True&loc=Local", dbInfo.User, dbInfo.Password, protocol, dbInfo.Database)
|
||||
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ func client() (*http.Client, string) {
|
||||
if host == "0.0.0.0" || host == "::" || host == "" {
|
||||
host = "127.0.0.1"
|
||||
}
|
||||
return &http.Client{}, "http://" + host + ":" + port
|
||||
return &http.Client{}, "http://" + net.JoinHostPort(host, port)
|
||||
}
|
||||
|
||||
func post(path string, reqBody, respBody any) error {
|
||||
|
||||
+3
-2
@@ -49,8 +49,9 @@ func Start() {
|
||||
}
|
||||
|
||||
func listen(serverConfig *ssh.ServerConfig) {
|
||||
log.Info().Msg("Starting SSH server on ssh://" + config.C.SshHost + ":" + config.C.SshPort)
|
||||
listener, err := net.Listen("tcp", config.C.SshHost+":"+config.C.SshPort)
|
||||
addr := net.JoinHostPort(config.C.SshHost, config.C.SshPort)
|
||||
log.Info().Msg("Starting SSH server on ssh://" + addr)
|
||||
listener, err := net.Listen("tcp", addr)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("SSH: Failed to start SSH server")
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package metrics
|
||||
|
||||
import (
|
||||
"net"
|
||||
"net/http"
|
||||
|
||||
"github.com/labstack/echo-contrib/echoprometheus"
|
||||
@@ -31,7 +32,7 @@ func NewServer() *Server {
|
||||
}
|
||||
|
||||
func (s *Server) Start() {
|
||||
addr := config.C.MetricsHost + ":" + config.C.MetricsPort
|
||||
addr := net.JoinHostPort(config.C.MetricsHost, config.C.MetricsPort)
|
||||
log.Info().Msg("Starting metrics server on http://" + addr)
|
||||
if err := s.echo.Start(addr); err != nil && err != http.ErrServerClosed {
|
||||
log.Error().Err(err).Msg("Failed to start metrics server")
|
||||
|
||||
@@ -62,7 +62,7 @@ func (s *Server) Start() {
|
||||
}
|
||||
|
||||
func (s *Server) startHTTP() {
|
||||
addr := config.C.HttpHost + ":" + config.C.HttpPort
|
||||
addr := net.JoinHostPort(config.C.HttpHost, config.C.HttpPort)
|
||||
|
||||
log.Info().Msg("Starting HTTP server on http://" + addr)
|
||||
if err := s.echo.Start(addr); err != nil && err != http.ErrServerClosed {
|
||||
|
||||
Reference in New Issue
Block a user