diff --git a/README.md b/README.md index 6a1cf09..6ae9217 100644 --- a/README.md +++ b/README.md @@ -50,11 +50,16 @@ provided: $ chmod +x onionbox $ ./onionbox -port 8080 -debug - -port : tell onionbox with port to make your onion service remotely - availble on. + -lport : tell onionbox which port to make your onion service locally + run on. + + -rport : tell onionbox which port to make your onion service remotely + available on. -torv3 : tell onionbox to run on torv3 or torv2. + -torrc : utilize a custom Torrc file to run your onion service. + -debug : tell onionbox to print debug logs or silence logs. ``` diff --git a/cmd/onionbox/main.go b/cmd/onionbox/main.go index 97d1901..22f4f4f 100644 --- a/cmd/onionbox/main.go +++ b/cmd/onionbox/main.go @@ -22,7 +22,9 @@ func main() { // Init flags flag.BoolVar(&ob.Debug, "debug", false, "run in debug mode") flag.BoolVar(&ob.TorVersion3, "torv3", true, "use version 3 of the Tor circuit (recommended)") - flag.IntVar(&ob.RemotePort, "port", 80, "remote port used to host the onion service") + flag.IntVar(&ob.RemotePort, "rport", 80, "remote port used to host the onion service") + flag.IntVar(&ob.LocalPort, "lport", 0, "local port used to host the onion service") + flag.StringVar(&ob.TorrcFile, "torrc", "", "provide a custom torrc file for the onion service") flag.Parse() // Wait at most 3 minutes to publish the service diff --git a/onionbox/onionbox.go b/onionbox/onionbox.go index f99af3f..ec786dc 100644 --- a/onionbox/onionbox.go +++ b/onionbox/onionbox.go @@ -29,7 +29,9 @@ const ( type Onionbox struct { OnionURL string RemotePort int + LocalPort int TorVersion3 bool + TorrcFile string Store *onionstore.OnionStore Logger *log.Logger Server *http.Server @@ -47,7 +49,7 @@ func (ob *Onionbox) Init(ctx context.Context) (*tor.Tor, *tor.OnionService, erro if runtime.GOOS != "windows" { lj = &lumberjack.Logger{ Filename: "/var/log/onionbox/onionbox.log", - MaxSize: 100, // megabytes + MaxSize: 10, // megabytes MaxBackups: 3, MaxAge: 28, // days Compress: true, @@ -57,7 +59,7 @@ func (ob *Onionbox) Init(ctx context.Context) (*tor.Tor, *tor.OnionService, erro } else { lj = &lumberjack.Logger{ Filename: "%APPDATA%/Local/onionbox/onionbox.log", - MaxSize: 100, // megabytes + MaxSize: 10, // megabytes MaxBackups: 3, MaxAge: 28, // days Compress: true, @@ -71,7 +73,7 @@ func (ob *Onionbox) Init(ctx context.Context) (*tor.Tor, *tor.OnionService, erro } // Start Tor - t, err := startTor(torLogger) + t, err := ob.startTor(torLogger) if err != nil { return nil, nil, err } @@ -97,7 +99,7 @@ func (ob *Onionbox) Init(ctx context.Context) (*tor.Tor, *tor.OnionService, erro return t, onionSvc, nil } -func startTor(logger io.Writer) (*tor.Tor, error) { +func (ob *Onionbox) startTor(logger io.Writer) (*tor.Tor, error) { fmt.Println("Starting and registering onion service, please wait...") var tempDataDir string @@ -110,9 +112,11 @@ func startTor(logger io.Writer) (*tor.Tor, error) { t, err := tor.Start(nil, &tor.StartConf{ // Start tor ProcessCreator: libtor.Creator, DebugWriter: logger, - UseEmbeddedControlConn: runtime.GOOS != "windows", // This option is not supported on Windows + UseEmbeddedControlConn: true, // Since we are using embedded tor via go-libtor TempDataDirBase: tempDataDir, RetainTempDataDir: false, + TorrcFile: ob.TorrcFile, + NoHush: ob.Debug, }) if err != nil { return nil, err @@ -125,6 +129,7 @@ func (ob *Onionbox) listenTor(ctx context.Context, t *tor.Tor) (*tor.OnionServic onionSvc, err := t.Listen(ctx, &tor.ListenConf{ Version3: ob.TorVersion3, RemotePorts: []int{ob.RemotePort}, + LocalPort: ob.LocalPort, }) if err != nil { return nil, err