chore: Format

This commit is contained in:
PapaTutuWawa 2024-01-01 00:38:39 +01:00
parent 1154eff9ae
commit 85bd71cff3
7 changed files with 97 additions and 100 deletions

View File

@ -5,8 +5,8 @@ import (
"crypto/ecdsa" "crypto/ecdsa"
"crypto/elliptic" "crypto/elliptic"
"crypto/rand" "crypto/rand"
"encoding/json"
"encoding/base64" "encoding/base64"
"encoding/json"
"io/ioutil" "io/ioutil"
"github.com/go-acme/lego/v4/acme" "github.com/go-acme/lego/v4/acme"
@ -61,7 +61,6 @@ func ClientFromFile(storage, acmeServer string) (*lego.Client, error) {
contacts = append(contacts, v.(string)) contacts = append(contacts, v.(string))
} }
registration := registration.Resource{ registration := registration.Resource{
URI: reg["uri"].(string), URI: reg["uri"].(string),
Body: acme.Account{ Body: acme.Account{

View File

@ -74,7 +74,7 @@ type CertificateWrapper struct {
func (c *CertificateWrapper) GetPrivateKey() *rsa.PrivateKey { func (c *CertificateWrapper) GetPrivateKey() *rsa.PrivateKey {
data, _ := base64.StdEncoding.DecodeString(c.PrivateKeyEncoded) data, _ := base64.StdEncoding.DecodeString(c.PrivateKeyEncoded)
pk, _ := certcrypto.ParsePEMPrivateKey(data); pk, _ := certcrypto.ParsePEMPrivateKey(data)
return pk.(*rsa.PrivateKey) return pk.(*rsa.PrivateKey)
} }
@ -160,7 +160,7 @@ func fallbackCert(pagesDomain string) (*CertificateWrapper, error) {
return nil, err return nil, err
} }
notAfter := time.Now().Add(time.Hour*24*7); notAfter := time.Now().Add(time.Hour * 24 * 7)
cert := x509.Certificate{ cert := x509.Certificate{
SerialNumber: big.NewInt(1), SerialNumber: big.NewInt(1),
Subject: pkix.Name{ Subject: pkix.Name{

View File

@ -2,18 +2,18 @@ package main
import ( import (
"crypto/tls" "crypto/tls"
"os"
"errors" "errors"
"fmt" "fmt"
"net" "net"
"net/http" "net/http"
"os"
"strings" "strings"
"time" "time"
"code.gitea.io/sdk/gitea" "code.gitea.io/sdk/gitea"
"github.com/urfave/cli/v2"
"github.com/go-acme/lego/v4/challenge/http01" "github.com/go-acme/lego/v4/challenge/http01"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
) )
const ( const (
@ -35,7 +35,6 @@ func handleSubdomain(domain string, cname string, path, giteaUrl string, giteaCl
cname, cname,
path, path,
giteaClient, giteaClient,
) )
if err != nil { if err != nil {
log.Errorf("Failed to get repo: %s", err) log.Errorf("Failed to get repo: %s", err)

View File

@ -14,7 +14,6 @@ var (
pathCache = cache.New(1*time.Hour, 1*time.Hour) pathCache = cache.New(1*time.Hour, 1*time.Hour)
) )
type PageCacheEntry struct { type PageCacheEntry struct {
Repository *gitea.Repository Repository *gitea.Repository
Path string Path string
@ -113,9 +112,9 @@ func RepoFromPath(username, host, cname, path string, giteaClient *gitea.Client)
repoLookup, repoLookup,
) )
reponame = repoLookup reponame = repoLookup
} else if (cname != "") { } else if cname != "" {
// Allow naming the repository "example.org" (But give the TXT record preference) // Allow naming the repository "example.org" (But give the TXT record preference)
reponame = cname; reponame = cname
} }
log.Debugf("Trying repository %s/%s", username, reponame) log.Debugf("Trying repository %s/%s", username, reponame)