~benthor/lunokhod

5d1c993253502be2496d6b5e2758a7fbfddb0285 — Benthor 1 year, 4 months ago 8342248
removed superfluous helper functions
1 files changed, 5 insertions(+), 25 deletions(-)

M main.go
M main.go => main.go +5 -25
@@ 92,7 92,10 @@ func (g Gemini) isAuthenticated(request *gemini.Request) (bool, error) {
		// TOFU, first client cert to speak inimeg:// becomes root
		log.Printf("INFO [%s]: Authentication: TOFU, registering user as root!", raddr)
		root = certs[0].Signature
		g.writeOrFatal(identity, root)
		err = g.Store.Write(identity, root)
		if err != nil {
			log.Fatalf("error registering user as root: %v", err)
		}
	}
	if sig == crypto.Bytes2Sym(root) {
		log.Printf("INFO [%s]: Authentication: Authenticated as root: %v[...]", raddr, sig[:16])


@@ 247,29 250,6 @@ func (g Gemini) getHeader(url url.URL) {

}

func writeOrFatal(key string, val []byte, store *diskv.Diskv) {
	err := store.Write(key, val)
	if err != nil {
		log.Fatalf("Unable to store bytes for key %v: %v", key, err)
	}
}

func (g Gemini) writeOrFatal(key string, val []byte) {
	writeOrFatal(key, val, g.Store)
}

func readOrFatal(key string, store *diskv.Diskv) []byte {
	val, err := store.Read(key)
	if err != nil {
		log.Fatalf("Unable to retrieve bytes for key %v: %v", key, err)
	}
	return val
}

func (g Gemini) readOrFatal(key string) []byte {
	return readOrFatal(key, g.Store)
}

func storeCert(domain, name string, store *diskv.Diskv, cert crypto.Cert) (err error) {
	var (
		certkey = filepath.Join("crypto", domain, name, "certificate")


@@ 387,8 367,8 @@ func InitGemini(domain string) Gemini {
					return &maincert, nil
				}
			}
			log.Printf("offering backup cert to peer supporting curves %v", info.SupportedCurves)
			return &backupcert, nil

		},
	}