From 0d2f31a9598affe7ccd19a60f6a1dc63c57768bd Mon Sep 17 00:00:00 2001 From: Shulhan Date: Mon, 28 Jan 2019 02:55:40 +0700 Subject: lib/dns: add type of connection This is to limit implementation to assign value of connection type to known values only. --- CHANGELOG.adoc | 1 + lib/dns/dns.go | 9 +++++++++ lib/dns/request.go | 9 +-------- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 6f8b51ed..a33d0338 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -8,6 +8,7 @@ first week of next month. === New Features +* `lib/dns`: add type of connection * `lib/http`: add parameter http.ResponseWriter to Callback. * `lib/http`: the RegisterXxx functions now use the Endpoint type. diff --git a/lib/dns/dns.go b/lib/dns/dns.go index cfacf1fa..db1f5161 100644 --- a/lib/dns/dns.go +++ b/lib/dns/dns.go @@ -65,6 +65,15 @@ var ( // nolint: gochecknoglobals clientTimeout = 6 * time.Second ) +type ConnType byte + +// List of known connection type. +const ( + ConnTypeUDP ConnType = 1 << iota + ConnTypeTCP + ConnTypeDoH +) + // OpCode define a custom type for DNS header operation code. type OpCode byte diff --git a/lib/dns/request.go b/lib/dns/request.go index b1f9eb96..00a8f909 100644 --- a/lib/dns/request.go +++ b/lib/dns/request.go @@ -9,13 +9,6 @@ import ( "net/http" ) -// List of known connection type. -const ( - ConnTypeUDP = 1 - ConnTypeTCP = 2 - ConnTypeDoH = 4 -) - // // Request contains UDP address and DNS query message from client. // @@ -27,7 +20,7 @@ const ( type Request struct { // Kind define the connection type that this request is belong to, // e.g. UDP, TCP, or DoH. - Kind int + Kind ConnType // Message define the DNS query. Message *Message -- cgit v1.3