Embed an i2pd router, and launch it as a last resort.

This commit is contained in:
idk
2022-02-13 02:19:46 -05:00
parent 9e9e63d215
commit 35f8586bf3
3 changed files with 42 additions and 5 deletions

20
i2pd.go Normal file
View File

@ -0,0 +1,20 @@
//go:build i2pd
// +build i2pd
package main
import (
i2pd "github.com/eyedeekay/go-i2pd/goi2pd"
)
func InitI2PSAM() func() {
return i2pd.InitI2PSAM()
}
func StartI2P() {
i2pd.StartI2P()
}
func StopI2P() {
defer i2pd.StopI2P()
}

View File

@ -16,8 +16,6 @@ import (
"github.com/itchio/headway/state"
tbget "i2pgit.org/idk/i2p.plugins.tor-manager/get"
tbserve "i2pgit.org/idk/i2p.plugins.tor-manager/serve"
i2pd "github.com/eyedeekay/go-i2pd/goi2pd"
)
/*
@ -166,11 +164,11 @@ func main() {
}
} else {
log.Fatal("Failed to run I2P", err)
closer := i2pd.InitI2PSAM()
closer := InitI2PSAM()
defer closer()
go i2pd.StartI2P()
go StartI2P()
//time.Sleep(time.Hour)
defer i2pd.StopI2P()
defer StopI2P()
//TODO: Link libi2pd and start our own router if we cant find one anywhere.
//TODO: loop again until TestHTTPDefaultProxy is up
}

19
no-i2pd.go Normal file
View File

@ -0,0 +1,19 @@
//go:build !i2pd
// +build !i2pd
package main
func InitI2PSAM() func() {
return nullFunc
}
func nullFunc() {
}
func StartI2P() {
}
func StopI2P() {
}