Skip to content

Commit

Permalink
Listen on IPv4 and IPv6 by default
Browse files Browse the repository at this point in the history
As noted [here](golang/go#9334 (comment)), the "correct way" to listen on both IPv4 and IPv6 loopback interfaces is to omit the address part.

Closes: #2

And will also close: wincent/vim-clipper#1
  • Loading branch information
wincent committed Nov 29, 2016
1 parent ac1cc23 commit ae2800d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ As previously noted, Clipper supports a number of command line options, which yo
```
Usage of ./clipper:
-a string
address to bind to (shorthand) (default "127.0.0.1")
address to bind to (shorthand)
-address string
address to bind to (default "127.0.0.1")
address to bind to
-c string
path to (JSON) config file (shorthand) (default "~/.clipper.json")
-config string
Expand Down Expand Up @@ -442,6 +442,8 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
## master (not yet released)

- Linux support via `xclip` instead of `pbcopy` (patch from Nelson Fernandez).
- Added `--executable` and `--flags` options.
- On dual-stack systems, listen on both IPv4 and IPv6 loopback interfaces by default.

## 0.3 (3 June 2016)

Expand Down
10 changes: 7 additions & 3 deletions clipper.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func initFlags() {
}

func setDefaults() {
defaults.Address = "127.0.0.1"
defaults.Address = "" // IPv4/IPv6 loopback.
defaults.Port = 8377

if runtime.GOOS == "linux" {
Expand Down Expand Up @@ -224,11 +224,15 @@ func main() {
addr = settings.Address
}
if strings.HasPrefix(addr, "/") {
log.Print("Starting UNIX domain socket server at ", addr)
listenType = "unix"
log.Print("Starting UNIX domain socket server at ", addr)
} else {
log.Print("Starting TCP server on ", addr)
listenType = "tcp"
if addr == "" {
log.Print("Starting TCP server on loopback interface")
} else {
log.Print("Starting TCP server on ", addr)
}
addr = fmt.Sprintf("%s:%d", settings.Address, settings.Port)
}
listener, err := net.Listen(listenType, addr)
Expand Down

0 comments on commit ae2800d

Please sign in to comment.