add http proxy

add http proxy

add proxy code

add proxy
This commit is contained in:
ambitioner
2017-05-19 16:34:03 +08:00
parent 716ec281f6
commit d1f5ec083a
3 changed files with 236 additions and 0 deletions

View File

@ -0,0 +1,32 @@
package proxy
import (
"bufio"
"encoding/json"
"os"
)
// Config 保存代理服务器的配置
type Config struct {
Port string `json:"port"`
Auth bool `json:"auth"`
User map[string]string `json:"user"`
}
// 从指定json文件读取config配置
func (c *Config) GetConfig(filename string) error {
configFile, err := os.Open(filename)
if err != nil {
return err
}
defer configFile.Close()
br := bufio.NewReader(configFile)
err = json.NewDecoder(br).Decode(c)
if err != nil {
return err
}
return nil
}