diff options
| author | Shulhan <ms@kilabit.info> | 2019-01-28 02:55:40 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2019-01-28 15:26:02 +0700 |
| commit | 0d2f31a9598affe7ccd19a60f6a1dc63c57768bd (patch) | |
| tree | 9ade7e66fe0224fbf10bd48212a9ec4c7db1f52b | |
| parent | bf0b63db74108f61da2e305c3cec99d68cc804fe (diff) | |
| download | pakakeh.go-0d2f31a9598affe7ccd19a60f6a1dc63c57768bd.tar.xz | |
lib/dns: add type of connection
This is to limit implementation to assign value of connection type to
known values only.
| -rw-r--r-- | CHANGELOG.adoc | 1 | ||||
| -rw-r--r-- | lib/dns/dns.go | 9 | ||||
| -rw-r--r-- | 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 |
