ergo/ergonomadic.go

45 lines
926 B
Go
Raw Normal View History

2014-02-08 22:18:11 +01:00
package main
import (
2014-02-24 07:21:39 +01:00
"code.google.com/p/go.crypto/bcrypt"
"encoding/base64"
"flag"
"fmt"
2014-02-08 22:18:11 +01:00
"github.com/jlatt/ergonomadic/irc"
2014-02-09 16:53:42 +01:00
"log"
2014-02-08 22:18:11 +01:00
)
2014-02-24 07:21:39 +01:00
func genPasswd(passwd string) {
log.Printf("encoding password \"%s\"\n", passwd)
crypted, err := bcrypt.GenerateFromPassword([]byte(passwd), bcrypt.DefaultCost)
if err != nil {
log.Fatal(err)
}
encoded := base64.StdEncoding.EncodeToString(crypted)
fmt.Println(encoded)
}
2014-02-08 22:18:11 +01:00
func main() {
2014-02-24 07:21:39 +01:00
conf := flag.String("conf", "ergonomadic.json", "ergonomadic config file")
passwd := flag.String("genpasswd", "", "bcrypt a password")
flag.Parse()
if *passwd != "" {
genPasswd(*passwd)
return
}
config, err := irc.LoadConfig(*conf)
2014-02-09 16:53:42 +01:00
if err != nil {
log.Fatal(err)
return
}
irc.DEBUG_NET = config.Debug["net"]
irc.DEBUG_CLIENT = config.Debug["client"]
irc.DEBUG_CHANNEL = config.Debug["channel"]
irc.DEBUG_SERVER = config.Debug["server"]
2014-02-24 04:13:45 +01:00
irc.NewServer(config).Run()
2014-02-08 22:18:11 +01:00
}