aboutsummaryrefslogtreecommitdiff
path: root/git_hooks_handle.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-02-17 21:57:09 +0800
committerRunxi Yu <me@runxiyu.org>2025-02-17 21:57:09 +0800
commiteb1883a8e6241bf811de13a978ebb6af79210967 (patch)
tree190197e8eee3176d2677c82ac2e470aa6141f619 /git_hooks_handle.go
parentgo.mod: Bump lindenii-common (cmap split into ComparableMap and Map) (diff)
downloadforge-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.go24
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 {