aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--global.go6
-rw-r--r--handle_group_index.go1
-rw-r--r--handle_index.go1
-rw-r--r--handle_repo_commit.go1
-rw-r--r--handle_repo_index.go3
-rw-r--r--handle_repo_info.go2
-rw-r--r--handle_repo_log.go1
-rw-r--r--handle_repo_raw.go1
-rw-r--r--handle_repo_tree.go1
-rw-r--r--ssh.go8
-rw-r--r--templates/index.html.tmpl22
11 files changed, 42 insertions, 5 deletions
diff --git a/global.go b/global.go
new file mode 100644
index 0000000..3e06171
--- /dev/null
+++ b/global.go
@@ -0,0 +1,6 @@
+package main
+
+var global_data = map[string]any {
+ "server_public_key_string": &server_public_key_string,
+ "server_public_key_fingerprint": &server_public_key_fingerprint,
+}
diff --git a/handle_group_index.go b/handle_group_index.go
index 0bb4a57..2a8e1ca 100644
--- a/handle_group_index.go
+++ b/handle_group_index.go
@@ -6,6 +6,7 @@ import (
func handle_group_repos(w http.ResponseWriter, r *http.Request, params map[string]string) {
data := make(map[string]any)
+ data["global"] = global_data
group_name := params["group_name"]
data["group_name"] = group_name
diff --git a/handle_index.go b/handle_index.go
index c631546..bf36f98 100644
--- a/handle_index.go
+++ b/handle_index.go
@@ -6,6 +6,7 @@ import (
func handle_index(w http.ResponseWriter, r *http.Request) {
data := make(map[string]any)
+ data["global"] = global_data
rows, err := database.Query(r.Context(), "SELECT name FROM groups")
if err != nil {
diff --git a/handle_repo_commit.go b/handle_repo_commit.go
index b567baa..d79b088 100644
--- a/handle_repo_commit.go
+++ b/handle_repo_commit.go
@@ -18,6 +18,7 @@ type usable_file_patch struct {
func handle_repo_commit(w http.ResponseWriter, r *http.Request, params map[string]string) {
data := make(map[string]any)
+ data["global"] = global_data
group_name, repo_name, commit_id_specified_string := params["group_name"], params["repo_name"], params["commit_id"]
data["group_name"], data["repo_name"] = group_name, repo_name
repo, err := open_git_repo(r.Context(), group_name, repo_name)
diff --git a/handle_repo_index.go b/handle_repo_index.go
index 1c03ece..0c7b570 100644
--- a/handle_repo_index.go
+++ b/handle_repo_index.go
@@ -7,6 +7,7 @@ import (
func handle_repo_index(w http.ResponseWriter, r *http.Request, params map[string]string) {
data := make(map[string]any)
+ data["global"] = global_data
group_name, repo_name := params["group_name"], params["repo_name"]
data["group_name"], data["repo_name"] = group_name, repo_name
repo, err := open_git_repo(r.Context(), group_name, repo_name)
@@ -41,7 +42,7 @@ func handle_repo_index(w http.ResponseWriter, r *http.Request, params map[string
data["readme_filename"], data["readme"] = render_readme_at_tree(tree)
data["files"] = build_display_git_tree(tree)
- data["clone_url"] = "ssh://" + r.Host + "/" + url.PathEscape(params["group_name"]) + "/:/repos/" + url.PathEscape(params["repo_name"])
+ data["clone_url"] = "ssh://" + r.Host + "/" + url.PathEscape(params["group_name"]) + "/:/repos/" + url.PathEscape(params["repo_name"])
err = templates.ExecuteTemplate(w, "repo_index", data)
if err != nil {
diff --git a/handle_repo_info.go b/handle_repo_info.go
index 4b01371..5dd92e9 100644
--- a/handle_repo_info.go
+++ b/handle_repo_info.go
@@ -6,5 +6,5 @@ import (
)
func handle_repo_info(w http.ResponseWriter, r *http.Request, params map[string]string) {
- http.Error(w, "\x1b[1;93mHi! We do not support Git operations over HTTP yet.\x1b[0m\n\x1b[1;93mMeanwhile, please use ssh by simply replacing the scheme with \"ssh://\":\x1b[0m\n\x1b[1;93mssh://" + r.Host + "/" + url.PathEscape(params["group_name"]) + "/:/repos/" + url.PathEscape(params["repo_name"]) + "\x1b[0m", http.StatusNotImplemented)
+ http.Error(w, "\x1b[1;93mHi! We do not support Git operations over HTTP yet.\x1b[0m\n\x1b[1;93mMeanwhile, please use ssh by simply replacing the scheme with \"ssh://\":\x1b[0m\n\x1b[1;93mssh://"+r.Host+"/"+url.PathEscape(params["group_name"])+"/:/repos/"+url.PathEscape(params["repo_name"])+"\x1b[0m", http.StatusNotImplemented)
}
diff --git a/handle_repo_log.go b/handle_repo_log.go
index 1c32862..6a3f446 100644
--- a/handle_repo_log.go
+++ b/handle_repo_log.go
@@ -9,6 +9,7 @@ import (
// TODO: I probably shouldn't include *all* commits here...
func handle_repo_log(w http.ResponseWriter, r *http.Request, params map[string]string) {
data := make(map[string]any)
+ data["global"] = global_data
group_name, repo_name, ref_name := params["group_name"], params["repo_name"], params["ref"]
data["group_name"], data["repo_name"], data["ref"] = group_name, repo_name, ref_name
repo, err := open_git_repo(r.Context(), group_name, repo_name)
diff --git a/handle_repo_raw.go b/handle_repo_raw.go
index 4cf7d1a..24b5794 100644
--- a/handle_repo_raw.go
+++ b/handle_repo_raw.go
@@ -11,6 +11,7 @@ import (
func handle_repo_raw(w http.ResponseWriter, r *http.Request, params map[string]string) {
data := make(map[string]any)
+ data["global"] = global_data
raw_path_spec := params["rest"]
group_name, repo_name, path_spec := params["group_name"], params["repo_name"], strings.TrimSuffix(raw_path_spec, "/")
diff --git a/handle_repo_tree.go b/handle_repo_tree.go
index 8076ed6..1dc06a8 100644
--- a/handle_repo_tree.go
+++ b/handle_repo_tree.go
@@ -16,6 +16,7 @@ import (
func handle_repo_tree(w http.ResponseWriter, r *http.Request, params map[string]string) {
data := make(map[string]any)
+ data["global"] = global_data
raw_path_spec := params["rest"]
group_name, repo_name, path_spec := params["group_name"], params["repo_name"], strings.TrimSuffix(raw_path_spec, "/")
ref_type, ref_name, err := get_param_ref_and_type(r)
diff --git a/ssh.go b/ssh.go
index 26370c7..a08e20c 100644
--- a/ssh.go
+++ b/ssh.go
@@ -11,6 +11,10 @@ import (
go_ssh "golang.org/x/crypto/ssh"
)
+var server_public_key_string string
+var server_public_key_fingerprint string
+var server_public_key go_ssh.PublicKey
+
func serve_ssh() error {
host_key_bytes, err := os.ReadFile(config.SSH.Key)
if err != nil {
@@ -22,6 +26,10 @@ func serve_ssh() error {
return err
}
+ server_public_key = host_key.PublicKey()
+ server_public_key_string = string(go_ssh.MarshalAuthorizedKey(server_public_key))
+ server_public_key_fingerprint = string(go_ssh.FingerprintSHA256(server_public_key))
+
server := &glider_ssh.Server{
Handler: func(session glider_ssh.Session) {
client_public_key := session.PublicKey()
diff --git a/templates/index.html.tmpl b/templates/index.html.tmpl
index 505ea70..e88b568 100644
--- a/templates/index.html.tmpl
+++ b/templates/index.html.tmpl
@@ -3,13 +3,14 @@
<html lang="en">
<head>
{{ template "head_common" . }}
- <title>Groups &ndash; Lindenii Forge</title>
+ <title>Index &ndash; Lindenii Forge</title>
</head>
<body class="index">
<div class="padding-wrapper">
- <h1>
+ <h1>Lindenii Forge</h1>
+ <h2>
Groups
- </h1>
+ </h2>
<ul>
{{- range .groups }}
<li>
@@ -17,6 +18,21 @@
</li>
{{- end }}
</ul>
+ <h2>
+ Info
+ </h2>
+ <table class="wide">
+ <tbody>
+ <tr>
+ <th scope="row">SSH Public Key</th>
+ <td><code>{{ .global.server_public_key_string }}</code></td>
+ </tr>
+ <tr>
+ <th scope="row">SSH Fingerprint</th>
+ <td><code>{{ .global.server_public_key_fingerprint }}</code></td>
+ </tr>
+ </tbody>
+ </table>
</div>
<footer>
{{ template "footer" . }}