-
Notifications
You must be signed in to change notification settings - Fork 1
/
starti2p.go
52 lines (49 loc) · 1.15 KB
/
starti2p.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"log"
i2cpcheck "github.com/eyedeekay/checki2cp"
"github.com/eyedeekay/go-I2P-jpackage"
tbget "i2pgit.org/idk/i2p.plugins.tor-manager/get"
)
func StartI2P(directory string) (*I2P.Daemon, error) {
if tbget.TestHTTPDefaultProxy() {
log.Println("I2P HTTP proxy OK")
} else {
log.Println("I2P HTTP proxy not OK")
run, err := i2cpcheck.ConditionallyLaunchI2P()
if err != nil {
log.Println("Couldn't launch I2P", err)
}
if run {
if tbget.TestHTTPDefaultProxy() {
log.Println("I2P HTTP proxy OK after launching I2P")
} else {
go proxy()
if !tbget.TestHTTPBackupProxy() {
log.Println("Please set the I2P HTTP proxy on localhost:4444", err)
return nil, err
}
}
} else {
I2Pdaemon, err := I2P.NewDaemon(directory, false)
if err != nil {
log.Println(err)
return nil, err
}
if err = I2Pdaemon.Start(); err != nil {
log.Println(err)
return nil, err
}
shutdown = true
go runSysTray(true)
if tbget.TestHTTPDefaultProxy() {
log.Println("I2P HTTP proxy OK")
} else {
log.Println(err)
return nil, err
}
return I2Pdaemon, nil
}
}
return nil, nil
}