Skip to content

Commit ae2800d

Browse files
committed
Listen on IPv4 and IPv6 by default
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
1 parent ac1cc23 commit ae2800d

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ As previously noted, Clipper supports a number of command line options, which yo
158158
```
159159
Usage of ./clipper:
160160
-a string
161-
address to bind to (shorthand) (default "127.0.0.1")
161+
address to bind to (shorthand)
162162
-address string
163-
address to bind to (default "127.0.0.1")
163+
address to bind to
164164
-c string
165165
path to (JSON) config file (shorthand) (default "~/.clipper.json")
166166
-config string
@@ -442,6 +442,8 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
442442
## master (not yet released)
443443

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

446448
## 0.3 (3 June 2016)
447449

clipper.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func initFlags() {
8686
}
8787

8888
func setDefaults() {
89-
defaults.Address = "127.0.0.1"
89+
defaults.Address = "" // IPv4/IPv6 loopback.
9090
defaults.Port = 8377
9191

9292
if runtime.GOOS == "linux" {
@@ -224,11 +224,15 @@ func main() {
224224
addr = settings.Address
225225
}
226226
if strings.HasPrefix(addr, "/") {
227-
log.Print("Starting UNIX domain socket server at ", addr)
228227
listenType = "unix"
228+
log.Print("Starting UNIX domain socket server at ", addr)
229229
} else {
230-
log.Print("Starting TCP server on ", addr)
231230
listenType = "tcp"
231+
if addr == "" {
232+
log.Print("Starting TCP server on loopback interface")
233+
} else {
234+
log.Print("Starting TCP server on ", addr)
235+
}
232236
addr = fmt.Sprintf("%s:%d", settings.Address, settings.Port)
233237
}
234238
listener, err := net.Listen(listenType, addr)

0 commit comments

Comments
 (0)