mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-12-27 12:35:21 -05:00
Convert point server config to interface for testibility
This commit is contained in:
@@ -3,10 +3,9 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/v2ray/v2ray-core"
|
||||
jsonconf "github.com/v2ray/v2ray-core/io/config/json"
|
||||
"github.com/v2ray/v2ray-core/log"
|
||||
|
||||
// The following are neccesary as they register handlers in their init functions.
|
||||
@@ -44,24 +43,12 @@ func main() {
|
||||
if configFile == nil || len(*configFile) == 0 {
|
||||
panic(log.Error("Config file is not set."))
|
||||
}
|
||||
rawVConfig, err := ioutil.ReadFile(*configFile)
|
||||
config, err := jsonconf.LoadConfig(*configFile)
|
||||
if err != nil {
|
||||
panic(log.Error("Failed to read config file (%s): %v", *configFile, err))
|
||||
}
|
||||
vconfig, err := core.LoadConfig(rawVConfig)
|
||||
if err != nil {
|
||||
panic(log.Error("Failed to parse Config: %v", err))
|
||||
}
|
||||
|
||||
if !filepath.IsAbs(vconfig.InboundConfig.File) && len(vconfig.InboundConfig.File) > 0 {
|
||||
vconfig.InboundConfig.File = filepath.Join(filepath.Dir(*configFile), vconfig.InboundConfig.File)
|
||||
}
|
||||
|
||||
if !filepath.IsAbs(vconfig.OutboundConfig.File) && len(vconfig.OutboundConfig.File) > 0 {
|
||||
vconfig.OutboundConfig.File = filepath.Join(filepath.Dir(*configFile), vconfig.OutboundConfig.File)
|
||||
}
|
||||
|
||||
vPoint, err := core.NewPoint(vconfig)
|
||||
vPoint, err := core.NewPoint(config)
|
||||
if err != nil {
|
||||
panic(log.Error("Failed to create Point server: %v", err))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user