- 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 upgrade -y
RUN apt install ca-certificates -y
RUN apt install tzdata -y
RUN mkdir -p /opt/zabov
WORKDIR /opt/zabov
COPY --from=builder /go/src/zabov /opt/zabov
EXPOSE 53/udp
ENV TZ Europe/Rome
ENTRYPOINT ["/opt/zabov/zabov"]

View File

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

View File

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

View File

@ -176,6 +176,8 @@ ipgroups: an array of ipgroup dictionaries
# DOCKER
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:
- ~~caching~~

View File

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