From 30215d6637fb689cfc5f35e262f92d66726577f1 Mon Sep 17 00:00:00 2001 From: ymmt2005 Date: Thu, 1 Sep 2016 23:21:27 +0900 Subject: [PATCH] Set the default listen address to "localhost:1081". --- CHANGELOG.md | 1 + README.md | 5 ++--- cmd/transocks/main.go | 8 +++++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42f17a8..f12185b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file. ### Changed - The default configuration file path is now `/etc/transocks.toml`. +- "listen" config option becomes optional. Default is "localhost:1081". - Configuration items for logging is changed. [cmd]: https://github.com/cybozu-go/cmd diff --git a/README.md b/README.md index 245bda8..ad37995 100644 --- a/README.md +++ b/README.md @@ -66,12 +66,11 @@ Configuration file format `transocks.toml` is a [TOML][] file. -`listen` and `proxy_url` are mandatory. -Other items are optional. +`proxy_url` are mandatory. Other items are optional. ``` # listening address of transocks. -listen = "localhost:1081" +listen = "localhost:1081" # default is "localhost:1081" proxy_url = "socks5://10.20.30.40:1080" # for SOCKS5 server #proxy_url = "http://10.20.30.40:3128" # for HTTP proxy server diff --git a/cmd/transocks/main.go b/cmd/transocks/main.go index 5370503..2b0cbc8 100644 --- a/cmd/transocks/main.go +++ b/cmd/transocks/main.go @@ -18,13 +18,19 @@ type tomlConfig struct { Log cmd.LogConfig `toml:"log"` } +const ( + defaultAddr = "localhost:1081" +) + var ( configFile = flag.String("f", "/etc/transocks.toml", "TOML configuration file path") ) func loadConfig() (*transocks.Config, error) { - tc := new(tomlConfig) + tc := &tomlConfig{ + Listen: defaultAddr, + } md, err := toml.DecodeFile(*configFile, tc) if err != nil { return nil, err