mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-03 15:00:26 +08:00
阶段性提交
This commit is contained in:
28
internal/configs/api_config.go
Normal file
28
internal/configs/api_config.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package configs
|
||||
|
||||
import (
|
||||
"github.com/go-yaml/yaml"
|
||||
"github.com/iwind/TeaGo/Tea"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
type APIConfig struct {
|
||||
RPC struct {
|
||||
Endpoints []string `yaml:"endpoints"`
|
||||
} `yaml:"rpc"`
|
||||
}
|
||||
|
||||
func LoadAPIConfig() (*APIConfig, error) {
|
||||
data, err := ioutil.ReadFile(Tea.ConfigFile("api.yaml"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
config := &APIConfig{}
|
||||
err = yaml.Unmarshal(data, config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return config, nil
|
||||
}
|
||||
11
internal/configs/api_config_test.go
Normal file
11
internal/configs/api_config_test.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package configs
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestLoadAPIConfig(t *testing.T) {
|
||||
config, err := LoadAPIConfig()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(config)
|
||||
}
|
||||
4
internal/configs/filter_config.go
Normal file
4
internal/configs/filter_config.go
Normal file
@@ -0,0 +1,4 @@
|
||||
package configs
|
||||
|
||||
type FilterConfig struct {
|
||||
}
|
||||
@@ -4,6 +4,7 @@ type ServerConfig struct {
|
||||
Id string `yaml:"id"` // ID
|
||||
IsOn bool `yaml:"isOn"` // 是否开启
|
||||
Components []*ComponentConfig `yaml:"components"` // 组件
|
||||
Filters []*FilterConfig `yaml:"filters"` // 过滤器
|
||||
Name string `yaml:"name"` // 名称
|
||||
Description string `yaml:"description"` // 描述
|
||||
ServerNames []string `yaml:"serverNames"` // 域名
|
||||
|
||||
Reference in New Issue
Block a user