mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 15:36:41 -05:00
add comments to exported func
This commit is contained in:
parent
ceb77ac8f5
commit
59e3a2a67c
@ -13,6 +13,7 @@ import (
|
|||||||
dns_feature "v2ray.com/core/features/dns"
|
dns_feature "v2ray.com/core/features/dns"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Fqdn normalize domain make sure it ends with '.'
|
||||||
func Fqdn(domain string) string {
|
func Fqdn(domain string) string {
|
||||||
if len(domain) > 0 && domain[len(domain)-1] == '.' {
|
if len(domain) > 0 && domain[len(domain)-1] == '.' {
|
||||||
return domain
|
return domain
|
||||||
@ -25,6 +26,7 @@ type record struct {
|
|||||||
AAAA *IPRecord
|
AAAA *IPRecord
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IPRecord is a cacheable item for a resolved domain
|
||||||
type IPRecord struct {
|
type IPRecord struct {
|
||||||
ReqID uint16
|
ReqID uint16
|
||||||
IP []net.Address
|
IP []net.Address
|
||||||
|
@ -40,6 +40,7 @@ type DoHNameServer struct {
|
|||||||
name string
|
name string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewDoHNameServer creates DOH client object for remote resolving
|
||||||
func NewDoHNameServer(dohHost string, dohPort uint32, dispatcher routing.Dispatcher, clientIP net.IP) (*DoHNameServer, error) {
|
func NewDoHNameServer(dohHost string, dohPort uint32, dispatcher routing.Dispatcher, clientIP net.IP) (*DoHNameServer, error) {
|
||||||
|
|
||||||
dohAddr := net.ParseAddress(dohHost)
|
dohAddr := net.ParseAddress(dohHost)
|
||||||
@ -100,6 +101,7 @@ func NewDoHNameServer(dohHost string, dohPort uint32, dispatcher routing.Dispatc
|
|||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewDoHLocalNameServer creates DOH client object for local resolving
|
||||||
func NewDoHLocalNameServer(dohHost string, dohPort uint32, clientIP net.IP) *DoHNameServer {
|
func NewDoHLocalNameServer(dohHost string, dohPort uint32, clientIP net.IP) *DoHNameServer {
|
||||||
|
|
||||||
if dohPort == 0 {
|
if dohPort == 0 {
|
||||||
@ -135,10 +137,12 @@ func baseDOHNameServer(dohHost string, dohPort uint32, prefix string, clientIP n
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Name returns client name
|
||||||
func (s *DoHNameServer) Name() string {
|
func (s *DoHNameServer) Name() string {
|
||||||
return s.name
|
return s.name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DialContext offer dispatched connection through core routing
|
||||||
func (s *DoHNameServer) DialContext(ctx context.Context, network, addr string) (net.Conn, error) {
|
func (s *DoHNameServer) DialContext(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||||
|
|
||||||
dest := s.dohDests[dice.Roll(len(s.dohDests))]
|
dest := s.dohDests[dice.Roll(len(s.dohDests))]
|
||||||
@ -153,6 +157,7 @@ func (s *DoHNameServer) DialContext(ctx context.Context, network, addr string) (
|
|||||||
), nil
|
), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cleanup clears expired items from cache
|
||||||
func (s *DoHNameServer) Cleanup() error {
|
func (s *DoHNameServer) Cleanup() error {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
s.Lock()
|
s.Lock()
|
||||||
|
@ -79,6 +79,7 @@ type MuxConfig struct {
|
|||||||
Concurrency int16 `json:"concurrency"`
|
Concurrency int16 `json:"concurrency"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Build creates MultiplexingConfig, Concurrency < 0 completely disables mux.
|
||||||
func (m *MuxConfig) Build() *proxyman.MultiplexingConfig {
|
func (m *MuxConfig) Build() *proxyman.MultiplexingConfig {
|
||||||
if m.Concurrency < 0 {
|
if m.Concurrency < 0 {
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user