Skip to content

Commit

Permalink
Rename Html>HTML, less output for successful boot
Browse files Browse the repository at this point in the history
  • Loading branch information
aerth committed Oct 12, 2016
1 parent e77db93 commit 774a58b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 46 deletions.
19 changes: 10 additions & 9 deletions 00-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ https://github.com/aerth/cosgo
import (
"flag"
"fmt"
"github.com/aerth/mbox"
"github.com/aerth/seconf"
"log"
"math/rand"
"net"
Expand All @@ -51,12 +49,15 @@ import (
"syscall"
"time"

"github.com/aerth/mbox"
"github.com/aerth/seconf"

"github.com/gorilla/csrf"
sl "github.com/hydrogen18/stoppableListener"
)

var (
version = "0.9.1" // Use makefile for version hash
version = "0.9.2" // Use Makefile for precise version
destinationEmail = "cosgo@localhost"
antiCSRFkey = []byte("LI80PNK1xcT01jmQBsEyxyrNCrbyyFPjPU8CKnxwmCruxNijgnyb3hXXD3p1RBc0+LIRQUUbTtis6hc6LD4I/A==")
cosgoRefresh = 42 * time.Minute
Expand Down Expand Up @@ -92,9 +93,9 @@ func setup() {
//var config seconf.Seconf

if seconf.Exists(*configlocation) {
config, err := seconf.ReadJSON(*configlocation)
if err != nil {
log.Println(err)
config, errar := seconf.ReadJSON(*configlocation)
if errar != nil {
log.Println(errar)
log.Fatalf("Bad config. Please remove the %q file and try again.", *configlocation)
os.Exit(1)
}
Expand Down Expand Up @@ -167,9 +168,9 @@ func setup() {
}

// Open mbox or dev/null
f, err := os.OpenFile(*mboxfile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0600)
if err != nil {
log.Printf("error opening file: %v", err)
f, ferr := os.OpenFile(*mboxfile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0600)
if ferr != nil {
log.Printf("error opening file: %v", ferr)
log.Fatal("Hint: touch ./cosgo.mbox, or chown/chmod it so that the cosgo process can access it.")
os.Exit(1)
}
Expand Down
26 changes: 12 additions & 14 deletions 02-internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ func openLogFile() {
if *logfile == "" {
return
}
f, err := os.OpenFile(*logfile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0600)
if err != nil {
log.Printf("error opening file: %v", err)
f, ferr := os.OpenFile(*logfile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0600)
if ferr != nil {
log.Printf("error opening file: %v", ferr)
log.Fatal("Hint: touch " + *logfile + ", or chown/chmod it so that the cosgo process can access it.")
os.Exit(1)
}
Expand Down Expand Up @@ -87,7 +87,6 @@ func templateFinder() string {
}

if strings.Contains(err.Error(), "no such file") {
log.Println("No such file...", err.Error())
log.Println("Creating!")
err = RestoreAssets(".", "templates")
if err != nil {
Expand All @@ -99,14 +98,13 @@ func templateFinder() string {
return templateDir
}

}

if strings.Contains(err.Error(), "not defined") {
} else if strings.Contains(err.Error(), "not defined") {
log.Println("Template is bad.", err.Error())
os.Exit(1)
}

return "./templates/"
log.Fatalln(err)
return ""
}

// staticFinder returns the static directory. If none is found, static files are disabled.
Expand Down Expand Up @@ -142,15 +140,15 @@ func getDestination() string {

// Open file into bytes
func read2mem(abspath string) []byte {
file, err := os.Open(abspath) // For read access.
if err != nil {
log.Fatal(err)
file, ferr := os.Open(abspath) // For read access.
if ferr != nil {
log.Fatal(ferr)
}

data := make([]byte, 4096)
i, err := file.Read(data)
if err != nil {
log.Fatal(err)
i, rerr := file.Read(data)
if rerr != nil {
log.Fatal(rerr)
}

return data[:i]
Expand Down
7 changes: 5 additions & 2 deletions 60-captcha.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ const (
CaptchaVariation = 2
// CollectNum triggers a garbage collection routine after X captchas are created.
CollectNum = 100
// Expiration for captchas
Expiration = 10 * time.Minute
StdWidth = 240
StdHeight = 90
// StdWidth for captcha
StdWidth = 240
// StdHeight for captcha
StdHeight = 90
)
Loading

0 comments on commit 774a58b

Please sign in to comment.