add socks proxy url to config file
This commit is contained in:
parent
7071165d04
commit
6b51cbed6c
|
@ -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.
|
||||
<br>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.
|
|
@ -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
|
|
@ -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)
|
||||
}
|
||||
|
|
8
main.go
8
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 proxyUrl != nil {
|
||||
proxyUrl, err := url.Parse(*proxyUrl)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
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,
|
||||
|
|
Loading…
Reference in New Issue