chore(release): 发布 v2.0.0
CI / verify (push) Canceled after 0s

- 内置 SSH 终端(/terminal):复用已保存的 SSH 密码/私钥与独立 known_hosts 校验
- 终端二次认证、会话审计(/terminal/audits)、录像审计与常用命令
- DDNS 服务商名称与自定义 IP,新增迁移 037/038/039
- CHANGELOG 与 VERSION 更新至 2.0.0
This commit is contained in:
2026-10-16 20:18:04 +08:00
parent a0cc553d2d
commit 302248a907
65 changed files with 7263 additions and 606 deletions
+56
View File
@@ -1,9 +1,19 @@
package app
import (
"context"
"errors"
"fmt"
"io"
"net"
"net/http"
"net/http/httptest"
"path/filepath"
"strings"
"testing"
"time"
"github.com/havline/havline/internal/config"
)
func TestGatewayPrefix(t *testing.T) {
@@ -23,3 +33,49 @@ func TestGatewayPrefix(t *testing.T) {
})
}
}
func TestRunGatewaySocketWithoutTCP(t *testing.T) {
socket := filepath.Join(t.TempDir(), "app.sock")
server := &http.Server{
Addr: "",
Handler: http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
_, _ = w.Write([]byte("havline-gateway-ok"))
}),
}
app := &App{
cfg: config.Config{GatewaySocket: socket},
server: server,
}
errCh := make(chan error, 1)
go func() { errCh <- app.Run() }()
response := requestUnixSocket(t, socket)
if !strings.Contains(response, "havline-gateway-ok") {
t.Fatalf("unix socket response %q", response)
}
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
_ = server.Shutdown(ctx)
if err := <-errCh; err != nil && !errors.Is(err, http.ErrServerClosed) {
t.Fatalf("Run() error: %v", err)
}
}
func requestUnixSocket(t *testing.T, socket string) string {
t.Helper()
deadline := time.Now().Add(2 * time.Second)
for time.Now().Before(deadline) {
conn, err := net.Dial("unix", socket)
if err == nil {
defer conn.Close()
_, _ = fmt.Fprintf(conn, "GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n")
data, _ := io.ReadAll(conn)
return string(data)
}
time.Sleep(20 * time.Millisecond)
}
t.Fatalf("unix socket not ready: %s", socket)
return ""
}