Remove IDE-specific noise from source code.
This commit is contained in:
parent
89753c4efb
commit
47e2a1004d
4
app.go
4
app.go
|
@ -263,7 +263,6 @@ func askUsernamePasswordIfPossible() error {
|
||||||
|
|
||||||
// Performs necessary upgrade operations if needed
|
// Performs necessary upgrade operations if needed
|
||||||
func upgradeConfig() error {
|
func upgradeConfig() error {
|
||||||
|
|
||||||
if config.SchemaVersion == SchemaVersion {
|
if config.SchemaVersion == SchemaVersion {
|
||||||
// No upgrade, do nothing
|
// No upgrade, do nothing
|
||||||
return nil
|
return nil
|
||||||
|
@ -276,7 +275,6 @@ func upgradeConfig() error {
|
||||||
|
|
||||||
// Perform upgrade operations for each consecutive version upgrade
|
// Perform upgrade operations for each consecutive version upgrade
|
||||||
for oldVersion, newVersion := config.SchemaVersion, config.SchemaVersion+1; newVersion <= SchemaVersion; {
|
for oldVersion, newVersion := config.SchemaVersion, config.SchemaVersion+1; newVersion <= SchemaVersion; {
|
||||||
|
|
||||||
err := upgradeConfigSchema(oldVersion, newVersion)
|
err := upgradeConfigSchema(oldVersion, newVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
@ -295,7 +293,6 @@ func upgradeConfig() error {
|
||||||
|
|
||||||
// Upgrade from oldVersion to newVersion
|
// Upgrade from oldVersion to newVersion
|
||||||
func upgradeConfigSchema(oldVersion int, newVersion int) error {
|
func upgradeConfigSchema(oldVersion int, newVersion int) error {
|
||||||
|
|
||||||
if oldVersion == 0 && newVersion == 1 {
|
if oldVersion == 0 && newVersion == 1 {
|
||||||
log.Printf("Updating schema from %d to %d", oldVersion, newVersion)
|
log.Printf("Updating schema from %d to %d", oldVersion, newVersion)
|
||||||
|
|
||||||
|
@ -303,7 +300,6 @@ func upgradeConfigSchema(oldVersion int, newVersion int) error {
|
||||||
// Added "ID" field to "filter" -- we need to populate this field now
|
// Added "ID" field to "filter" -- we need to populate this field now
|
||||||
// Added "config.ourDataDir" -- where we will now store filters contents
|
// Added "config.ourDataDir" -- where we will now store filters contents
|
||||||
for i := range config.Filters {
|
for i := range config.Filters {
|
||||||
|
|
||||||
filter := &config.Filters[i] // otherwise we will be operating on a copy
|
filter := &config.Filters[i] // otherwise we will be operating on a copy
|
||||||
|
|
||||||
// Set the filter ID
|
// Set the filter ID
|
||||||
|
|
|
@ -121,7 +121,6 @@ var config = configuration{
|
||||||
|
|
||||||
// Creates a helper object for working with the user rules
|
// Creates a helper object for working with the user rules
|
||||||
func getUserFilter() filter {
|
func getUserFilter() filter {
|
||||||
|
|
||||||
// TODO: This should be calculated when UserRules are set
|
// TODO: This should be calculated when UserRules are set
|
||||||
var contents []byte
|
var contents []byte
|
||||||
for _, rule := range config.UserRules {
|
for _, rule := range config.UserRules {
|
||||||
|
|
11
control.go
11
control.go
|
@ -63,7 +63,6 @@ func httpUpdateConfigReloadDNSReturnOK(w http.ResponseWriter, r *http.Request) {
|
||||||
returnOK(w, r)
|
returnOK(w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
//noinspection GoUnusedParameter
|
|
||||||
func returnOK(w http.ResponseWriter, r *http.Request) {
|
func returnOK(w http.ResponseWriter, r *http.Request) {
|
||||||
_, err := fmt.Fprintf(w, "OK\n")
|
_, err := fmt.Fprintf(w, "OK\n")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -73,7 +72,6 @@ func returnOK(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//noinspection GoUnusedParameter
|
|
||||||
func handleStatus(w http.ResponseWriter, r *http.Request) {
|
func handleStatus(w http.ResponseWriter, r *http.Request) {
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
"dns_address": config.BindHost,
|
"dns_address": config.BindHost,
|
||||||
|
@ -213,7 +211,6 @@ func handleTestUpstreamDNS(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkDNS(input string) error {
|
func checkDNS(input string) error {
|
||||||
|
|
||||||
u, err := upstream.NewUpstream(input, config.CoreDNS.BootstrapDNS)
|
u, err := upstream.NewUpstream(input, config.CoreDNS.BootstrapDNS)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -234,7 +231,6 @@ func checkDNS(input string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//noinspection GoUnusedParameter
|
|
||||||
func handleGetVersionJSON(w http.ResponseWriter, r *http.Request) {
|
func handleGetVersionJSON(w http.ResponseWriter, r *http.Request) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
if now.Sub(versionCheckLastTime) <= versionCheckPeriod && len(versionCheckJSON) != 0 {
|
if now.Sub(versionCheckLastTime) <= versionCheckPeriod && len(versionCheckJSON) != 0 {
|
||||||
|
@ -290,7 +286,6 @@ func handleFilteringDisable(w http.ResponseWriter, r *http.Request) {
|
||||||
httpUpdateConfigReloadDNSReturnOK(w, r)
|
httpUpdateConfigReloadDNSReturnOK(w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
//noinspection GoUnusedParameter
|
|
||||||
func handleFilteringStatus(w http.ResponseWriter, r *http.Request) {
|
func handleFilteringStatus(w http.ResponseWriter, r *http.Request) {
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
"enabled": config.CoreDNS.FilteringEnabled,
|
"enabled": config.CoreDNS.FilteringEnabled,
|
||||||
|
@ -320,7 +315,6 @@ func handleFilteringStatus(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleFilteringAddURL(w http.ResponseWriter, r *http.Request) {
|
func handleFilteringAddURL(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
filter := filter{}
|
filter := filter{}
|
||||||
err := json.NewDecoder(r.Body).Decode(&filter)
|
err := json.NewDecoder(r.Body).Decode(&filter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -667,7 +661,6 @@ func (filter *filter) update(force bool) (bool, error) {
|
||||||
|
|
||||||
// saves filter contents to the file in config.ourDataDir
|
// saves filter contents to the file in config.ourDataDir
|
||||||
func (filter *filter) save() error {
|
func (filter *filter) save() error {
|
||||||
|
|
||||||
filterFilePath := filter.getFilterFilePath()
|
filterFilePath := filter.getFilterFilePath()
|
||||||
log.Printf("Saving filter %d contents to: %s", filter.ID, filterFilePath)
|
log.Printf("Saving filter %d contents to: %s", filter.ID, filterFilePath)
|
||||||
|
|
||||||
|
@ -681,7 +674,6 @@ func (filter *filter) save() error {
|
||||||
|
|
||||||
// loads filter contents from the file in config.ourDataDir
|
// loads filter contents from the file in config.ourDataDir
|
||||||
func (filter *filter) load() error {
|
func (filter *filter) load() error {
|
||||||
|
|
||||||
if !filter.Enabled {
|
if !filter.Enabled {
|
||||||
// No need to load a filter that is not enabled
|
// No need to load a filter that is not enabled
|
||||||
return nil
|
return nil
|
||||||
|
@ -729,7 +721,6 @@ func handleSafeBrowsingDisable(w http.ResponseWriter, r *http.Request) {
|
||||||
httpUpdateConfigReloadDNSReturnOK(w, r)
|
httpUpdateConfigReloadDNSReturnOK(w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
//noinspection GoUnusedParameter
|
|
||||||
func handleSafeBrowsingStatus(w http.ResponseWriter, r *http.Request) {
|
func handleSafeBrowsingStatus(w http.ResponseWriter, r *http.Request) {
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
"enabled": config.CoreDNS.SafeBrowsingEnabled,
|
"enabled": config.CoreDNS.SafeBrowsingEnabled,
|
||||||
|
@ -805,7 +796,6 @@ func handleParentalDisable(w http.ResponseWriter, r *http.Request) {
|
||||||
httpUpdateConfigReloadDNSReturnOK(w, r)
|
httpUpdateConfigReloadDNSReturnOK(w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
//noinspection GoUnusedParameter
|
|
||||||
func handleParentalStatus(w http.ResponseWriter, r *http.Request) {
|
func handleParentalStatus(w http.ResponseWriter, r *http.Request) {
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
"enabled": config.CoreDNS.ParentalEnabled,
|
"enabled": config.CoreDNS.ParentalEnabled,
|
||||||
|
@ -845,7 +835,6 @@ func handleSafeSearchDisable(w http.ResponseWriter, r *http.Request) {
|
||||||
httpUpdateConfigReloadDNSReturnOK(w, r)
|
httpUpdateConfigReloadDNSReturnOK(w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
//noinspection GoUnusedParameter
|
|
||||||
func handleSafeSearchStatus(w http.ResponseWriter, r *http.Request) {
|
func handleSafeSearchStatus(w http.ResponseWriter, r *http.Request) {
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
"enabled": config.CoreDNS.SafeSearchEnabled,
|
"enabled": config.CoreDNS.SafeSearchEnabled,
|
||||||
|
|
|
@ -161,7 +161,6 @@ func setupPlugin(c *caddy.Controller) (*plug, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
//noinspection GoDeferInLoop
|
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
count := 0
|
count := 0
|
||||||
|
@ -271,7 +270,6 @@ func (p *plug) onFinalShutdown() error {
|
||||||
|
|
||||||
type statsFunc func(ch interface{}, name string, text string, value float64, valueType prometheus.ValueType)
|
type statsFunc func(ch interface{}, name string, text string, value float64, valueType prometheus.ValueType)
|
||||||
|
|
||||||
//noinspection GoUnusedParameter
|
|
||||||
func doDesc(ch interface{}, name string, text string, value float64, valueType prometheus.ValueType) {
|
func doDesc(ch interface{}, name string, text string, value float64, valueType prometheus.ValueType) {
|
||||||
realch, ok := ch.(chan<- *prometheus.Desc)
|
realch, ok := ch.(chan<- *prometheus.Desc)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
|
@ -105,7 +105,6 @@ func logRequest(question *dns.Msg, answer *dns.Msg, result dnsfilter.Result, ela
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//noinspection GoUnusedParameter
|
|
||||||
func HandleQueryLog(w http.ResponseWriter, r *http.Request) {
|
func HandleQueryLog(w http.ResponseWriter, r *http.Request) {
|
||||||
queryLogLock.RLock()
|
queryLogLock.RLock()
|
||||||
values := make([]*logEntry, len(queryLogCache))
|
values := make([]*logEntry, len(queryLogCache))
|
||||||
|
@ -140,10 +139,10 @@ func HandleQueryLog(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonEntry := map[string]interface{}{
|
jsonEntry := map[string]interface{}{
|
||||||
"reason": entry.Result.Reason.String(),
|
"reason": entry.Result.Reason.String(),
|
||||||
"elapsedMs": strconv.FormatFloat(entry.Elapsed.Seconds()*1000, 'f', -1, 64),
|
"elapsedMs": strconv.FormatFloat(entry.Elapsed.Seconds()*1000, 'f', -1, 64),
|
||||||
"time": entry.Time.Format(time.RFC3339),
|
"time": entry.Time.Format(time.RFC3339),
|
||||||
"client": entry.IP,
|
"client": entry.IP,
|
||||||
}
|
}
|
||||||
if q != nil {
|
if q != nil {
|
||||||
jsonEntry["question"] = map[string]interface{}{
|
jsonEntry["question"] = map[string]interface{}{
|
||||||
|
|
|
@ -61,7 +61,6 @@ func (p *plug) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *plug) allowRequest(ip string) (bool, error) {
|
func (p *plug) allowRequest(ip string) (bool, error) {
|
||||||
|
|
||||||
if len(p.whitelist) > 0 {
|
if len(p.whitelist) > 0 {
|
||||||
i := sort.SearchStrings(p.whitelist, ip)
|
i := sort.SearchStrings(p.whitelist, ip)
|
||||||
|
|
||||||
|
@ -114,7 +113,6 @@ type plug struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupPlugin(c *caddy.Controller) (*plug, error) {
|
func setupPlugin(c *caddy.Controller) (*plug, error) {
|
||||||
|
|
||||||
p := &plug{ratelimit: defaultRatelimit}
|
p := &plug{ratelimit: defaultRatelimit}
|
||||||
|
|
||||||
for c.Next() {
|
for c.Next() {
|
||||||
|
|
|
@ -36,7 +36,6 @@ func TestSetup(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRatelimiting(t *testing.T) {
|
func TestRatelimiting(t *testing.T) {
|
||||||
|
|
||||||
// rate limit is 1 per sec
|
// rate limit is 1 per sec
|
||||||
c := caddy.NewTestController("dns", `ratelimit 1`)
|
c := caddy.NewTestController("dns", `ratelimit 1`)
|
||||||
p, err := setupPlugin(c)
|
p, err := setupPlugin(c)
|
||||||
|
@ -59,7 +58,6 @@ func TestRatelimiting(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWhitelist(t *testing.T) {
|
func TestWhitelist(t *testing.T) {
|
||||||
|
|
||||||
// rate limit is 1 per sec
|
// rate limit is 1 per sec
|
||||||
c := caddy.NewTestController("dns", `ratelimit 1 { whitelist 127.0.0.2 127.0.0.1 127.0.0.125 }`)
|
c := caddy.NewTestController("dns", `ratelimit 1 { whitelist 127.0.0.2 127.0.0.1 127.0.0.125 }`)
|
||||||
p, err := setupPlugin(c)
|
p, err := setupPlugin(c)
|
||||||
|
|
|
@ -225,13 +225,10 @@ func (r *rulesTable) Add(rule *rule) {
|
||||||
if rule.ip != nil {
|
if rule.ip != nil {
|
||||||
// Hosts syntax
|
// Hosts syntax
|
||||||
r.rulesByHost[rule.text] = rule
|
r.rulesByHost[rule.text] = rule
|
||||||
} else if //noinspection GoBoolExpressions
|
} else if len(rule.shortcut) == shortcutLength && enableFastLookup {
|
||||||
len(rule.shortcut) == shortcutLength && enableFastLookup {
|
|
||||||
|
|
||||||
// Adblock syntax with a shortcut
|
// Adblock syntax with a shortcut
|
||||||
r.rulesByShortcut[rule.shortcut] = append(r.rulesByShortcut[rule.shortcut], rule)
|
r.rulesByShortcut[rule.shortcut] = append(r.rulesByShortcut[rule.shortcut], rule)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Adblock syntax -- too short to have a shortcut
|
// Adblock syntax -- too short to have a shortcut
|
||||||
r.rulesLeftovers = append(r.rulesLeftovers, rule)
|
r.rulesLeftovers = append(r.rulesLeftovers, rule)
|
||||||
}
|
}
|
||||||
|
@ -239,7 +236,6 @@ func (r *rulesTable) Add(rule *rule) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *rulesTable) matchByHost(host string) (Result, error) {
|
func (r *rulesTable) matchByHost(host string) (Result, error) {
|
||||||
|
|
||||||
// First: examine the hosts-syntax rules
|
// First: examine the hosts-syntax rules
|
||||||
res, err := r.searchByHost(host)
|
res, err := r.searchByHost(host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -271,7 +267,6 @@ func (r *rulesTable) matchByHost(host string) (Result, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *rulesTable) searchByHost(host string) (Result, error) {
|
func (r *rulesTable) searchByHost(host string) (Result, error) {
|
||||||
|
|
||||||
rule, ok := r.rulesByHost[host]
|
rule, ok := r.rulesByHost[host]
|
||||||
|
|
||||||
if ok {
|
if ok {
|
||||||
|
@ -773,7 +768,6 @@ func (d *Dnsfilter) AddRule(input string, filterListID int64) error {
|
||||||
|
|
||||||
rule.extractShortcut()
|
rule.extractShortcut()
|
||||||
|
|
||||||
//noinspection GoBoolExpressions
|
|
||||||
if !enableDelayedCompilation {
|
if !enableDelayedCompilation {
|
||||||
err := rule.compile()
|
err := rule.compile()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -20,7 +20,6 @@ import (
|
||||||
|
|
||||||
// Writes data first to a temporary file and then renames it to what's specified in path
|
// Writes data first to a temporary file and then renames it to what's specified in path
|
||||||
func writeFileSafe(path string, data []byte) error {
|
func writeFileSafe(path string, data []byte) error {
|
||||||
|
|
||||||
dir := filepath.Dir(path)
|
dir := filepath.Dir(path)
|
||||||
err := os.MkdirAll(dir, 0755)
|
err := os.MkdirAll(dir, 0755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -18,7 +18,6 @@ type DnsUpstream struct {
|
||||||
|
|
||||||
// NewDnsUpstream creates a new DNS upstream
|
// NewDnsUpstream creates a new DNS upstream
|
||||||
func NewDnsUpstream(endpoint string, proto string, tlsServerName string) (Upstream, error) {
|
func NewDnsUpstream(endpoint string, proto string, tlsServerName string) (Upstream, error) {
|
||||||
|
|
||||||
u := &DnsUpstream{
|
u := &DnsUpstream{
|
||||||
endpoint: endpoint,
|
endpoint: endpoint,
|
||||||
timeout: defaultTimeout,
|
timeout: defaultTimeout,
|
||||||
|
@ -42,7 +41,6 @@ func NewDnsUpstream(endpoint string, proto string, tlsServerName string) (Upstre
|
||||||
|
|
||||||
// Exchange provides an implementation for the Upstream interface
|
// Exchange provides an implementation for the Upstream interface
|
||||||
func (u *DnsUpstream) Exchange(ctx context.Context, query *dns.Msg) (*dns.Msg, error) {
|
func (u *DnsUpstream) Exchange(ctx context.Context, query *dns.Msg) (*dns.Msg, error) {
|
||||||
|
|
||||||
resp, err := u.exchange(u.proto, query)
|
resp, err := u.exchange(u.proto, query)
|
||||||
|
|
||||||
// Retry over TCP if response is truncated
|
// Retry over TCP if response is truncated
|
||||||
|
@ -68,7 +66,6 @@ func (u *DnsUpstream) Exchange(ctx context.Context, query *dns.Msg) (*dns.Msg, e
|
||||||
|
|
||||||
// Clear resources
|
// Clear resources
|
||||||
func (u *DnsUpstream) Close() error {
|
func (u *DnsUpstream) Close() error {
|
||||||
|
|
||||||
// Close active connections
|
// Close active connections
|
||||||
u.transport.Stop()
|
u.transport.Stop()
|
||||||
return nil
|
return nil
|
||||||
|
@ -77,7 +74,6 @@ func (u *DnsUpstream) Close() error {
|
||||||
// Performs a synchronous query. It sends the message m via the conn
|
// Performs a synchronous query. It sends the message m via the conn
|
||||||
// c and waits for a reply. The conn c is not closed.
|
// c and waits for a reply. The conn c is not closed.
|
||||||
func (u *DnsUpstream) exchange(proto string, query *dns.Msg) (r *dns.Msg, err error) {
|
func (u *DnsUpstream) exchange(proto string, query *dns.Msg) (r *dns.Msg, err error) {
|
||||||
|
|
||||||
// Establish a connection if needed (or reuse cached)
|
// Establish a connection if needed (or reuse cached)
|
||||||
conn, err := u.transport.Dial(proto)
|
conn, err := u.transport.Dial(proto)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -10,7 +10,6 @@ import (
|
||||||
|
|
||||||
// Detects the upstream type from the specified url and creates a proper Upstream object
|
// Detects the upstream type from the specified url and creates a proper Upstream object
|
||||||
func NewUpstream(url string, bootstrap string) (Upstream, error) {
|
func NewUpstream(url string, bootstrap string) (Upstream, error) {
|
||||||
|
|
||||||
proto := "udp"
|
proto := "udp"
|
||||||
prefix := ""
|
prefix := ""
|
||||||
|
|
||||||
|
@ -64,7 +63,6 @@ func NewUpstream(url string, bootstrap string) (Upstream, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateResolver(bootstrap string) *net.Resolver {
|
func CreateResolver(bootstrap string) *net.Resolver {
|
||||||
|
|
||||||
bootstrapResolver := net.DefaultResolver
|
bootstrapResolver := net.DefaultResolver
|
||||||
|
|
||||||
if bootstrap != "" {
|
if bootstrap != "" {
|
||||||
|
@ -82,7 +80,6 @@ func CreateResolver(bootstrap string) *net.Resolver {
|
||||||
|
|
||||||
// Performs a simple health-check of the specified upstream
|
// Performs a simple health-check of the specified upstream
|
||||||
func IsAlive(u Upstream) (bool, error) {
|
func IsAlive(u Upstream) (bool, error) {
|
||||||
|
|
||||||
// Using ipv4only.arpa. domain as it is a part of DNS64 RFC and it should exist everywhere
|
// Using ipv4only.arpa. domain as it is a part of DNS64 RFC and it should exist everywhere
|
||||||
ping := new(dns.Msg)
|
ping := new(dns.Msg)
|
||||||
ping.SetQuestion("ipv4only.arpa.", dns.TypeA)
|
ping.SetQuestion("ipv4only.arpa.", dns.TypeA)
|
||||||
|
|
|
@ -17,7 +17,6 @@ func init() {
|
||||||
|
|
||||||
// Read the configuration and initialize upstreams
|
// Read the configuration and initialize upstreams
|
||||||
func setup(c *caddy.Controller) error {
|
func setup(c *caddy.Controller) error {
|
||||||
|
|
||||||
p, err := setupPlugin(c)
|
p, err := setupPlugin(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -34,7 +33,6 @@ func setup(c *caddy.Controller) error {
|
||||||
|
|
||||||
// Read the configuration
|
// Read the configuration
|
||||||
func setupPlugin(c *caddy.Controller) (*UpstreamPlugin, error) {
|
func setupPlugin(c *caddy.Controller) (*UpstreamPlugin, error) {
|
||||||
|
|
||||||
p := New()
|
p := New()
|
||||||
|
|
||||||
log.Println("Initializing the Upstream plugin")
|
log.Println("Initializing the Upstream plugin")
|
||||||
|
@ -72,7 +70,6 @@ func setupPlugin(c *caddy.Controller) (*UpstreamPlugin, error) {
|
||||||
|
|
||||||
func (p *UpstreamPlugin) onShutdown() error {
|
func (p *UpstreamPlugin) onShutdown() error {
|
||||||
for i := range p.Upstreams {
|
for i := range p.Upstreams {
|
||||||
|
|
||||||
u := p.Upstreams[i]
|
u := p.Upstreams[i]
|
||||||
err := u.Close()
|
err := u.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSetup(t *testing.T) {
|
func TestSetup(t *testing.T) {
|
||||||
|
|
||||||
var tests = []struct {
|
var tests = []struct {
|
||||||
config string
|
config string
|
||||||
}{
|
}{
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDnsUpstreamIsAlive(t *testing.T) {
|
func TestDnsUpstreamIsAlive(t *testing.T) {
|
||||||
|
|
||||||
var tests = []struct {
|
var tests = []struct {
|
||||||
url string
|
url string
|
||||||
bootstrap string
|
bootstrap string
|
||||||
|
@ -32,7 +31,6 @@ func TestDnsUpstreamIsAlive(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHttpsUpstreamIsAlive(t *testing.T) {
|
func TestHttpsUpstreamIsAlive(t *testing.T) {
|
||||||
|
|
||||||
var tests = []struct {
|
var tests = []struct {
|
||||||
url string
|
url string
|
||||||
bootstrap string
|
bootstrap string
|
||||||
|
@ -54,7 +52,6 @@ func TestHttpsUpstreamIsAlive(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDnsOverTlsIsAlive(t *testing.T) {
|
func TestDnsOverTlsIsAlive(t *testing.T) {
|
||||||
|
|
||||||
var tests = []struct {
|
var tests = []struct {
|
||||||
url string
|
url string
|
||||||
bootstrap string
|
bootstrap string
|
||||||
|
@ -77,7 +74,6 @@ func TestDnsOverTlsIsAlive(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDnsUpstream(t *testing.T) {
|
func TestDnsUpstream(t *testing.T) {
|
||||||
|
|
||||||
var tests = []struct {
|
var tests = []struct {
|
||||||
url string
|
url string
|
||||||
bootstrap string
|
bootstrap string
|
||||||
|
@ -100,7 +96,6 @@ func TestDnsUpstream(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHttpsUpstream(t *testing.T) {
|
func TestHttpsUpstream(t *testing.T) {
|
||||||
|
|
||||||
var tests = []struct {
|
var tests = []struct {
|
||||||
url string
|
url string
|
||||||
bootstrap string
|
bootstrap string
|
||||||
|
@ -122,7 +117,6 @@ func TestHttpsUpstream(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDnsOverTlsUpstream(t *testing.T) {
|
func TestDnsOverTlsUpstream(t *testing.T) {
|
||||||
|
|
||||||
var tests = []struct {
|
var tests = []struct {
|
||||||
url string
|
url string
|
||||||
bootstrap string
|
bootstrap string
|
||||||
|
@ -154,7 +148,6 @@ func testUpstreamIsAlive(t *testing.T, u Upstream) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testUpstream(t *testing.T, u Upstream) {
|
func testUpstream(t *testing.T, u Upstream) {
|
||||||
|
|
||||||
var tests = []struct {
|
var tests = []struct {
|
||||||
name string
|
name string
|
||||||
expected net.IP
|
expected net.IP
|
||||||
|
|
Loading…
Reference in New Issue