File tree Expand file tree Collapse file tree 4 files changed +19
-1
lines changed Expand file tree Collapse file tree 4 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ require (
15
15
github.com/miekg/dns v1.1.58 // indirect
16
16
github.com/natefinch/atomic v1.0.1 // indirect
17
17
github.com/spf13/pflag v1.0.5 // indirect
18
+ golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect
18
19
golang.org/x/mod v0.14.0 // indirect
19
20
golang.org/x/net v0.20.0 // indirect
20
21
golang.org/x/sync v0.6.0 // indirect
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
16
16
github.com/spf13/cobra v1.8.0 /go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho =
17
17
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA =
18
18
github.com/spf13/pflag v1.0.5 /go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg =
19
+ golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA =
20
+ golang.org/x/exp v0.0.0-20240119083558-1b970713d09a /go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08 =
19
21
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0 =
20
22
golang.org/x/mod v0.14.0 /go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c =
21
23
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo =
Original file line number Diff line number Diff line change @@ -187,7 +187,7 @@ func (o *DNSServer) ServeDNS(w dns.ResponseWriter, r *dns.Msg) {
187
187
now := time .Now ()
188
188
for _ , item := range items {
189
189
netAddr := item .Address ().Unmap ()
190
- ttl := uint32 (item .ExpiresAt ().Sub (now ).Seconds ())
190
+ ttl := uint32 (util . Max ( item .ExpiresAt ().Sub (now ).Seconds (), 0 ))
191
191
switch qtype {
192
192
case dns .TypeA :
193
193
if netAddr .Is4 () {
Original file line number Diff line number Diff line change 9
9
"net/netip"
10
10
"strings"
11
11
12
+ "golang.org/x/exp/constraints"
12
13
"gopkg.in/yaml.v3"
13
14
)
14
15
@@ -117,3 +118,17 @@ func ResolveInterface(spec string) (*net.Interface, error) {
117
118
}
118
119
return nil , errors .New ("specified interface not found" )
119
120
}
121
+
122
+ func Max [T constraints.Ordered ](x , y T ) T {
123
+ if x >= y {
124
+ return x
125
+ }
126
+ return y
127
+ }
128
+
129
+ func Min [T constraints.Ordered ](x , y T ) T {
130
+ if x <= y {
131
+ return x
132
+ }
133
+ return y
134
+ }
You can’t perform that action at this time.
0 commit comments