diff --git a/Caddyfile b/Caddyfile new file mode 100644 index 0000000..d418646 --- /dev/null +++ b/Caddyfile @@ -0,0 +1,7 @@ +{ + email vicenteferrarismith@gmail.com +} + +alfheimgame.com { + reverse_proxy localhost:4000 +} \ No newline at end of file diff --git a/Makefile b/Makefile index 047934b..b2ff818 100644 --- a/Makefile +++ b/Makefile @@ -16,4 +16,5 @@ deploy: .PHONY: service service: rsync -P alfheimgame.service alfheim@alfheimgame.com:/home/alfheim - ssh -t alfheim@alfheimgame.com 'sudo mv /home/alfheim/alfheimgame.service /etc/systemd/system && sudo systemctl enable alfheimgame && sudo systemctl restart alfheimgame' + rsync -P Caddyfile alfheim@alfheimgame.com:/home/alfheim + ssh -t root@alfheimgame.com 'mv /home/alfheim/alfheimgame.service /etc/systemd/system && mv /home/alfheim/Caddyfile /etc/caddy && systemctl enable alfheimgame && systemctl restart alfheimgame' diff --git a/bin/Caddyfile b/bin/Caddyfile new file mode 100644 index 0000000..d418646 --- /dev/null +++ b/bin/Caddyfile @@ -0,0 +1,7 @@ +{ + email vicenteferrarismith@gmail.com +} + +alfheimgame.com { + reverse_proxy localhost:4000 +} \ No newline at end of file diff --git a/bin/linux_amd64/Caddyfile b/bin/linux_amd64/Caddyfile new file mode 100644 index 0000000..d418646 --- /dev/null +++ b/bin/linux_amd64/Caddyfile @@ -0,0 +1,7 @@ +{ + email vicenteferrarismith@gmail.com +} + +alfheimgame.com { + reverse_proxy localhost:4000 +} \ No newline at end of file diff --git a/bin/linux_amd64/static/panel-000.png b/bin/linux_amd64/static/panel-000.png new file mode 100644 index 0000000..82c2a37 Binary files /dev/null and b/bin/linux_amd64/static/panel-000.png differ diff --git a/bin/linux_amd64/static/style.css b/bin/linux_amd64/static/style.css index 1554965..9f503cf 100644 --- a/bin/linux_amd64/static/style.css +++ b/bin/linux_amd64/static/style.css @@ -1,200 +1,201 @@ html { - height: 100%; - padding: 8px; - /*background: no-repeat url(/static/image.png); - background-size: cover; - background-position: center;*/ - background-color: black; - box-sizing: border-box; + height: 100%; + padding: 8px; + /*background: no-repeat url(/static/image.png); + background-size: cover; + background-position: center;*/ + background-color: black; + box-sizing: border-box; } body { - background-color: #3475CB; - font-family: "Vollkorn"; - color: white; - margin-top: 0px; - margin-left: auto; - margin-right: auto; - margin-bottom: 0px; - min-height: 100%; - max-width: 900px; + background-color: #3475CB; + font-family: "Vollkorn"; + color: white; + margin-top: 0px; + margin-left: auto; + margin-right: auto; + margin-bottom: 0px; + display: flex; + flex-direction: column; + min-height: 100%; + max-width: 900px; } header { - max-width: 100%; + max-width: 100%; } nav { - padding-left: 8px; - padding-right: 8px; - display: flex; - align-items: center; - justify-content: space-between; + padding-left: 8px; + padding-right: 8px; + display: flex; + align-items: center; + justify-content: space-between; } .navbuttons a { - display: inline-block; + display: inline-block; } .maintitle { - margin: 0px; - font-size: 6rem; - color: white; + margin: 0px; + font-size: 6rem; + color: white; } @media (max-width: 1080px) { - .maintitle { - font-size: 4rem; - } + .maintitle { + font-size: 4rem; + } } .loginbutton { - align-self: center; - display: flex; - background-color: white; - padding-top: 15px; - padding-right: 20px; - padding-bottom: 15px; - padding-left: 20px; - border-radius: 5px; - color: black; - /*box-shadow: 10px 10px 5px lightblue;*/ + align-self: center; + display: flex; + border: 12px solid; + border-image-source: url("/static/panel-000.png"); + border-image-slice: 12 fill; + padding-top: 15px; + padding-right: 20px; + padding-bottom: 15px; + padding-left: 20px; + color: black; + /*box-shadow: 10px 10px 5px lightblue;*/ } main { - margin: 0px; - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - min-height: 100%; - max-height: 100%; - margin-left: auto; - margin-right: auto; + padding: 5px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + min-height: 100%; + max-height: 100%; + margin-left: auto; + margin-right: auto; } p { - text-align: center; - font-size: 1rem; + text-align: center; + font-size: 1rem; } .account-wrapper { - background: transparent; - border: 2px solid white; - backdrop-filter: blur(20px); - box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); - border-radius: 15px; - padding: 30px 40px; - font-size: 1.5rem; + background: transparent; + border: 2px solid white; + backdrop-filter: blur(20px); + box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); + border-radius: 15px; + padding: 30px 40px; + font-size: 1.5rem; } .wrapper { - display: inline-block; - background: transparent; - border: 2px solid white; - backdrop-filter: blur(20px); - box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); - border-radius: 15px; - padding: 30px 40px; - width: 80%; - text-align: center; + display: inline-block; + background: transparent; + border: 2px solid white; + backdrop-filter: blur(20px); + box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); + border-radius: 15px; + padding: 30px 40px; + width: 80%; + text-align: center; } .wrapper h1 { - font-size: 1.5rem; - text-align: center; + font-size: 1.5rem; + text-align: center; } .wrapper .input-box { - width: 100%; + width: 100%; } .input-box input { - box-sizing: border-box; - background: transparent; - width: 100%; - height: 100%; - outline: none; - border: 2px solid rgba(255, 255, 255, .2); - border-radius: 25px; - padding: 10px 45px 10px 20px + box-sizing: border-box; + background: transparent; + width: 100%; + height: 100%; + outline: none; + border: 2px solid rgba(255, 255, 255, .2); + border-radius: 25px; + padding: 10px 45px 10px 20px } .input-box input::placeholder { - color: white; + color: white; } .wrapper .input-error { - width: 100%; + width: 100%; } .error { - color: rgba(240, 0, 0, .8); + color: rgba(240, 0, 0, .8); } .input-error input { - box-sizing: border-box; - background: transparent; - width: 100%; - height: 100%; - outline: none; - border: 2px solid rgba(255, 0, 0, .2); - border-radius: 25px; - padding: 10px 45px 10px 20px + box-sizing: border-box; + background: transparent; + width: 100%; + height: 100%; + outline: none; + border: 2px solid rgba(255, 0, 0, .2); + border-radius: 25px; + padding: 10px 45px 10px 20px } .input-error input::placeholder { - color: red; + color: red; } .login-btn-wrapper { - display: flex; - justify-content: center; + display: flex; + justify-content: center; } .wrapper .btn { - width: 100%; - outline: none; - border: none; - border-radius: 20px; + width: 100%; + outline: none; + border: none; + border-radius: 20px; } .wrapper .register-link { - display: flex; - justify-content: center; + display: flex; + justify-content: center; } input { - font-family: inherit; + font-family: inherit; } footer { - position: relative; - left: 0; - bottom: 0; - width: 100%; - background-color: #132123; - color: white; - text-align: center; + margin-top: auto; + width: 100%; + background-color: #132123; + color: white; + text-align: center; } a:link { - text-decoration: none; + text-decoration: none; } .wrapper a:link { - text-decoration: none; + text-decoration: none; } .wrapper a:visited { - text-decoration: none; + text-decoration: none; } .wrapper a:hover { - text-decoration: underline; + text-decoration: underline; } video { - width: 100%; - height: auto; + width: 100%; + height: auto; } diff --git a/bin/linux_amd64/ui/base.html b/bin/linux_amd64/ui/base.html index 0c81a52..42f9e32 100644 --- a/bin/linux_amd64/ui/base.html +++ b/bin/linux_amd64/ui/base.html @@ -1,54 +1,48 @@ - - - - Alfheim - - - - - - - - + + Alfheim + + + + + + + + - -
- +
-
- {{template "body" .}} -
+
+ {{template "body" .}} +
- - + + diff --git a/bin/static/panel-000.png b/bin/static/panel-000.png new file mode 100644 index 0000000..82c2a37 Binary files /dev/null and b/bin/static/panel-000.png differ diff --git a/bin/static/style.css b/bin/static/style.css index 1554965..9f503cf 100644 --- a/bin/static/style.css +++ b/bin/static/style.css @@ -1,200 +1,201 @@ html { - height: 100%; - padding: 8px; - /*background: no-repeat url(/static/image.png); - background-size: cover; - background-position: center;*/ - background-color: black; - box-sizing: border-box; + height: 100%; + padding: 8px; + /*background: no-repeat url(/static/image.png); + background-size: cover; + background-position: center;*/ + background-color: black; + box-sizing: border-box; } body { - background-color: #3475CB; - font-family: "Vollkorn"; - color: white; - margin-top: 0px; - margin-left: auto; - margin-right: auto; - margin-bottom: 0px; - min-height: 100%; - max-width: 900px; + background-color: #3475CB; + font-family: "Vollkorn"; + color: white; + margin-top: 0px; + margin-left: auto; + margin-right: auto; + margin-bottom: 0px; + display: flex; + flex-direction: column; + min-height: 100%; + max-width: 900px; } header { - max-width: 100%; + max-width: 100%; } nav { - padding-left: 8px; - padding-right: 8px; - display: flex; - align-items: center; - justify-content: space-between; + padding-left: 8px; + padding-right: 8px; + display: flex; + align-items: center; + justify-content: space-between; } .navbuttons a { - display: inline-block; + display: inline-block; } .maintitle { - margin: 0px; - font-size: 6rem; - color: white; + margin: 0px; + font-size: 6rem; + color: white; } @media (max-width: 1080px) { - .maintitle { - font-size: 4rem; - } + .maintitle { + font-size: 4rem; + } } .loginbutton { - align-self: center; - display: flex; - background-color: white; - padding-top: 15px; - padding-right: 20px; - padding-bottom: 15px; - padding-left: 20px; - border-radius: 5px; - color: black; - /*box-shadow: 10px 10px 5px lightblue;*/ + align-self: center; + display: flex; + border: 12px solid; + border-image-source: url("/static/panel-000.png"); + border-image-slice: 12 fill; + padding-top: 15px; + padding-right: 20px; + padding-bottom: 15px; + padding-left: 20px; + color: black; + /*box-shadow: 10px 10px 5px lightblue;*/ } main { - margin: 0px; - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - min-height: 100%; - max-height: 100%; - margin-left: auto; - margin-right: auto; + padding: 5px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + min-height: 100%; + max-height: 100%; + margin-left: auto; + margin-right: auto; } p { - text-align: center; - font-size: 1rem; + text-align: center; + font-size: 1rem; } .account-wrapper { - background: transparent; - border: 2px solid white; - backdrop-filter: blur(20px); - box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); - border-radius: 15px; - padding: 30px 40px; - font-size: 1.5rem; + background: transparent; + border: 2px solid white; + backdrop-filter: blur(20px); + box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); + border-radius: 15px; + padding: 30px 40px; + font-size: 1.5rem; } .wrapper { - display: inline-block; - background: transparent; - border: 2px solid white; - backdrop-filter: blur(20px); - box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); - border-radius: 15px; - padding: 30px 40px; - width: 80%; - text-align: center; + display: inline-block; + background: transparent; + border: 2px solid white; + backdrop-filter: blur(20px); + box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); + border-radius: 15px; + padding: 30px 40px; + width: 80%; + text-align: center; } .wrapper h1 { - font-size: 1.5rem; - text-align: center; + font-size: 1.5rem; + text-align: center; } .wrapper .input-box { - width: 100%; + width: 100%; } .input-box input { - box-sizing: border-box; - background: transparent; - width: 100%; - height: 100%; - outline: none; - border: 2px solid rgba(255, 255, 255, .2); - border-radius: 25px; - padding: 10px 45px 10px 20px + box-sizing: border-box; + background: transparent; + width: 100%; + height: 100%; + outline: none; + border: 2px solid rgba(255, 255, 255, .2); + border-radius: 25px; + padding: 10px 45px 10px 20px } .input-box input::placeholder { - color: white; + color: white; } .wrapper .input-error { - width: 100%; + width: 100%; } .error { - color: rgba(240, 0, 0, .8); + color: rgba(240, 0, 0, .8); } .input-error input { - box-sizing: border-box; - background: transparent; - width: 100%; - height: 100%; - outline: none; - border: 2px solid rgba(255, 0, 0, .2); - border-radius: 25px; - padding: 10px 45px 10px 20px + box-sizing: border-box; + background: transparent; + width: 100%; + height: 100%; + outline: none; + border: 2px solid rgba(255, 0, 0, .2); + border-radius: 25px; + padding: 10px 45px 10px 20px } .input-error input::placeholder { - color: red; + color: red; } .login-btn-wrapper { - display: flex; - justify-content: center; + display: flex; + justify-content: center; } .wrapper .btn { - width: 100%; - outline: none; - border: none; - border-radius: 20px; + width: 100%; + outline: none; + border: none; + border-radius: 20px; } .wrapper .register-link { - display: flex; - justify-content: center; + display: flex; + justify-content: center; } input { - font-family: inherit; + font-family: inherit; } footer { - position: relative; - left: 0; - bottom: 0; - width: 100%; - background-color: #132123; - color: white; - text-align: center; + margin-top: auto; + width: 100%; + background-color: #132123; + color: white; + text-align: center; } a:link { - text-decoration: none; + text-decoration: none; } .wrapper a:link { - text-decoration: none; + text-decoration: none; } .wrapper a:visited { - text-decoration: none; + text-decoration: none; } .wrapper a:hover { - text-decoration: underline; + text-decoration: underline; } video { - width: 100%; - height: auto; + width: 100%; + height: auto; } diff --git a/bin/ui/base.html b/bin/ui/base.html index 0c81a52..42f9e32 100644 --- a/bin/ui/base.html +++ b/bin/ui/base.html @@ -1,54 +1,48 @@ - - - - Alfheim - - - - - - - - + + Alfheim + + + + + + + + - -
- +
-
- {{template "body" .}} -
+
+ {{template "body" .}} +
- - + + diff --git a/go.mod b/go.mod index 1b1f312..fc1848c 100644 --- a/go.mod +++ b/go.mod @@ -7,12 +7,12 @@ require ( github.com/gorilla/sessions v1.2.2 github.com/lib/pq v1.10.9 github.com/stripe/stripe-go/v78 v78.7.0 - golang.org/x/crypto v0.23.0 + golang.org/x/crypto v0.33.0 ) require ( github.com/gorilla/securecookie v1.1.2 // indirect golang.org/x/net v0.21.0 // indirect - golang.org/x/sys v0.20.0 // indirect - golang.org/x/text v0.15.0 // indirect + golang.org/x/sys v0.30.0 // indirect + golang.org/x/text v0.22.0 // indirect ) diff --git a/go.sum b/go.sum index 52d96eb..6b08b7b 100644 --- a/go.sum +++ b/go.sum @@ -23,6 +23,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= +golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= +golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -47,6 +49,8 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= +golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= @@ -61,6 +65,8 @@ golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= +golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= diff --git a/main.go b/main.go index 062eb78..f78d378 100644 --- a/main.go +++ b/main.go @@ -4,15 +4,23 @@ package main -import "log" -import "flag" -import "net/http" -import _ "github.com/lib/pq" -import "database/sql" -import "github.com/gorilla/sessions" -import "regexp" +import ( + "flag" + "log" + "net/http" + "time" -import "github.com/stripe/stripe-go/v78" + "database/sql" + "regexp" + + "github.com/gorilla/sessions" + _ "github.com/lib/pq" + "github.com/stripe/stripe-go/v78" + + "crypto/tls" + + "golang.org/x/crypto/acme/autocert" +) var users *Usermodel var subscriptions *SubscriptionModel @@ -23,77 +31,94 @@ var store = sessions.NewCookieStore(key) var emailrx = regexp.MustCompile("/^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/") func main() { - addr := flag.String("addr", "127.0.0.1:8080", "HTTP network addr") - prodaddr := flag.String("prodaddr", "45.76.84.7:443", "HTTP network addr") + addr := flag.String("addr", "127.0.0.1:8080", "HTTP network addr") + //prodaddr := flag.String("prodaddr", "127.0.0.1:4000", "HTTP network addr") + prodaddr := flag.String("prodaddr", "45.76.84.7:443", "HTTP network addr") - production := flag.Bool("production", false, "Whether to use production port and TLS") - _ = addr - flag.Parse() - log.Println("Hello, Sailor!") + production := flag.Bool("production", false, "Whether to use production port and TLS") + _ = addr + flag.Parse() + log.Println("Hello, Sailor!") - stripe.Key = "sk_test_51PGebgKUHKCjyTmc97rfDPcvew6EhqDz2qp3U7XoAMIilAU9IVo2NO4P7ylkTvbBafFVr94trha1VYY32jRWMw2K00Yq7YJXFf" + stripe.Key = "sk_test_51PGebgKUHKCjyTmc97rfDPcvew6EhqDz2qp3U7XoAMIilAU9IVo2NO4P7ylkTvbBafFVr94trha1VYY32jRWMw2K00Yq7YJXFf" - store.MaxAge(0) + store.MaxAge(0) - db, err := sql.Open("postgres", "postgres://elves_database:iK2SoVbDhdCki5n3LxGyP6zKpLspt4@80.240.25.87/elves_database") - if err != nil { - log.Fatal(err) - } - defer db.Close() + db, err := sql.Open("postgres", "postgres://elves_database:iK2SoVbDhdCki5n3LxGyP6zKpLspt4@80.240.25.87/elves_database") + if err != nil { + log.Fatal(err) + } + defer db.Close() - users = &Usermodel{db} - subscriptions = &SubscriptionModel{db} + users = &Usermodel{db} + subscriptions = &SubscriptionModel{db} - mux := http.NewServeMux() + mux := http.NewServeMux() - //rows, err := db.Query("SELECT * FROM accounts") - //if err != nil { - // log.Fatal(err) - //} - //defer rows.Close() + //rows, err := db.Query("SELECT * FROM accounts") + //if err != nil { + // log.Fatal(err) + //} + //defer rows.Close() - //accounts := make([]*Account, 0) - //for rows.Next() { - // acc := new(Account) - // err := rows.Scan(&acc.id, &acc.Username, &acc.password, &acc.Color) - // if err != nil { - // log.Fatal(err) - // } - // accounts = append(accounts, acc) - //} + //accounts := make([]*Account, 0) + //for rows.Next() { + // acc := new(Account) + // err := rows.Scan(&acc.id, &acc.Username, &acc.password, &acc.Color) + // if err != nil { + // log.Fatal(err) + // } + // accounts = append(accounts, acc) + //} - //if err = rows.Err() err != nil { - // log.Fatal(err) - //} + //if err = rows.Err() err != nil { + // log.Fatal(err) + //} - //for _, acc := range accounts { - // log.Println(acc) - //} + //for _, acc := range accounts { + // log.Println(acc) + //} - mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static")))) + mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static")))) - mux.HandleFunc("/favicon.ico", favicon) + mux.HandleFunc("/favicon.ico", favicon) - mux.HandleFunc("/", home) - mux.HandleFunc("/login", login) - mux.HandleFunc("/logout", logout) - mux.HandleFunc("/register", register) - mux.HandleFunc("/account", require_authenticated_user(account)) - mux.HandleFunc("/deleteaccount", require_authenticated_user(deleteaccount)) - mux.HandleFunc("/subscribe", require_authenticated_user(subscribe_stripe)) - mux.HandleFunc("/managebilling", require_authenticated_user(managebilling)) - mux.HandleFunc("/webhook", webhooks) + mux.HandleFunc("/", home) + mux.HandleFunc("/login", login) + mux.HandleFunc("/logout", logout) + mux.HandleFunc("/register", register) + mux.HandleFunc("/account", require_authenticated_user(account)) + mux.HandleFunc("/deleteaccount", require_authenticated_user(deleteaccount)) + mux.HandleFunc("/subscribe", require_authenticated_user(subscribe_stripe)) + mux.HandleFunc("/managebilling", require_authenticated_user(managebilling)) + mux.HandleFunc("/webhook", webhooks) - if *production { + if *production { + autocertManager := autocert.Manager{ + Prompt: autocert.AcceptTOS, + HostPolicy: autocert.HostWhitelist("alfheimgame.com"), + Email: "vicenteferrarismith@gmail.com", + Cache: autocert.DirCache("certs"), + } - server := &http.Server{ - Addr: *prodaddr, - Handler: log_connection(secure_headers(mux)), - } + tlsConfig := &tls.Config{ + GetCertificate: autocertManager.GetCertificate, + PreferServerCipherSuites: true, + CurvePreferences: []tls.CurveID{tls.X25519, tls.CurveP256}, + NextProtos: []string{"acme-tls/1"}, + } + server := &http.Server{ + Addr: *prodaddr, + Handler: log_connection(secure_headers(mux)), + TLSConfig: tlsConfig, + IdleTimeout: time.Minute, + ReadTimeout: 5 * time.Second, + WriteTimeout: 10 * time.Second, + } - log.Fatal(server.ListenAndServeTLS("/home/alfheim/cert/config/live/alfheimgame.com/fullchain.pem", "/home/alfheim/cert/config/live/alfheimgame.com/privkey.pem")) - } else { - log.Fatal(http.ListenAndServe(*addr, log_connection(secure_headers(mux)))) - } + log.Fatal(server.ListenAndServeTLS("", "")) + } else { + log.Fatal(http.ListenAndServe(*addr, log_connection(secure_headers(mux)))) + } } diff --git a/neovide_backtraces.log b/neovide_backtraces.log deleted file mode 100644 index 445bf8a..0000000 --- a/neovide_backtraces.log +++ /dev/null @@ -1,20 +0,0 @@ -2024-04-30 13:18:48 - Neovide panicked with the message 'called `Result::unwrap()` on an `Err` value: Connection(IoError(Custom { kind: Other, error: UnknownError }))'. (File: /build/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.10/src/platform_impl/linux/x11/window.rs; Line: 1316, Column: 14) - 0: - 1: - 2: - 3: - 4: - 5: - 6: - 7: - 8: - 9: - 10: - 11: - 12: - 13: - 14: - 15: - 16: __libc_start_main - 17: - diff --git a/setup.sh b/setup.sh index b1e666e..2811487 100644 --- a/setup.sh +++ b/setup.sh @@ -55,12 +55,11 @@ ufw --force enable apt --yes install fail2ban apt --yes install certbot -su - alfheim -c "mkdir cert" -su - alfheim -c "mkdir cert/lib" -su - alfheim -c "mkdir cert/config" -su - alfheim -c "mkdir cert/log" -su - alfheim -c "sudo certbot certonly --cert-path cert/ --work-dir cert/lib --config-dir cert/config/ --logs-dir cert/log/ --standalone" -su - alfheim -c "sudo chown -R alfheim:alfheim cert" +sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl +curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg +curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list +sudo apt update +sudo apt install caddy # Add a DSN for connecting to the greenlight database to the system-wide environment # variables in the /etc/environment file. diff --git a/static/style.css b/static/style.css index 034d993..9f503cf 100644 --- a/static/style.css +++ b/static/style.css @@ -65,7 +65,7 @@ nav { } main { - margin: 0px; + padding: 5px; display: flex; flex-direction: column; justify-content: center;