File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99 "os"
1010 "strconv"
1111
12+ "github.com/libp2p/go-libp2p/p2p/host/eventbus"
13+
1214 "github.com/anywherelan/awl"
1315 "github.com/anywherelan/awl/config"
1416 "github.com/anywherelan/awl/vpn"
@@ -21,16 +23,33 @@ var (
2123
2224// All public functions are part of the library
2325
24- func InitServer (dataDir string , tunFD int32 ) (err error ) {
26+ func Setup (dataDir string ) {
27+ globalDataDir = dataDir
28+ _ = os .Setenv (config .AppDataDirEnvKey , dataDir )
29+ }
30+
31+ func GetConfig () string {
32+ if globalDataDir == "" {
33+ panic ("call to GetConfig before Setup" )
34+ }
35+
36+ conf , loadConfigErr := config .LoadConfig (eventbus .NewBus ())
37+ if loadConfigErr != nil {
38+ conf = config .NewConfig (eventbus .NewBus ())
39+ }
40+
41+ data := conf .Export ()
42+ return string (data )
43+ }
44+
45+ func StartServer (tunFD int32 ) (err error ) {
2546 defer func () {
2647 recovered := recover ()
2748 if recovered != nil {
2849 err = fmt .Errorf ("recovered panic from InitServer: %v" , recovered )
2950 }
3051 }()
3152
32- globalDataDir = dataDir
33- _ = os .Setenv (config .AppDataDirEnvKey , dataDir )
3453 _ = os .Setenv (vpn .TunFDEnvKey , strconv .Itoa (int (tunFD )))
3554
3655 globalApp = awl .New ()
You can’t perform that action at this time.
0 commit comments