mirror of
https://github.com/0xERR0R/blocky.git
synced 2026-10-12 02:01:13 +00:00
Closes #20
This commit is contained in:
+1
-3
@@ -34,8 +34,6 @@ COPY --from=build-env /usr/share/zoneinfo /usr/share/zoneinfo
|
||||
# the tls certificates:
|
||||
COPY --from=build-env /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
HEALTHCHECK --interval=1m --timeout=3s CMD dig @127.0.0.1 -p 53 healthcheck.blocky +tcp || exit 1
|
||||
|
||||
ENTRYPOINT ["/app/blocky"]
|
||||
ENTRYPOINT ["/app/blocky","--config","/app/config.yml"]
|
||||
+2
-2
@@ -165,11 +165,11 @@ type QueryLogConfig struct {
|
||||
LogRetentionDays uint64 `yaml:"logRetentionDays"`
|
||||
}
|
||||
|
||||
func NewConfig() Config {
|
||||
func NewConfig(path string) Config {
|
||||
cfg := Config{}
|
||||
setDefaultValues(&cfg)
|
||||
|
||||
data, err := ioutil.ReadFile("config.yml")
|
||||
data, err := ioutil.ReadFile(path)
|
||||
|
||||
if err != nil {
|
||||
log.Fatal("Can't read config file: ", err)
|
||||
|
||||
@@ -15,7 +15,7 @@ func Test_NewConfig(t *testing.T) {
|
||||
err := os.Chdir("../testdata")
|
||||
assert.NoError(t, err)
|
||||
|
||||
cfg := NewConfig()
|
||||
cfg := NewConfig("config.yml")
|
||||
|
||||
assert.Equal(t, uint16(55555), cfg.Port)
|
||||
assert.Len(t, cfg.Upstream.ExternalResolvers, 3)
|
||||
@@ -49,7 +49,7 @@ func Test_NewConfig_Malformed(t *testing.T) {
|
||||
|
||||
logrus.StandardLogger().ExitFunc = func(int) { fatal = true }
|
||||
|
||||
_ = NewConfig()
|
||||
_ = NewConfig("config.yml")
|
||||
|
||||
assert.True(t, fatal)
|
||||
}
|
||||
@@ -63,7 +63,7 @@ func Test_NewConfig_FileDoesNotExist(t *testing.T) {
|
||||
var fatal bool
|
||||
|
||||
logrus.StandardLogger().ExitFunc = func(int) { fatal = true }
|
||||
_ = NewConfig()
|
||||
_ = NewConfig("config.yml")
|
||||
|
||||
assert.True(t, fatal)
|
||||
}
|
||||
|
||||
+1
-1
@@ -158,7 +158,7 @@ services:
|
||||
```
|
||||
|
||||
### Run standalone
|
||||
Download binary file for your architecture, put it in one directory with config file. Please be aware, you must run the binary with root privileges if you want to use port 53 or 953.
|
||||
Download binary file for your architecture and run `./blocky --config config.yml`. Please be aware, you must run the binary with root privileges if you want to use port 53 or 953.
|
||||
|
||||
### Run with kubernetes (helm)
|
||||
See [this repo](https://github.com/billimek/billimek-charts/tree/master/charts/blocky) or [the helm hub site](https://hub.helm.sh/charts/billimek/blocky) for details about running blocky via helm in kubernetes.
|
||||
|
||||
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"blocky/config"
|
||||
"blocky/server"
|
||||
"flag"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
@@ -20,7 +21,10 @@ var version = "undefined"
|
||||
var buildTime = "undefined"
|
||||
|
||||
func main() {
|
||||
cfg := config.NewConfig()
|
||||
configPath := flag.String("config", "./config.yml", "Path to config file.")
|
||||
flag.Parse()
|
||||
|
||||
cfg := config.NewConfig(*configPath)
|
||||
configureLog(&cfg)
|
||||
|
||||
printBanner()
|
||||
|
||||
Reference in New Issue
Block a user