From b2f10dbf50c41c8ace5379e93680acde698634df Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Wed, 5 Apr 2017 22:07:31 -0700 Subject: [PATCH] server: remove tor for now :( --- server/server.go | 14 +-------- server/tor.go | 80 ------------------------------------------------ 2 files changed, 1 insertion(+), 93 deletions(-) delete mode 100644 server/tor.go diff --git a/server/server.go b/server/server.go index 6c7319e..a270361 100644 --- a/server/server.go +++ b/server/server.go @@ -77,16 +77,6 @@ func New(cfg Config) (*Server, error) { return nil, err } - t, err := StartTor(TorConfig{ - DataDir: cfg.TorDataDir, - HashedControlPassword: cfg.TorHashedPassword, - ClearPassword: cfg.TorPassword, - Timeout: 30 * time.Second, - }) - if err != nil { - return nil, err - } - rpcs := rpc.NewServer() s := &Server{ @@ -148,9 +138,7 @@ func (s *Server) onionPath(name string) string { return filepath.Join(s.cfg.TorDataDir, name) } -func (s *Server) Director(r *http.Request) { - -} +func (s *Server) Director(r *http.Request) {} func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { r.Header.Del("X-Forwarded-For") diff --git a/server/tor.go b/server/tor.go deleted file mode 100644 index 013c5b0..0000000 --- a/server/tor.go +++ /dev/null @@ -1,80 +0,0 @@ -package server - -import ( - "crypto/rsa" - "log" - "math/rand" - "strconv" - "time" - - "github.com/Yawning/bulb" - "github.com/sycamoreone/orc/tor" -) - -// TorConfig is a wrapper struct for tor configuration. -type TorConfig struct { - DataDir string - HashedControlPassword string - ClearPassword string - Timeout time.Duration -} - -// StartTor starts a new instance of tor or doesn't with the reason why. -func StartTor(cfg TorConfig) (*Tor, error) { - tc := tor.NewConfig() - tc.Set("DataDirectory", cfg.DataDir) - tc.Set("HashedControlPassword", cfg.HashedControlPassword) - tc.Set("SocksPort", "0") - cp := rand.Intn(64512) - tc.Set("ControlPort", cp) - tc.Timeout = cfg.Timeout - - tcmd, err := tor.NewCmd(tc) - if err != nil { - return nil, err - } - - err = tcmd.Start() - if err != nil { - return nil, err - } - - log.Println("tor started, sleeping for a few seconds for it to settle...") - time.Sleep(5 * time.Second) - - bc, err := bulb.Dial("tcp", "127.0.0.1:"+strconv.Itoa(cp)) - if err != nil { - return nil, err - } - - err = bc.Authenticate(cfg.ClearPassword) - if err != nil { - return nil, err - } - - t := &Tor{ - tc: tc, - tcmd: tcmd, - bc: bc, - } - - return t, nil -} - -// Tor is a higher level wrapper to a child tor process -type Tor struct { - tc *tor.Config - tcmd *tor.Cmd - bc *bulb.Conn -} - -// AddOnion adds an onion service to this machine with the given private key -// (can be nil for an auto-generated key), virtual onion port and TCP destunation. -func (t *Tor) AddOnion(pKey *rsa.PrivateKey, virtPort uint16, destination string) (*bulb.OnionInfo, error) { - return t.bc.AddOnion([]bulb.OnionPortSpec{ - { - VirtPort: virtPort, - Target: destination, - }, - }, pKey, true) -}