mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-03 15:17:25 +00:00
Isn't this just the most beautiful thing you've ever seen?
This commit is contained in:
parent
ebd2e5bf30
commit
e945e65b13
@ -18,6 +18,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
@ -826,6 +827,11 @@ func TestHostCheck(t *testing.T) {
|
||||
|
||||
// This should all work over IPv6 as well
|
||||
|
||||
if runningInContainer() {
|
||||
// Working IPv6 in Docker can't be taken for granted.
|
||||
return
|
||||
}
|
||||
|
||||
cfg = new(mockedConfig)
|
||||
cfg.gui.RawAddress = "[::1]:0"
|
||||
baseURL, err = startHTTP(cfg)
|
||||
@ -1090,3 +1096,24 @@ func equalStrings(a, b []string) bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// runningInContainer returns true if we are inside Docker or LXC. It might
|
||||
// be prone to false negatives if things change in the future, but likely
|
||||
// not false positives.
|
||||
func runningInContainer() bool {
|
||||
if runtime.GOOS != "linux" {
|
||||
return false
|
||||
}
|
||||
|
||||
bs, err := ioutil.ReadFile("/proc/1/cgroup")
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if bytes.Contains(bs, []byte("/docker/")) {
|
||||
return true
|
||||
}
|
||||
if bytes.Contains(bs, []byte("/lxc/")) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user