mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-09-17 02:16:54 +00:00
Defaults in the config file are a nice thing to have
This commit is contained in:
parent
c5f53657cb
commit
787f5a1caa
2 changed files with 21 additions and 23 deletions
|
@ -181,7 +181,26 @@ func FetchBacklogData(chatSubs []string) ([]ClientMessage, error) {
|
||||||
|
|
||||||
func GenerateKeys(outputFile, serverId, theirPublicStr string) {
|
func GenerateKeys(outputFile, serverId, theirPublicStr string) {
|
||||||
var err error
|
var err error
|
||||||
output := ConfigFile{}
|
output := ConfigFile{
|
||||||
|
ListenAddr: "0.0.0.0:8001",
|
||||||
|
SocketOrigin: "localhost:8001",
|
||||||
|
BackendUrl: "http://localhost:8002/ffz",
|
||||||
|
BannerHTML: `
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<title>CatBag</title>
|
||||||
|
<link rel="stylesheet" href="//cdn.frankerfacez.com/script/catbag.css">
|
||||||
|
<div id="container">
|
||||||
|
<div id="zf0"></div><div id="zf1"></div><div id="zf2"></div>
|
||||||
|
<div id="zf3"></div><div id="zf4"></div><div id="zf5"></div>
|
||||||
|
<div id="zf6"></div><div id="zf7"></div><div id="zf8"></div>
|
||||||
|
<div id="zf9"></div><div id="catbag"></div>
|
||||||
|
<div id="bottom">
|
||||||
|
A <a href="http://www.frankerfacez.com/">FrankerFaceZ</a> Service
|
||||||
|
— CatBag by <a href="http://www.twitch.tv/wolsk">Wolsk</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`,
|
||||||
|
}
|
||||||
|
|
||||||
output.ServerId, err = strconv.Atoi(serverId)
|
output.ServerId, err = strconv.Atoi(serverId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -203,7 +222,6 @@ func GenerateKeys(outputFile, serverId, theirPublicStr string) {
|
||||||
output.BackendPublicKey = theirPublic
|
output.BackendPublicKey = theirPublic
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(ourPublic, ourPrivate)
|
|
||||||
bytes, err := json.MarshalIndent(output, "", "\t")
|
bytes, err := json.MarshalIndent(output, "", "\t")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"golang.org/x/net/websocket"
|
"golang.org/x/net/websocket"
|
||||||
"html/template"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -112,37 +111,18 @@ func SetupServerAndHandle(config *ConfigFile, tlsConfig *tls.Config, serveMux *h
|
||||||
serveMux = http.DefaultServeMux
|
serveMux = http.DefaultServeMux
|
||||||
}
|
}
|
||||||
serveMux.HandleFunc("/", ServeWebsocketOrCatbag(sockServer.ServeHTTP))
|
serveMux.HandleFunc("/", ServeWebsocketOrCatbag(sockServer.ServeHTTP))
|
||||||
serveMux.Handle("/assets", http.FileServer(nil)) // TODO
|
|
||||||
serveMux.HandleFunc("/pub_msg", HBackendPublishRequest)
|
serveMux.HandleFunc("/pub_msg", HBackendPublishRequest)
|
||||||
serveMux.HandleFunc("/dump_backlog", HBackendDumpBacklog)
|
serveMux.HandleFunc("/dump_backlog", HBackendDumpBacklog)
|
||||||
serveMux.HandleFunc("/update_and_pub", HBackendUpdateAndPublish)
|
serveMux.HandleFunc("/update_and_pub", HBackendUpdateAndPublish)
|
||||||
}
|
}
|
||||||
|
|
||||||
var Memes = template.Must(template.New("catbag").Parse(`
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<title>CatBag</title>
|
|
||||||
<link rel="stylesheet" href="//cdn.frankerfacez.com/script/catbag.css">
|
|
||||||
<div id="container">
|
|
||||||
<div id="zf0"></div><div id="zf1"></div><div id="zf2"></div>
|
|
||||||
<div id="zf3"></div><div id="zf4"></div><div id="zf5"></div>
|
|
||||||
<div id="zf6"></div><div id="zf7"></div><div id="zf8"></div>
|
|
||||||
<div id="zf9"></div><div id="catbag"></div>
|
|
||||||
<div id="bottom">
|
|
||||||
A <a href="http://www.frankerfacez.com/">FrankerFaceZ</a> Service
|
|
||||||
— CatBag by <a href="http://www.twitch.tv/wolsk">Wolsk</a>
|
|
||||||
<br>
|
|
||||||
This socket server hosted by {{.}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`))
|
|
||||||
|
|
||||||
func ServeWebsocketOrCatbag(sockfunc func(http.ResponseWriter, *http.Request)) http.HandlerFunc {
|
func ServeWebsocketOrCatbag(sockfunc func(http.ResponseWriter, *http.Request)) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Header.Get("Connection") == "Upgrade" {
|
if r.Header.Get("Connection") == "Upgrade" {
|
||||||
sockfunc(w, r)
|
sockfunc(w, r)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
Memes.Execute(w, "Todo Add Feature")
|
w.Write([]byte(gconfig.BannerHTML))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue