mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 17:38:41 +00:00
v1.0.0
This commit is contained in:
parent
47d23e9972
commit
c7f7c08ead
711 changed files with 82154 additions and 2 deletions
34
main/confloader/confloader.go
Normal file
34
main/confloader/confloader.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
package confloader
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
type configFileLoader func(string) (io.Reader, error)
|
||||
type extconfigLoader func([]string, io.Reader) (io.Reader, error)
|
||||
|
||||
var (
|
||||
EffectiveConfigFileLoader configFileLoader
|
||||
EffectiveExtConfigLoader extconfigLoader
|
||||
)
|
||||
|
||||
// LoadConfig reads from a path/url/stdin
|
||||
// actual work is in external module
|
||||
func LoadConfig(file string) (io.Reader, error) {
|
||||
if EffectiveConfigFileLoader == nil {
|
||||
newError("external config module not loaded, reading from stdin").AtInfo().WriteToLog()
|
||||
return os.Stdin, nil
|
||||
}
|
||||
return EffectiveConfigFileLoader(file)
|
||||
}
|
||||
|
||||
// LoadExtConfig calls xctl to handle multiple config
|
||||
// the actual work also in external module
|
||||
func LoadExtConfig(files []string, reader io.Reader) (io.Reader, error) {
|
||||
if EffectiveExtConfigLoader == nil {
|
||||
return nil, newError("external config module not loaded").AtError()
|
||||
}
|
||||
|
||||
return EffectiveExtConfigLoader(files, reader)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue