Bail if Tor is already running too

This commit is contained in:
idk
2022-01-22 01:13:30 -05:00
parent 7ca1ace12d
commit fe187dba30
2 changed files with 6 additions and 0 deletions

View File

@ -71,6 +71,7 @@ func (m *Client) ServeHTTP(rw http.ResponseWriter, rq *http.Request) {
func (m *Client) Serve() error {
//http.Handle("/", m)
go m.TBS.RunTorWithLang()
return http.ListenAndServe("127.0.0.1:7695", m)
}

View File

@ -3,6 +3,7 @@ package tbsupervise
import (
"fmt"
"log"
"net"
"os"
"os/exec"
"path/filepath"
@ -153,6 +154,10 @@ func (s *Supervisor) RunI2PBWithLang() error {
}
func (s *Supervisor) torbail() error {
_, err := net.Listen("TCP", "127.0.0.1:9050")
if err != nil {
return fmt.Errorf("Already running")
}
if s.torcmd != nil && s.torcmd.Process != nil && s.torcmd.ProcessState != nil {
if s.torcmd.ProcessState.Exited() {
return nil