forked from tslocum/twins
Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
|
c026f5c7b1 | |
|
668e099ffa | |
|
066fe276eb |
|
@ -10,14 +10,19 @@ via the `--config` argument.
|
|||
|
||||
Address to listen for connections on in the format of `interface:port`.
|
||||
|
||||
### Listen on localhost
|
||||
|
||||
`localhost:1965`
|
||||
|
||||
### Listen on all interfaces
|
||||
### Listen on all addresses (IPv4 and IPv6)
|
||||
|
||||
`:1965`
|
||||
|
||||
### Listen on a specific address (IPv4 or IPv6)
|
||||
|
||||
`192.0.2.1:1965` or `"[2001:db8::1]:1965"` (please note the quotes and brackets
|
||||
for IPv6 addresses).
|
||||
|
||||
### Listen on localhost (IPv4 only)
|
||||
|
||||
`localhost:1965`
|
||||
|
||||
## Types
|
||||
|
||||
Content types may be defined by file extension. When a type is not defined for
|
||||
|
|
|
@ -127,13 +127,13 @@ func readconfig(configPath string) error {
|
|||
newLine = "\r\n"
|
||||
}
|
||||
|
||||
split := strings.Split(config.Listen, ":")
|
||||
if len(split) != 2 {
|
||||
listenRe := regexp.MustCompile("(.*):([0-9]+)$")
|
||||
if !listenRe.MatchString(config.Listen) {
|
||||
config.hostname = config.Listen
|
||||
config.Listen += ":1965"
|
||||
} else {
|
||||
config.hostname = split[0]
|
||||
config.port, err = strconv.Atoi(split[1])
|
||||
config.hostname = listenRe.ReplaceAllString(config.Listen, "$1")
|
||||
config.port, err = strconv.Atoi(listenRe.ReplaceAllString(config.Listen, "$2"))
|
||||
if err != nil {
|
||||
log.Fatalf("invalid port specified: %s", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue