README stub and minor app usability features

This commit is contained in:
Dan Ballard 2021-07-12 14:34:55 -07:00
parent a2bed9b884
commit 5e2790dea2
2 changed files with 40 additions and 4 deletions

21
README.md Normal file
View File

@ -0,0 +1,21 @@
# Cwtch Server
## Running
- cd app
- go build
- ./app
The app takes the following arguments
- -debug: enabled debug logging
The app takes the following environment variables
- CWTCH_HOME: sets the config dir for the app
## Using the Server
When run the app will output standard log lines, one of which will contain the `tofubundle` in purple. This is the part you need to capture and import into a Cwtch client app so you can use the server for hosting groups
## Docker
Currently, the dockerfile is out of date and is not usable. Check back for updates.

View File

@ -4,10 +4,13 @@ import (
"crypto/rand"
"cwtch.im/cwtch/model"
"encoding/base64"
"flag"
"fmt"
cwtchserver "git.openprivacy.ca/cwtch.im/server"
"git.openprivacy.ca/cwtch.im/tapir/primitives"
"git.openprivacy.ca/openprivacy/connectivity/tor"
"git.openprivacy.ca/openprivacy/log"
"io/ioutil"
mrand "math/rand"
"os"
"os/signal"
@ -20,11 +23,19 @@ const (
)
func main() {
flagDebug := flag.Bool("debug", false, "Enable debug logging")
flagExportTofu := flag.Bool("exportTofuBundle", false, "Export the tofubundle to a file called `tofubundle`")
flag.Parse()
log.AddEverythingFromPattern("server/app/main")
log.AddEverythingFromPattern("server/server")
log.ExcludeFromPattern("service.go")
log.SetLevel(log.LevelDebug)
configDir := os.Getenv("CWTCH_CONFIG_DIR")
log.SetLevel(log.LevelInfo)
if *flagDebug {
log.Infoln("enableing Debug logging")
log.SetLevel(log.LevelDebug)
}
configDir := os.Getenv("CWTCH_HOME")
if len(os.Args) == 2 && os.Args[1] == "gen1" {
config := new(cwtchserver.Config)
@ -80,9 +91,13 @@ func main() {
}
bundle := server.KeyBundle().Serialize()
log.Infof("Server Config: server:%s", base64.StdEncoding.EncodeToString(bundle))
tofubundle := fmt.Sprintf("tofubundle:server:%s||%s", base64.StdEncoding.EncodeToString(bundle), invite)
log.Infof("Server Tofu Bundle (import into client to use server): %s", log.Magenta(tofubundle))
log.Infof("Server Config: server address:%s", base64.StdEncoding.EncodeToString(bundle))
log.Infof("Server Tofu Bundle: tofubundle:server:%s||%s", base64.StdEncoding.EncodeToString(bundle), invite)
if *flagExportTofu {
ioutil.WriteFile("tofubundle", []byte(tofubundle), 0600)
}
// Graceful Shutdown
c := make(chan os.Signal, 1)