forked from tcp.direct/tcp.ac
making unnecessary commits for pretty stdout
This commit is contained in:
parent
5595ec9404
commit
324fcd6789
14
config.go
14
config.go
|
@ -33,30 +33,30 @@ func configRead() {
|
||||||
|
|
||||||
s = "http.baseurl"
|
s = "http.baseurl"
|
||||||
baseUrl = viper.GetString(s)
|
baseUrl = viper.GetString(s)
|
||||||
log.Debug().Str(s, baseUrl).Msg("[config]")
|
log.Debug().Str(s, baseUrl).Msg("configRead()")
|
||||||
|
|
||||||
s = "http.port"
|
s = "http.port"
|
||||||
i := viper.GetInt(s)
|
i := viper.GetInt(s)
|
||||||
webPort = strconv.Itoa(i) // int looks cleaner in config
|
webPort = strconv.Itoa(i) // int looks cleaner in config
|
||||||
log.Debug().Str(s, webPort).Msg("[config]") // but we reference it as a string later
|
log.Debug().Str(s, webPort).Msg("configRead()") // but we reference it as a string later
|
||||||
|
|
||||||
s = "http.bindip"
|
s = "http.bindip"
|
||||||
webIP = viper.GetString(s)
|
webIP = viper.GetString(s)
|
||||||
log.Debug().Str(s, webIP).Msg("[config]")
|
log.Debug().Str(s, webIP).Msg("configRead()")
|
||||||
|
|
||||||
s = "files.data"
|
s = "files.data"
|
||||||
dbDir = viper.GetString(s)
|
dbDir = viper.GetString(s)
|
||||||
log.Debug().Str(s, dbDir).Msg("[config]") // where we're actually gonna store everything
|
log.Debug().Str(s, dbDir).Msg("configRead()") // where we're actually gonna store everything
|
||||||
|
|
||||||
s = "files.logs"
|
s = "files.logs"
|
||||||
logDir = viper.GetString(s)
|
logDir = viper.GetString(s)
|
||||||
log.Debug().Str(s, logDir).Msg("[config]")
|
log.Debug().Str(s, logDir).Msg("configRead()")
|
||||||
|
|
||||||
s = "img.uidsize"
|
s = "img.uidsize"
|
||||||
uidSize = viper.GetInt(s)
|
uidSize = viper.GetInt(s)
|
||||||
log.Debug().Int(s, uidSize).Msg("[config]")
|
log.Debug().Int(s, uidSize).Msg("configRead()")
|
||||||
|
|
||||||
s = "img.delkeysize"
|
s = "img.delkeysize"
|
||||||
keySize = viper.GetInt(s)
|
keySize = viper.GetInt(s)
|
||||||
log.Debug().Int(s, keySize).Msg("[config]")
|
log.Debug().Int(s, keySize).Msg("configRead()")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
title = "tcp.ac config"
|
title = "tcp.ac config"
|
||||||
|
|
||||||
[global]
|
[global]
|
||||||
debug = false
|
debug = true
|
||||||
|
|
||||||
[http]
|
[http]
|
||||||
baseurl = "http://127.0.0.1:8080/"
|
baseurl = "http://127.0.0.1:8080/"
|
||||||
|
|
16
db.go
16
db.go
|
@ -1,8 +1,8 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"github.com/prologic/bitcask"
|
"github.com/prologic/bitcask"
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dbInit() {
|
func dbInit() {
|
||||||
|
@ -10,18 +10,18 @@ func dbInit() {
|
||||||
bitcask.WithMaxValueSize(24 / 1024 / 1024),
|
bitcask.WithMaxValueSize(24 / 1024 / 1024),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hashDB, _ = bitcask.Open(dbDir+"hsh", opts...) // this will probably only be for images?
|
||||||
|
log.Debug().Msg("Initializing checksum database")
|
||||||
|
|
||||||
keyDB, _ = bitcask.Open(dbDir+"key", opts...) // delete keys (maybe for all objects?)
|
keyDB, _ = bitcask.Open(dbDir+"key", opts...) // delete keys (maybe for all objects?)
|
||||||
fmt.Println("Initializing key database")
|
log.Debug().Msg("Initializing key database")
|
||||||
|
|
||||||
imgDB, _ = bitcask.Open(dbDir+"img", opts...) // literal image files
|
imgDB, _ = bitcask.Open(dbDir+"img", opts...) // literal image files
|
||||||
fmt.Println("Initializing img database")
|
log.Debug().Msg("Initializing img database")
|
||||||
|
|
||||||
hashDB, _ = bitcask.Open(dbDir+"hsh", opts...) // this will probably only be for images?
|
|
||||||
fmt.Println("Initializing checksum database")
|
|
||||||
|
|
||||||
txtDB, _ = bitcask.Open(dbDir + "txt") // pastebin
|
txtDB, _ = bitcask.Open(dbDir + "txt") // pastebin
|
||||||
fmt.Println("Initializing txt database")
|
log.Debug().Msg("Initializing txt database")
|
||||||
|
|
||||||
urlDB, _ = bitcask.Open(dbDir + "url") // url shortener entries
|
urlDB, _ = bitcask.Open(dbDir + "url") // url shortener entries
|
||||||
fmt.Println("Initializing url database")
|
log.Debug().Msg("Initializing url database")
|
||||||
}
|
}
|
||||||
|
|
7
main.go
7
main.go
|
@ -3,7 +3,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -11,13 +10,11 @@ func init() {
|
||||||
// initialize the logger before the config: that way we can output debug lines
|
// initialize the logger before the config: that way we can output debug lines
|
||||||
// pertaining to the parsing of the configuration init
|
// pertaining to the parsing of the configuration init
|
||||||
|
|
||||||
fmt.Println("Initializing...")
|
|
||||||
|
|
||||||
//////////// init logging ////////////
|
//////////// init logging ////////////
|
||||||
|
|
||||||
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}) // before we read config, do Stderr pretty print (need logs location)
|
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}) // before we read config, do Stderr pretty print (need logs location)
|
||||||
|
|
||||||
log.Info().Msg("Reading configuration file...")
|
log.Info().Msg("Initializing...")
|
||||||
|
|
||||||
// see config.go
|
// see config.go
|
||||||
configRead()
|
configRead()
|
||||||
|
@ -38,7 +35,7 @@ func init() {
|
||||||
|
|
||||||
lf, err := os.OpenFile(logDir+"tcpac.log", os.O_RDWR | os.O_CREATE | os.O_APPEND, 0666)
|
lf, err := os.OpenFile(logDir+"tcpac.log", os.O_RDWR | os.O_CREATE | os.O_APPEND, 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error opening log file: " + err.Error())
|
log.Fatal().Str("logDir",logDir).Err(err).Msg("Error opening log file!")
|
||||||
}
|
}
|
||||||
|
|
||||||
consoleWriter := zerolog.ConsoleWriter{Out: os.Stdout}
|
consoleWriter := zerolog.ConsoleWriter{Out: os.Stdout}
|
||||||
|
|
|
@ -34,6 +34,7 @@ func httpRouter() {
|
||||||
|
|
||||||
imgR := router.Group("/i")
|
imgR := router.Group("/i")
|
||||||
{
|
{
|
||||||
|
imgR.GET("/", func(c *gin.Context) { c.String(200,"") }) // javascript wants something here idk
|
||||||
imgR.POST("/put", imgPost) // put looks nicer even though its actually POST
|
imgR.POST("/put", imgPost) // put looks nicer even though its actually POST
|
||||||
imgR.GET("/:uid", imgView)
|
imgR.GET("/:uid", imgView)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue