diff options
-rw-r--r-- | git_hooks_handle_linux.go | 2 | ||||
-rw-r--r-- | git_hooks_handle_other.go | 2 | ||||
-rw-r--r-- | server.go | 4 | ||||
-rw-r--r-- | ssh_handle_receive_pack.go | 8 |
4 files changed, 8 insertions, 8 deletions
diff --git a/git_hooks_handle_linux.go b/git_hooks_handle_linux.go index fde4c7e..097f236 100644 --- a/git_hooks_handle_linux.go +++ b/git_hooks_handle_linux.go @@ -77,7 +77,7 @@ func (s *server) hooksHandler(conn net.Conn) { { var ok bool - packPass, ok = packPasses.Load(misc.BytesToString(cookie)) + packPass, ok = s.packPasses.Load(misc.BytesToString(cookie)) if !ok { if _, err = conn.Write([]byte{1}); err != nil { return diff --git a/git_hooks_handle_other.go b/git_hooks_handle_other.go index 8b99285..687bd8f 100644 --- a/git_hooks_handle_other.go +++ b/git_hooks_handle_other.go @@ -55,7 +55,7 @@ func (s *server) hooksHandler(conn net.Conn) { { var ok bool - packPass, ok = packPasses.Load(misc.BytesToString(cookie)) + packPass, ok = s.packPasses.Load(misc.BytesToString(cookie)) if !ok { if _, err = conn.Write([]byte{1}); err != nil { return @@ -4,6 +4,7 @@ import ( "net/http" "github.com/jackc/pgx/v5/pgxpool" + "go.lindenii.runxiyu.org/lindenii-common/cmap" goSSH "golang.org/x/crypto/ssh" ) @@ -27,4 +28,7 @@ type server struct { serverPubkeyString string serverPubkeyFP string serverPubkey goSSH.PublicKey + + // packPasses contains hook cookies mapped to their packPass. + packPasses cmap.Map[string, packPass] } diff --git a/ssh_handle_receive_pack.go b/ssh_handle_receive_pack.go index 317609f..33262e4 100644 --- a/ssh_handle_receive_pack.go +++ b/ssh_handle_receive_pack.go @@ -11,7 +11,6 @@ import ( gliderSSH "github.com/gliderlabs/ssh" "github.com/go-git/go-git/v5" - "go.lindenii.runxiyu.org/lindenii-common/cmap" ) // packPass contains information known when handling incoming SSH connections @@ -30,9 +29,6 @@ type packPass struct { contribReq string } -// packPasses contains hook cookies mapped to their packPass. -var packPasses = cmap.Map[string, packPass]{} - // sshHandleRecvPack handles attempts to push to repos. func (s *server) sshHandleRecvPack(session gliderSSH.Session, pubkey, repoIdentifier string) (err error) { groupPath, repoName, repoID, repoPath, directAccess, contribReq, userType, userID, err := s.getRepoInfo2(session.Context(), repoIdentifier, pubkey) @@ -95,7 +91,7 @@ func (s *server) sshHandleRecvPack(session gliderSSH.Session, pubkey, repoIdenti fmt.Fprintln(session.Stderr(), "Error while generating cookie:", err) } - packPasses.Store(cookie, packPass{ + s.packPasses.Store(cookie, packPass{ session: session, pubkey: pubkey, directAccess: directAccess, @@ -108,7 +104,7 @@ func (s *server) sshHandleRecvPack(session gliderSSH.Session, pubkey, repoIdenti contribReq: contribReq, userType: userType, }) - defer packPasses.Delete(cookie) + defer s.packPasses.Delete(cookie) // The Delete won't execute until proc.Wait returns unless something // horribly wrong such as a panic occurs. |