diff --git a/README.md b/README.md index ce7f798..4145955 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,3 @@ other than a couple layout tweaks, it adds the following features: * route network traffic through a socks5 proxy if you want to run it for yourself, see INSTALL file for r's original instructions. -
you probably don't have a socks proxy running on port 8080 on your local machine, so comment out lines 41-45 in main.go or set the url on line 41 to a valid proxy url. \ No newline at end of file diff --git a/bloat.conf b/bloat.conf index dd77875..74067b4 100644 --- a/bloat.conf +++ b/bloat.conf @@ -50,3 +50,7 @@ post_formats=PlainText:text/plain,HTML:text/html,Markdown:text/markdown,BBCode:t # Path to custom CSS. Value can be a file path relative to the static directory. # or a URL starting with either "http://" or "https://". # custom_css=custom.css + +# SOCKS5 proxy URL +# example works for tor default, change as needed +# proxy_url=socks5://127.0.0.1:9050 \ No newline at end of file diff --git a/config/config.go b/config/config.go index 8678f52..2353338 100644 --- a/config/config.go +++ b/config/config.go @@ -22,6 +22,7 @@ type config struct { CustomCSS string PostFormats []model.PostFormat LogFile string + ProxyUrl *string } func (c *config) IsValid() bool { @@ -100,6 +101,8 @@ func Parse(r io.Reader) (c *config, err error) { c.PostFormats = formats case "log_file": c.LogFile = val + case "proxy_url": + c.ProxyUrl = &val default: return nil, errors.New("invalid config key " + key) } diff --git a/main.go b/main.go index 5c08440..056ac36 100644 --- a/main.go +++ b/main.go @@ -28,7 +28,7 @@ func errExit(err error) { os.Exit(1) } -func setupHttp() { +func setupHttp(proxyUrl *string) { tr := http.DefaultTransport.(*http.Transport) tr.MaxIdleConnsPerHost = 30 tr.MaxIdleConns = 300 @@ -38,11 +38,13 @@ func setupHttp() { KeepAlive: 3 * time.Minute, DualStack: true, }).DialContext - proxyUrl, err := url.Parse("socks5://127.0.0.1:8080") - if err != nil { - log.Fatalln(err) + if proxyUrl != nil { + proxyUrl, err := url.Parse(*proxyUrl) + if err != nil { + log.Fatalln(err) + } + tr.Proxy = http.ProxyURL(proxyUrl) } - tr.Proxy = http.ProxyURL(proxyUrl) client := http.DefaultClient client.Transport = tr } @@ -114,7 +116,7 @@ func main() { logger = log.New(lf, "", log.LstdFlags) } - setupHttp() + setupHttp(config.ProxyUrl) s := service.NewService(config.ClientName, config.ClientScope, config.ClientWebsite, customCSS, config.PostFormats, renderer,