- FIX: timetable eval time as "local time" (no UTC)

- FIX: Dockerfile: added timezone configuration (defaults to CET), use TZ env var to change it
pull/1/head
bloved 2021-01-16 00:11:54 +01:00
parent 0f046cf18e
commit 85ff0dac52
5 changed files with 14 additions and 3 deletions

View File

@ -10,9 +10,11 @@ FROM debian:latest
RUN apt update RUN apt update
RUN apt upgrade -y RUN apt upgrade -y
RUN apt install ca-certificates -y RUN apt install ca-certificates -y
RUN apt install tzdata -y
RUN mkdir -p /opt/zabov RUN mkdir -p /opt/zabov
WORKDIR /opt/zabov WORKDIR /opt/zabov
COPY --from=builder /go/src/zabov /opt/zabov COPY --from=builder /go/src/zabov /opt/zabov
EXPOSE 53/udp EXPOSE 53/udp
ENV TZ Europe/Rome
ENTRYPOINT ["/opt/zabov/zabov"] ENTRYPOINT ["/opt/zabov/zabov"]

View File

@ -10,8 +10,10 @@ FROM arm32v7/debian:latest
RUN apt update RUN apt update
RUN apt upgrade -y RUN apt upgrade -y
RUN apt install ca-certificates -y RUN apt install ca-certificates -y
RUN apt install tzdata -y
RUN mkdir -p /opt/zabov RUN mkdir -p /opt/zabov
WORKDIR /opt/zabov WORKDIR /opt/zabov
COPY --from=builder /go/src/zabov /opt/zabov COPY --from=builder /go/src/zabov /opt/zabov
EXPOSE 53/udp EXPOSE 53/udp
ENV TZ Europe/Rome
ENTRYPOINT ["/opt/zabov/zabov"] ENTRYPOINT ["/opt/zabov/zabov"]

View File

@ -10,8 +10,10 @@ FROM arm64v8/debian:latest
RUN apt update RUN apt update
RUN apt upgrade -y RUN apt upgrade -y
RUN apt install ca-certificates -y RUN apt install ca-certificates -y
RUN apt install tzdata -y
RUN mkdir -p /opt/zabov RUN mkdir -p /opt/zabov
WORKDIR /opt/zabov WORKDIR /opt/zabov
COPY --from=builder /go/src/zabov /opt/zabov COPY --from=builder /go/src/zabov /opt/zabov
EXPOSE 53/udp EXPOSE 53/udp
ENV TZ Europe/Rome
ENTRYPOINT ["/opt/zabov/zabov"] ENTRYPOINT ["/opt/zabov/zabov"]

View File

@ -176,6 +176,8 @@ ipgroups: an array of ipgroup dictionaries
# DOCKER # DOCKER
Multistage Dockerfiles are provided for AMD64, ARMv7, ARM64V8 Multistage Dockerfiles are provided for AMD64, ARMv7, ARM64V8
NOTE: you shall use TZ env var to change docker image timezone. TZ defaults to CET.
# TODO: # TODO:
- ~~caching~~ - ~~caching~~

View File

@ -105,6 +105,8 @@ func init() {
dns.TypeTA: "TypeTA", dns.TypeTA: "TypeTA",
dns.TypeDLV: "TypeDLV", dns.TypeDLV: "TypeDLV",
dns.TypeReserved: "TypeReserved"} dns.TypeReserved: "TypeReserved"}
fmt.Println("Local Time:", getLocalTime().Format(time.ANSIC))
} }
func logQuery(clientIP string, name string, reqType uint16, config string, timetable string, killed string) { func logQuery(clientIP string, name string, reqType uint16, config string, timetable string, killed string) {
@ -136,8 +138,8 @@ func logQuery(clientIP string, name string, reqType uint16, config string, timet
} }
} }
func getCurTime() (time.Time, error) { func getLocalTime() time.Time {
return time.Parse("15:04", time.Now().Format("15:04")) return time.Now().Local()
} }
func confFromTimeTable(timetable string) string { func confFromTimeTable(timetable string) string {
@ -149,7 +151,8 @@ func confFromTimeTable(timetable string) string {
return "default" return "default"
} }
for _, ttentry := range tt.table { for _, ttentry := range tt.table {
now := time.Now() now := getLocalTime()
nowHour := now.Hour() nowHour := now.Hour()
nowMinute := now.Minute() nowMinute := now.Minute()
weekday := weekdays[now.Weekday()] weekday := weekdays[now.Weekday()]