2020-04-21 12:16:28 +07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"io/ioutil"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Config struct {
|
|
|
|
Targets []checkTarget
|
2020-04-23 07:42:16 +07:00
|
|
|
Port int
|
2020-04-21 12:16:28 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
func ReadConfig(file string) (Config, error) {
|
|
|
|
bytes, err := ioutil.ReadFile(file)
|
|
|
|
if err != nil {
|
|
|
|
return Config{}, err
|
|
|
|
}
|
|
|
|
var result Config
|
2020-04-23 08:23:21 +07:00
|
|
|
err = json.Unmarshal(bytes, &result)
|
|
|
|
return result, err
|
2020-04-21 12:16:28 +07:00
|
|
|
}
|