aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2019-04-10 18:10:49 +0700
committerShulhan <ms@kilabit.info>2019-04-12 19:14:02 +0700
commit152a82e1bba4628ee5a63c1d703d88b44aaccbee (patch)
treef0019b3d45eded76f8cfb7bfcc356c8a49be1219
parent0be6dbb429cb550f7f56b07929d1b636b7d579da (diff)
downloadpakakeh.go-152a82e1bba4628ee5a63c1d703d88b44aaccbee.tar.xz
dns: unexport connection type
Since the caches and forwarding now is handled internally, and Request has been unexported, there is no need for exporting the connection type anymore.
-rw-r--r--lib/dns/dns.go18
-rw-r--r--lib/dns/request.go2
-rw-r--r--lib/dns/server.go12
3 files changed, 16 insertions, 16 deletions
diff --git a/lib/dns/dns.go b/lib/dns/dns.go
index 450709a6..064bf9d3 100644
--- a/lib/dns/dns.go
+++ b/lib/dns/dns.go
@@ -62,20 +62,20 @@ var (
clientTimeout = 6 * time.Second //nolint: gochecknoglobals
)
-type ConnType byte
+type connType byte
// List of known connection type.
const (
- ConnTypeUDP ConnType = 1 << iota
- ConnTypeTCP
- ConnTypeDoH
+ connTypeUDP connType = 1 << iota
+ connTypeTCP
+ connTypeDoH
)
-// ConnTypeNames contains a mapping between connection type and its name.
-var ConnTypeNames = map[ConnType]string{ //nolint: gochecknoglobals
- ConnTypeUDP: "UDP",
- ConnTypeTCP: "TCP",
- ConnTypeDoH: "DoH",
+// connTypeNames contains a mapping between connection type and its name.
+var connTypeNames = map[connType]string{ //nolint: gochecknoglobals
+ connTypeUDP: "UDP",
+ connTypeTCP: "TCP",
+ connTypeDoH: "DoH",
}
// OpCode define a custom type for DNS header operation code.
diff --git a/lib/dns/request.go b/lib/dns/request.go
index a5e6d4c9..4cc210b7 100644
--- a/lib/dns/request.go
+++ b/lib/dns/request.go
@@ -20,7 +20,7 @@ import (
type request struct {
// Kind define the connection type that this request is belong to,
// e.g. UDP, TCP, or DoH.
- kind ConnType
+ kind connType
// Message define the DNS query.
message *Message
diff --git a/lib/dns/server.go b/lib/dns/server.go
index c60d5ef1..0b2bf06d 100644
--- a/lib/dns/server.go
+++ b/lib/dns/server.go
@@ -369,7 +369,7 @@ func (srv *Server) serveUDP() {
return
}
- req.kind = ConnTypeUDP
+ req.kind = connTypeUDP
req.udpAddr = raddr
req.message.Packet = req.message.Packet[:n]
@@ -439,7 +439,7 @@ func (srv *Server) handleDoHPost(w http.ResponseWriter, r *http.Request) {
func (srv *Server) handleDoHRequest(raw []byte, w http.ResponseWriter) {
req := newRequest()
- req.kind = ConnTypeDoH
+ req.kind = connTypeDoH
req.responseWriter = w
req.chanResponded = make(chan bool, 1)
@@ -479,7 +479,7 @@ func (srv *Server) serveTCPClient(cl *TCPClient) {
break
}
- req.kind = ConnTypeTCP
+ req.kind = connTypeTCP
req.message.UnpackHeaderQuestion()
req.sender = cl
@@ -549,7 +549,7 @@ func (srv *Server) processResponse(req *request, res *Message, isLocal bool) {
}
switch req.kind {
- case ConnTypeUDP:
+ case connTypeUDP:
if req.sender != nil {
_, err := req.sender.Send(res.Packet, req.udpAddr)
if err != nil {
@@ -558,7 +558,7 @@ func (srv *Server) processResponse(req *request, res *Message, isLocal bool) {
}
}
- case ConnTypeTCP:
+ case connTypeTCP:
if req.sender != nil {
_, err := req.sender.Send(res.Packet, nil)
if err != nil {
@@ -567,7 +567,7 @@ func (srv *Server) processResponse(req *request, res *Message, isLocal bool) {
}
}
- case ConnTypeDoH:
+ case connTypeDoH:
if req.responseWriter != nil {
_, err := req.responseWriter.Write(res.Packet)
req.chanResponded <- true