chromeworker/proxyserver/config.go

49 lines
772 B
Go
Raw Normal View History

2020-11-20 10:24:42 +00:00
package main
import (
"os"
"os/exec"
"gopkg.in/yaml.v2"
)
2020-11-27 07:57:24 +00:00
var config = &LocalConfig{}
2020-11-20 10:24:42 +00:00
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)
}
}
2020-11-27 07:57:24 +00:00
// LocalConfig 本地yaml配置对象
type LocalConfig struct {
2020-11-20 10:24:42 +00:00
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)
}
}
2020-11-27 07:57:24 +00:00
// ChromeConfig chrome的配置, 包括代理
type ChromeConfig struct {
PacScript string
}