TODO: 测试稳定性.

This commit is contained in:
eson
2020-11-20 18:24:42 +08:00
parent 94b01ccb0f
commit 4bf8705a8d
7 changed files with 76 additions and 6 deletions

43
proxyserver/config.go Normal file
View File

@@ -0,0 +1,43 @@
package main
import (
"os"
"os/exec"
"gopkg.in/yaml.v2"
)
var config = &Config{}
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)
}
}
// Config 本地yaml配置对象
type Config 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)
}
}

5
proxyserver/config.yaml Normal file
View File

@@ -0,0 +1,5 @@
server:
uri: "0.0.0.0:7123"
chromeproxy:
host: "http://localhost:7123"

View File

@@ -16,5 +16,5 @@ require (
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9 // indirect
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 // indirect
google.golang.org/protobuf v1.25.0 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
gopkg.in/yaml.v2 v2.3.0
)

View File

@@ -1,10 +1,12 @@
package main
import "github.com/gin-gonic/gin"
import (
"github.com/gin-gonic/gin"
)
var engine = gin.New()
func main() {
engine.Run(":7123")
initChromeProxy()
engine.Run(config.Server.URI)
}