mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-23 03:02:48 +01:00
commit
f615809d03
12
oragono.go
12
oragono.go
@ -39,6 +39,13 @@ func getPassword() string {
|
|||||||
return strings.TrimSpace(text)
|
return strings.TrimSpace(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func fileDoesNotExist(file string) bool {
|
||||||
|
if _, err := os.Stat(file); os.IsNotExist(err) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// implements the `oragono mkcerts` command
|
// implements the `oragono mkcerts` command
|
||||||
func doMkcerts(configFile string, quiet bool) {
|
func doMkcerts(configFile string, quiet bool) {
|
||||||
config, err := irc.LoadRawConfig(configFile)
|
config, err := irc.LoadRawConfig(configFile)
|
||||||
@ -59,7 +66,7 @@ func doMkcerts(configFile string, quiet bool) {
|
|||||||
if existingKey == conf.TLS.Key {
|
if existingKey == conf.TLS.Key {
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
log.Fatal("Conflicting TLS key files for", conf.TLS.Cert)
|
log.Fatal("Conflicting TLS key files for ", conf.TLS.Cert)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !quiet {
|
if !quiet {
|
||||||
@ -67,6 +74,9 @@ func doMkcerts(configFile string, quiet bool) {
|
|||||||
}
|
}
|
||||||
host := config.Server.Name
|
host := config.Server.Name
|
||||||
cert, key := conf.TLS.Cert, conf.TLS.Key
|
cert, key := conf.TLS.Cert, conf.TLS.Key
|
||||||
|
if !(fileDoesNotExist(cert) && fileDoesNotExist(key)) {
|
||||||
|
log.Fatalf("Preexisting TLS cert and/or key files: %s %s", cert, key)
|
||||||
|
}
|
||||||
err := mkcerts.CreateCert("Oragono", host, cert, key)
|
err := mkcerts.CreateCert("Oragono", host, cert, key)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if !quiet {
|
if !quiet {
|
||||||
|
Loading…
Reference in New Issue
Block a user