0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-06-21 23:17:38 +02:00
gitea/modules/ssh/agent_windows.go
pomidorry 80c5948595 Merge remote-tracking branch 'upstream/main' into ssh-mirror-migrations
# Conflicts:
#	go.mod
#	models/repo/mirror.go
#	modules/git/gitcmd/command.go
#	modules/git/remote.go
#	routers/web/user/setting/keys.go
#	services/repository/migrate.go
2026-06-03 19:29:39 +03:00

40 lines
1.0 KiB
Go

// Copyright 2026 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
//go:build windows
package ssh
import (
"fmt"
"net"
"gitea.dev/modules/util"
"github.com/Microsoft/go-winio"
)
// createAgentListener creates a Windows named pipe listener for the SSH agent.
// Returns the listener, pipe path, and a cleanup function for early-return error paths.
func createAgentListener() (net.Listener, string, func(), error) {
agentID := util.CryptoRandomString(16)
pipePath := `\\.\pipe\gitea-ssh-agent-` + agentID
listener, err := winio.ListenPipe(pipePath, nil)
if err != nil {
return nil, "", nil, fmt.Errorf("failed to create named pipe: %w", err)
}
cleanup := func() {
listener.Close()
}
return listener, pipePath, cleanup, nil
}
// setListenerAcceptDeadline is a no-op on Windows; named pipes don't support SetDeadline.
func setListenerAcceptDeadline(_ net.Listener) {}
// cleanupAgentSocket is a no-op on Windows; named pipes are automatically cleaned up when closed.
func cleanupAgentSocket(_ string) {}