diff options
author | Runxi Yu <me@runxiyu.org> | 2025-02-17 21:57:09 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-02-17 21:57:09 +0800 |
commit | eb1883a8e6241bf811de13a978ebb6af79210967 (patch) | |
tree | 190197e8eee3176d2677c82ac2e470aa6141f619 /git_hooks_handle.go | |
parent | go.mod: Bump lindenii-common (cmap split into ComparableMap and Map) (diff) | |
download | forge-eb1883a8e6241bf811de13a978ebb6af79210967.tar.gz forge-eb1883a8e6241bf811de13a978ebb6af79210967.tar.zst forge-eb1883a8e6241bf811de13a978ebb6af79210967.zip |
hooks, etc.: Authenticate hooks, and handle them in the spawning thread
Diffstat (limited to 'git_hooks_handle.go')
-rw-r--r-- | git_hooks_handle.go | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/git_hooks_handle.go b/git_hooks_handle.go index 5cb59ce..4e3d93d 100644 --- a/git_hooks_handle.go +++ b/git_hooks_handle.go @@ -31,6 +31,21 @@ func hooks_handle_connection(conn net.Conn) { return } + cookie := make([]byte, 64) + _, err = conn.Read(cookie) + if err != nil { + conn.Write([]byte{1}) + fmt.Fprintln(conn, "Failed to read cookie:", err.Error()) + return + } + + deployer_chan, ok := hooks_cookie_deployer.Load(string(cookie)) + if !ok { + conn.Write([]byte{1}) + fmt.Fprintln(conn, "Invalid cookie") + return + } + var argc64 uint64 err = binary.Read(conn, binary.NativeEndian, &argc64) if err != nil { @@ -57,7 +72,14 @@ func hooks_handle_connection(conn net.Conn) { args = append(args, arg.String()) } - conn.Write([]byte{0}) + callback := make(chan struct{}) + + deployer_chan <- hooks_cookie_deployer_return{ + args: args, + callback: callback, + conn: conn, + } + <-callback } func serve_git_hooks(listener net.Listener) error { |