From 59e3a2a67c23dc500823ccab46c5e9a9a70d956b Mon Sep 17 00:00:00 2001 From: vcptr <51714622+vcptr@users.noreply.github.com> Date: Tue, 26 Nov 2019 13:24:46 +0800 Subject: [PATCH] add comments to exported func --- app/dns/dnscommon.go | 2 ++ app/dns/dohdns.go | 5 +++++ infra/conf/v2ray.go | 1 + 3 files changed, 8 insertions(+) diff --git a/app/dns/dnscommon.go b/app/dns/dnscommon.go index 77a0ecda7..65f4bc522 100644 --- a/app/dns/dnscommon.go +++ b/app/dns/dnscommon.go @@ -13,6 +13,7 @@ import ( dns_feature "v2ray.com/core/features/dns" ) +// Fqdn normalize domain make sure it ends with '.' func Fqdn(domain string) string { if len(domain) > 0 && domain[len(domain)-1] == '.' { return domain @@ -25,6 +26,7 @@ type record struct { AAAA *IPRecord } +// IPRecord is a cacheable item for a resolved domain type IPRecord struct { ReqID uint16 IP []net.Address diff --git a/app/dns/dohdns.go b/app/dns/dohdns.go index 8a2fd2b7c..c7a3f5c25 100644 --- a/app/dns/dohdns.go +++ b/app/dns/dohdns.go @@ -40,6 +40,7 @@ type DoHNameServer struct { name string } +// NewDoHNameServer creates DOH client object for remote resolving func NewDoHNameServer(dohHost string, dohPort uint32, dispatcher routing.Dispatcher, clientIP net.IP) (*DoHNameServer, error) { dohAddr := net.ParseAddress(dohHost) @@ -100,6 +101,7 @@ func NewDoHNameServer(dohHost string, dohPort uint32, dispatcher routing.Dispatc return s, nil } +// NewDoHLocalNameServer creates DOH client object for local resolving func NewDoHLocalNameServer(dohHost string, dohPort uint32, clientIP net.IP) *DoHNameServer { if dohPort == 0 { @@ -135,10 +137,12 @@ func baseDOHNameServer(dohHost string, dohPort uint32, prefix string, clientIP n return s } +// Name returns client name func (s *DoHNameServer) Name() string { return s.name } +// DialContext offer dispatched connection through core routing func (s *DoHNameServer) DialContext(ctx context.Context, network, addr string) (net.Conn, error) { dest := s.dohDests[dice.Roll(len(s.dohDests))] @@ -153,6 +157,7 @@ func (s *DoHNameServer) DialContext(ctx context.Context, network, addr string) ( ), nil } +// Cleanup clears expired items from cache func (s *DoHNameServer) Cleanup() error { now := time.Now() s.Lock() diff --git a/infra/conf/v2ray.go b/infra/conf/v2ray.go index 198922d74..58c9c6dad 100644 --- a/infra/conf/v2ray.go +++ b/infra/conf/v2ray.go @@ -79,6 +79,7 @@ type MuxConfig struct { Concurrency int16 `json:"concurrency"` } +// Build creates MultiplexingConfig, Concurrency < 0 completely disables mux. func (m *MuxConfig) Build() *proxyman.MultiplexingConfig { if m.Concurrency < 0 { return nil