Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f66f58f67f | ||
|
|
5f036dbc89 |
@@ -1,4 +1,3 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
import os
|
import os
|
||||||
import argparse
|
import argparse
|
||||||
import psycopg2
|
import psycopg2
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
import os
|
import os
|
||||||
import argparse
|
import argparse
|
||||||
import psycopg2
|
import psycopg2
|
||||||
|
|||||||
13
main.go
13
main.go
@@ -19,11 +19,9 @@ import (
|
|||||||
"nxcaldav/internal/extra"
|
"nxcaldav/internal/extra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// -- GET CONFIG
|
// -- GET CONFIG
|
||||||
path := "config.yaml";
|
path := "config.yaml"
|
||||||
if len(os.Args) == 3 {
|
if len(os.Args) == 3 {
|
||||||
if os.Args[1] == "-c" {
|
if os.Args[1] == "-c" {
|
||||||
path = os.Args[2]
|
path = os.Args[2]
|
||||||
@@ -41,18 +39,18 @@ func main() {
|
|||||||
log.Fatalf("failed to initialize database backend: %v", err)
|
log.Fatalf("failed to initialize database backend: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// -- GET CONTEXT AND DB
|
// -- GET CONTEXT AND DB
|
||||||
caldavHandler := &caldav.Handler{Backend: be}
|
caldavHandler := &caldav.Handler{Backend: be}
|
||||||
carddavHandler := &carddav.Handler{Backend: be}
|
carddavHandler := &carddav.Handler{Backend: be}
|
||||||
publicURL, _ := url.Parse(cfg.Server.PublicURL)
|
publicURL, _ := url.Parse(cfg.Server.PublicURL)
|
||||||
|
|
||||||
|
|
||||||
// -- DISCOVERIES
|
// -- DISCOVERIES
|
||||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
scheme := r.URL.Scheme
|
scheme := r.URL.Scheme
|
||||||
if scheme == "" { scheme = "http" }
|
if scheme == "" {
|
||||||
|
scheme = "http"
|
||||||
|
}
|
||||||
|
|
||||||
// set host (because reverse proxies exist)
|
// set host (because reverse proxies exist)
|
||||||
if publicURL != nil && publicURL.Host != "" {
|
if publicURL != nil && publicURL.Host != "" {
|
||||||
@@ -60,7 +58,7 @@ func main() {
|
|||||||
r.URL.Host = publicURL.Host
|
r.URL.Host = publicURL.Host
|
||||||
|
|
||||||
// prioritize X-Forwarded-Proto, then PublicURL (e.g. Cloudfalre proxy)
|
// prioritize X-Forwarded-Proto, then PublicURL (e.g. Cloudfalre proxy)
|
||||||
scheme := publicURL.Scheme
|
scheme = publicURL.Scheme
|
||||||
if proto := r.Header.Get("X-Forwarded-Proto"); proto != "" {
|
if proto := r.Header.Get("X-Forwarded-Proto"); proto != "" {
|
||||||
scheme = proto
|
scheme = proto
|
||||||
}
|
}
|
||||||
@@ -162,6 +160,7 @@ func main() {
|
|||||||
http.NotFound(w, r)
|
http.NotFound(w, r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
fmt.Printf("Starting CalDAV/CardDAV server on %s...\n", cfg.Server.BindAddress)
|
fmt.Printf("Starting CalDAV/CardDAV server on %s...\n", cfg.Server.BindAddress)
|
||||||
server := &http.Server{
|
server := &http.Server{
|
||||||
|
|||||||
Reference in New Issue
Block a user