diff --git a/main.go b/main.go index 9a83410..04100da 100644 --- a/main.go +++ b/main.go @@ -43,6 +43,9 @@ func main() { Flags: []cli.Flag{ cli.StringFlag{Name: "url, u", Value: "localhost", Usage: "public URL to use"}, cli.StringFlag{Name: "port", Value: "8010", Usage: "ports of the local relay"}, + cli.StringFlag{Name: "google-site-verification-id, g", Value: "", Usage: "Google site verification ID"}, + cli.StringFlag{Name: "umami-url", Value: "", Usage: "Umami analytics URL"}, + cli.StringFlag{Name: "umami-id", Value: "", Usage: "Umami analytics ID"}, }, HelpName: "hostyoself relay", Action: func(c *cli.Context) error { @@ -118,6 +121,11 @@ func relay(c *cli.Context) (err error) { flagPublicURL = "http://" + flagPublicURL } - s := server.New(flagPublicURL, c.String("port")) + s := server.New( + flagPublicURL, + c.String("port"), + c.String("google-site-verification-id"), + c.String("umami-url"), + c.String("umami-id")) return s.Run() } diff --git a/pkg/server/server.go b/pkg/server/server.go index 9ecae83..41c3b89 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -21,8 +21,11 @@ import ( ) type server struct { - publicURL string - port string + publicURL string + port string + googleSiteVerification string + umamiURL string + umamiID string // connections stored as map of domain -> connections conn map[string][]*connection @@ -39,11 +42,14 @@ type connection struct { ws *wsconn.WebsocketConn } -func New(publicURL, port string) *server { +func New(publicURL, port, googleSiteVerification, umamiURL, umamiID string) *server { return &server{ - publicURL: publicURL, - port: port, - conn: make(map[string][]*connection), + publicURL: publicURL, + port: port, + googleSiteVerification: googleSiteVerification, + umamiURL: umamiURL, + umamiID: umamiID, + conn: make(map[string][]*connection), } } @@ -106,14 +112,20 @@ Disallow:`)) return err } type view struct { - PublicURL template.JS - GeneratedDomain string - GeneratedKey string + PublicURL template.JS + GoogleSiteVerification string + UmamiURL template.JS + UmamiID string + GeneratedDomain string + GeneratedKey string } return t.Execute(w, view{ - PublicURL: template.JS(s.publicURL), - GeneratedDomain: namesgenerator.GetRandomName(), - GeneratedKey: utils.RandStringBytesMaskImpr(6), + PublicURL: template.JS(s.publicURL), + GoogleSiteVerification: s.googleSiteVerification, + UmamiURL: template.JS(s.umamiURL), + UmamiID: s.umamiID, + GeneratedDomain: namesgenerator.GetRandomName(), + GeneratedKey: utils.RandStringBytesMaskImpr(6), }) } else { // get IP address diff --git a/templates/view.html b/templates/view.html index f8eacf9..152f275 100644 --- a/templates/view.html +++ b/templates/view.html @@ -4,7 +4,12 @@ host yo self - + {{ if .GoogleSiteVerification }} + + {{ end }} + {{ if and .UmamiURL .UmamiID }} + + {{ end }}