守护进程 负载均衡

This commit is contained in:
刘河
2019-02-03 00:54:43 +08:00
parent 662a799f02
commit da899fd3db
20 changed files with 341 additions and 129 deletions

View File

@@ -3,7 +3,6 @@ package utils
import (
"encoding/base64"
"io/ioutil"
"log"
"net"
"net/http"
"os"
@@ -38,7 +37,6 @@ WWW-Authenticate: Basic realm="easyProxy"
`
)
//判断压缩方式
func GetCompressType(compress string) (int, int) {
switch compress {
@@ -47,7 +45,7 @@ func GetCompressType(compress string) (int, int) {
case "snappy":
return COMPRESS_SNAPY_DECODE, COMPRESS_SNAPY_ENCODE
default:
log.Fatalln("数据压缩格式错误")
Fatalln("数据压缩格式错误")
}
return COMPRESS_NONE_DECODE, COMPRESS_NONE_ENCODE
}
@@ -127,7 +125,6 @@ func Getverifyval(vkey string) string {
return Md5(vkey)
}
func ChangeHostAndHeader(r *http.Request, host string, header string, addr string) {
if host != "" {
r.Host = host
@@ -153,3 +150,14 @@ func ReadAllFromFile(filePath string) ([]byte, error) {
}
return ioutil.ReadAll(f)
}
// FileExists reports whether the named file or directory exists.
func FileExists(name string) bool {
if _, err := os.Stat(name); err != nil {
if os.IsNotExist(err) {
return false
}
}
return true
}