Commit 99133f53 authored by Frank Denis's avatar Frank Denis

Skip BOMs in configuration files

Fixes #613
parent 4192e2ff
package main
import (
"bytes"
"encoding/binary"
"errors"
"fmt"
"io/ioutil"
"net"
"os"
"runtime"
"strconv"
"strings"
"unicode"
"os"
)
type CryptoConstruction uint16
......@@ -38,7 +40,7 @@ var (
)
var (
FileDescriptors = make([]*os.File, 0)
FileDescriptors = make([]*os.File, 0)
FileDescriptorNum = 0
)
......@@ -170,3 +172,12 @@ func MemUsage() {
fmt.Printf("\tSys = %v MiB", m.Sys/1024/1024)
fmt.Printf("\tNumGC = %v\n", m.NumGC)
}
func ReadTextFile(filename string) (string, error) {
bin, err := ioutil.ReadFile(filename)
if err != nil {
return "", err
}
bin = bytes.TrimPrefix(bin, []byte{0xef, 0xbb, 0xbf})
return string(bin), nil
}
......@@ -3,7 +3,6 @@ package main
import (
"errors"
"fmt"
"io/ioutil"
"net"
"strings"
"time"
......@@ -32,7 +31,7 @@ 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 := ioutil.ReadFile(proxy.blockIPFile)
bin, err := ReadTextFile(proxy.blockIPFile)
if err != nil {
return err
}
......
......@@ -3,7 +3,6 @@ package main
import (
"errors"
"fmt"
"io/ioutil"
"net"
"strings"
"time"
......@@ -31,7 +30,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 := ioutil.ReadFile(proxy.blockNameFile)
bin, err := ReadTextFile(proxy.blockNameFile)
if err != nil {
return err
}
......
package main
import (
"io/ioutil"
"net"
"strings"
"sync"
......@@ -36,7 +35,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 := ioutil.ReadFile(proxy.cloakFile)
bin, err := ReadTextFile(proxy.cloakFile)
if err != nil {
return err
}
......
......@@ -2,7 +2,6 @@ package main
import (
"fmt"
"io/ioutil"
"math/rand"
"net"
"strings"
......@@ -31,7 +30,7 @@ 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 := ioutil.ReadFile(proxy.forwardFile)
bin, err := ReadTextFile(proxy.forwardFile)
if err != nil {
return err
}
......
......@@ -3,7 +3,6 @@ package main
import (
"errors"
"fmt"
"io/ioutil"
"net"
"strings"
"time"
......@@ -31,7 +30,7 @@ func (plugin *PluginWhitelistName) Description() string {
func (plugin *PluginWhitelistName) Init(proxy *Proxy) error {
dlog.Noticef("Loading the set of whitelisting rules from [%s]", proxy.whitelistNameFile)
bin, err := ioutil.ReadFile(proxy.whitelistNameFile)
bin, err := ReadTextFile(proxy.whitelistNameFile)
if err != nil {
return err
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment