2018-03-30 21:16:51 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2018-05-28 18:05:06 +00:00
|
|
|
cwtchserver "cwtch.im/cwtch/server"
|
2018-11-10 22:14:12 +00:00
|
|
|
"git.openprivacy.ca/openprivacy/libricochet-go/connectivity"
|
2018-12-04 02:52:11 +00:00
|
|
|
"git.openprivacy.ca/openprivacy/libricochet-go/log"
|
2018-11-01 17:32:26 +00:00
|
|
|
"os"
|
2018-11-10 22:14:12 +00:00
|
|
|
"path"
|
2018-03-30 21:16:51 +00:00
|
|
|
)
|
|
|
|
|
2018-06-18 22:57:21 +00:00
|
|
|
const (
|
|
|
|
serverConfigFile = "serverConfig.json"
|
|
|
|
)
|
2018-05-03 22:45:50 +00:00
|
|
|
|
2018-03-30 21:16:51 +00:00
|
|
|
func main() {
|
2018-12-04 02:52:11 +00:00
|
|
|
log.AddEverythingFromPattern("server/app/main")
|
|
|
|
log.AddEverythingFromPattern("server/server")
|
2018-11-01 17:32:26 +00:00
|
|
|
configDir := os.Getenv("CWTCH_CONFIG_DIR")
|
|
|
|
|
2018-11-01 20:22:29 +00:00
|
|
|
serverConfig := cwtchserver.LoadConfig(configDir, serverConfigFile)
|
2018-05-03 22:45:50 +00:00
|
|
|
|
2018-11-22 18:01:04 +00:00
|
|
|
acn, err := connectivity.StartTor(path.Join(configDir, "tor"), "")
|
2018-11-10 22:14:12 +00:00
|
|
|
if err != nil {
|
2018-12-04 02:52:11 +00:00
|
|
|
log.Errorf("\nError connecting to Tor: %v\n", err)
|
|
|
|
os.Exit(1)
|
2018-11-10 22:14:12 +00:00
|
|
|
}
|
2018-11-22 18:01:04 +00:00
|
|
|
defer acn.Close()
|
2018-11-10 22:14:12 +00:00
|
|
|
|
2018-03-30 21:16:51 +00:00
|
|
|
server := new(cwtchserver.Server)
|
2018-12-04 02:52:11 +00:00
|
|
|
log.Infoln("starting cwtch server...")
|
2018-03-30 21:16:51 +00:00
|
|
|
|
2018-06-03 19:36:20 +00:00
|
|
|
// TODO load params from .cwtch/server.conf or command line flag
|
2018-11-10 22:14:12 +00:00
|
|
|
// TODO: respond to HUP so t.Close is gracefully called
|
2018-11-22 18:01:04 +00:00
|
|
|
server.Run(acn, serverConfig)
|
2018-06-19 22:38:22 +00:00
|
|
|
}
|