|
4 | 4 | "fmt" |
5 | 5 | "io/ioutil" |
6 | 6 | "path/filepath" |
| 7 | + "regexp" |
7 | 8 |
|
8 | 9 | "github.com/hashicorp/go-multierror" |
9 | 10 | "github.com/naoina/toml" |
@@ -71,6 +72,12 @@ type Server struct { |
71 | 72 | Hostname string `toml:"hostname"` |
72 | 73 | // Port is a server port to listen to |
73 | 74 | Port int `toml:"port"` |
| 75 | + // Bind a specific IP addresses for server |
| 76 | + // "*": bind all IP addresses which is default option |
| 77 | + // localhost or 127.0.0.1 bind a single IPv4 address |
| 78 | + BindAddress string `toml:"bind_address"` |
| 79 | + // Specify path for reverse proxy and only [A-Za-z0-9] |
| 80 | + Path string `toml:"path"` |
74 | 81 | // DataDir is a path to a directory to keep XML feeds and downloaded episodes, |
75 | 82 | // that will be available to user via web server for download. |
76 | 83 | DataDir string `toml:"data_dir"` |
@@ -163,8 +170,15 @@ func (c *Config) validate() error { |
163 | 170 | result = multierror.Append(result, errors.New("data directory is required")) |
164 | 171 | } |
165 | 172 |
|
| 173 | + if c.Server.Path != "" { |
| 174 | + var pathReg = regexp.MustCompile(model.PathRegex) |
| 175 | + if !pathReg.MatchString(c.Server.Path) { |
| 176 | + result = multierror.Append(result, errors.Errorf("Server handle path must be match %s or empty", model.PathRegex)) |
| 177 | + } |
| 178 | + } |
| 179 | + |
166 | 180 | if len(c.Feeds) == 0 { |
167 | | - result = multierror.Append(result, errors.New("at least one feed must be speficied")) |
| 181 | + result = multierror.Append(result, errors.New("at least one feed must be specified")) |
168 | 182 | } |
169 | 183 |
|
170 | 184 | for id, feed := range c.Feeds { |
|
0 commit comments