소스 검색

feature(worker): added worker http server config

bigeagle 9 년 전
부모
커밋
8b56fda1e9
2개의 변경된 파일17개의 추가작업 그리고 0개의 파일을 삭제
  1. 9 0
      worker/config.go
  2. 8 0
      worker/config_test.go

+ 9 - 0
worker/config.go

@@ -49,6 +49,7 @@ func (p *ProviderEnum) UnmarshalText(text []byte) error {
 type Config struct {
 	Global  globalConfig   `toml:"global"`
 	Manager managerConfig  `toml:"manager"`
+	Server  serverConfig   `toml:"server"`
 	Mirrors []mirrorConfig `toml:"mirrors"`
 }
 
@@ -66,6 +67,14 @@ type managerConfig struct {
 	Token   string `toml:"token"`
 }
 
+type serverConfig struct {
+	Hostname string `toml:"hostname"`
+	Addr     string `toml:"listen_addr"`
+	Port     int    `toml:"listen_port"`
+	SSLCert  string `toml:"ssl_cert"`
+	SSLKey   string `toml:"ssl_key"`
+}
+
 type mirrorConfig struct {
 	Name      string            `toml:"name"`
 	Provider  ProviderEnum      `toml:"provider"`

+ 8 - 0
worker/config_test.go

@@ -21,6 +21,13 @@ interval = 240
 api_base = "https://127.0.0.1:5000"
 token = "some_token"
 
+[server]
+hostname = "worker1.example.com"
+listen_addr = "127.0.0.1"
+listen_port = 6000
+ssl_cert = "/etc/tunasync.d/worker1.cert"
+ssl_key = "/etc/tunasync.d/worker1.key"
+
 [[mirrors]]
 name = "AOSP"
 provider = "command"
@@ -68,6 +75,7 @@ exclude_file = "/etc/tunasync.d/fedora-exclude.txt"
 		So(cfg.Global.MirrorDir, ShouldEqual, "/data/mirrors")
 
 		So(cfg.Manager.APIBase, ShouldEqual, "https://127.0.0.1:5000")
+		So(cfg.Server.Hostname, ShouldEqual, "worker1.example.com")
 
 		m := cfg.Mirrors[0]
 		So(m.Name, ShouldEqual, "AOSP")