TODO: 测试稳定性.
This commit is contained in:
43
proxyserver/config.go
Normal file
43
proxyserver/config.go
Normal 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
5
proxyserver/config.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
server:
|
||||
uri: "0.0.0.0:7123"
|
||||
chromeproxy:
|
||||
host: "http://localhost:7123"
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user