Don't call "bin" what is actually text
This commit is contained in:
parent
d8b1f4e7cd
commit
cef4b041d7
|
@ -146,13 +146,13 @@ func ColdStart(proxy *Proxy) (*CaptivePortalHandler, error) {
|
|||
if len(proxy.captivePortalMapFile) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
bin, err := ReadTextFile(proxy.captivePortalMapFile)
|
||||
lines, err := ReadTextFile(proxy.captivePortalMapFile)
|
||||
if err != nil {
|
||||
dlog.Warn(err)
|
||||
return nil, err
|
||||
}
|
||||
ipsMap := make(CaptivePortalMap)
|
||||
for lineNo, line := range strings.Split(string(bin), "\n") {
|
||||
for lineNo, line := range strings.Split(lines, "\n") {
|
||||
line = TrimAndStripInlineComments(line)
|
||||
if len(line) == 0 {
|
||||
continue
|
||||
|
|
|
@ -906,7 +906,7 @@ func (config *Config) loadSource(proxy *Proxy, cfgSourceName string, cfgSource *
|
|||
cfgSource.Prefix,
|
||||
)
|
||||
if err != nil {
|
||||
if len(source.bin) == 0 {
|
||||
if len(source.bin) <= 0 {
|
||||
dlog.Criticalf("Unable to retrieve source [%s]: [%s]", cfgSourceName, err)
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
)
|
||||
|
||||
func NetProbe(proxy *Proxy, address string, timeout int) error {
|
||||
if len(address) == 0 || timeout == 0 {
|
||||
if len(address) <= 0 || timeout == 0 {
|
||||
return nil
|
||||
}
|
||||
if captivePortalHandler, err := ColdStart(proxy); err == nil {
|
||||
|
|
|
@ -30,13 +30,13 @@ func (plugin *PluginAllowedIP) Description() string {
|
|||
|
||||
func (plugin *PluginAllowedIP) Init(proxy *Proxy) error {
|
||||
dlog.Noticef("Loading the set of allowed IP rules from [%s]", proxy.allowedIPFile)
|
||||
bin, err := ReadTextFile(proxy.allowedIPFile)
|
||||
lines, err := ReadTextFile(proxy.allowedIPFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
plugin.allowedPrefixes = iradix.New()
|
||||
plugin.allowedIPs = make(map[string]interface{})
|
||||
for lineNo, line := range strings.Split(bin, "\n") {
|
||||
for lineNo, line := range strings.Split(lines, "\n") {
|
||||
line = TrimAndStripInlineComments(line)
|
||||
if len(line) == 0 {
|
||||
continue
|
||||
|
|
|
@ -29,13 +29,13 @@ func (plugin *PluginAllowName) Description() string {
|
|||
|
||||
func (plugin *PluginAllowName) Init(proxy *Proxy) error {
|
||||
dlog.Noticef("Loading the set of allowed names from [%s]", proxy.allowNameFile)
|
||||
bin, err := ReadTextFile(proxy.allowNameFile)
|
||||
lines, err := ReadTextFile(proxy.allowNameFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
plugin.allWeeklyRanges = proxy.allWeeklyRanges
|
||||
plugin.patternMatcher = NewPatternMatcher()
|
||||
for lineNo, line := range strings.Split(string(bin), "\n") {
|
||||
for lineNo, line := range strings.Split(lines, "\n") {
|
||||
line = TrimAndStripInlineComments(line)
|
||||
if len(line) == 0 {
|
||||
continue
|
||||
|
|
|
@ -30,13 +30,13 @@ func (plugin *PluginBlockIP) Description() string {
|
|||
|
||||
func (plugin *PluginBlockIP) Init(proxy *Proxy) error {
|
||||
dlog.Noticef("Loading the set of IP blocking rules from [%s]", proxy.blockIPFile)
|
||||
bin, err := ReadTextFile(proxy.blockIPFile)
|
||||
lines, err := ReadTextFile(proxy.blockIPFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
plugin.blockedPrefixes = iradix.New()
|
||||
plugin.blockedIPs = make(map[string]interface{})
|
||||
for lineNo, line := range strings.Split(string(bin), "\n") {
|
||||
for lineNo, line := range strings.Split(lines, "\n") {
|
||||
line = TrimAndStripInlineComments(line)
|
||||
if len(line) == 0 {
|
||||
continue
|
||||
|
|
|
@ -87,7 +87,7 @@ func (plugin *PluginBlockName) Description() string {
|
|||
|
||||
func (plugin *PluginBlockName) Init(proxy *Proxy) error {
|
||||
dlog.Noticef("Loading the set of blocking rules from [%s]", proxy.blockNameFile)
|
||||
bin, err := ReadTextFile(proxy.blockNameFile)
|
||||
lines, err := ReadTextFile(proxy.blockNameFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ func (plugin *PluginBlockName) Init(proxy *Proxy) error {
|
|||
allWeeklyRanges: proxy.allWeeklyRanges,
|
||||
patternMatcher: NewPatternMatcher(),
|
||||
}
|
||||
for lineNo, line := range strings.Split(string(bin), "\n") {
|
||||
for lineNo, line := range strings.Split(lines, "\n") {
|
||||
line = TrimAndStripInlineComments(line)
|
||||
if len(line) == 0 {
|
||||
continue
|
||||
|
|
|
@ -39,7 +39,7 @@ func (plugin *PluginCloak) Description() string {
|
|||
|
||||
func (plugin *PluginCloak) Init(proxy *Proxy) error {
|
||||
dlog.Noticef("Loading the set of cloaking rules from [%s]", proxy.cloakFile)
|
||||
bin, err := ReadTextFile(proxy.cloakFile)
|
||||
lines, err := ReadTextFile(proxy.cloakFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ func (plugin *PluginCloak) Init(proxy *Proxy) error {
|
|||
plugin.createPTR = proxy.cloakedPTR
|
||||
plugin.patternMatcher = NewPatternMatcher()
|
||||
cloakedNames := make(map[string]*CloakedName)
|
||||
for lineNo, line := range strings.Split(bin, "\n") {
|
||||
for lineNo, line := range strings.Split(lines, "\n") {
|
||||
line = TrimAndStripInlineComments(line)
|
||||
if len(line) == 0 {
|
||||
continue
|
||||
|
|
|
@ -29,11 +29,11 @@ func (plugin *PluginForward) Description() string {
|
|||
|
||||
func (plugin *PluginForward) Init(proxy *Proxy) error {
|
||||
dlog.Noticef("Loading the set of forwarding rules from [%s]", proxy.forwardFile)
|
||||
bin, err := ReadTextFile(proxy.forwardFile)
|
||||
lines, err := ReadTextFile(proxy.forwardFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for lineNo, line := range strings.Split(string(bin), "\n") {
|
||||
for lineNo, line := range strings.Split(lines, "\n") {
|
||||
line = TrimAndStripInlineComments(line)
|
||||
if len(line) == 0 {
|
||||
continue
|
||||
|
|
|
@ -127,7 +127,7 @@ func (proxy *Proxy) addDNSListener(listenAddrStr string) {
|
|||
}
|
||||
|
||||
// if 'userName' is not set, continue as before
|
||||
if len(proxy.userName) == 0 {
|
||||
if len(proxy.userName) <= 0 {
|
||||
if err := proxy.udpListenerFromAddr(listenUDPAddr); err != nil {
|
||||
dlog.Fatal(err)
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ func (proxy *Proxy) addLocalDoHListener(listenAddrStr string) {
|
|||
}
|
||||
|
||||
// if 'userName' is not set, continue as before
|
||||
if len(proxy.userName) == 0 {
|
||||
if len(proxy.userName) <= 0 {
|
||||
if err := proxy.localDoHListenerFromAddr(listenTCPAddr); err != nil {
|
||||
dlog.Fatal(err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue