chromeworker/proxyserver/config.go
2020-11-27 15:57:24 +08:00

49 lines
772 B
Go

package main
import (
"os"
"os/exec"
"gopkg.in/yaml.v2"
)
var config = &LocalConfig{}
func init() {
f, err := os.Open("config.yaml")
if err != nil {
panic(err)
}
dec := yaml.NewDecoder(f)
err = dec.Decode(config)
if err != nil {
panic(err)
}
}
// LocalConfig 本地yaml配置对象
type LocalConfig struct {
Server struct {
URI string `yaml:"uri"`
} `yaml:"server"`
ChromeProxy struct {
Host string `yaml:"host"`
} `yaml:"chromeproxy"`
}
func initChromeProxy() {
err := exec.Command("google-chrome",
"http://eson.config?taskurl="+config.ChromeProxy.Host,
"--user-data-dir=/tmp/chromeproxy-userdata",
).Run()
if err != nil {
panic(err)
}
}
// ChromeConfig chrome的配置, 包括代理
type ChromeConfig struct {
PacScript string
}