Skip to content

Commit 0e7c790

Browse files
authored
Merge pull request #85 from arangodb-helper/disable-ipv6
Support disabling IPv6 notation
2 parents 0bdd85a + 850c544 commit 0e7c790

File tree

7 files changed

+95
-3
lines changed

7 files changed

+95
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Changes from version 0.9.1 to 0.9.2
2+
3+
- Added `--starter.disable-ipv6` option to cope with environments
4+
where IPv6 is actively disabled.
5+
16
# Changes from version 0.9.0 to 0.9.1
27

38
- Update to go 1.9.0

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,14 @@ the other servers are derived from this number.
383383
This is the port used for communication of the `arangodb` instances
384384
amongst each other.
385385

386+
* `--starter.disable-ipv6=bool`
387+
388+
if disabled, the starter will configure the `arangod` servers
389+
to bind to address `0.0.0.0` (all IPv4 interfaces)
390+
instead of binding to `[::]` (all IPv4 and all IPv6 interfaces).
391+
392+
This is useful when IPv6 has actively been disabled on your machine.
393+
386394
* `--server.arangod=path`
387395

388396
path to the `arangod` executable (default varies from platform to

main.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ import (
3535
"syscall"
3636
"time"
3737

38-
_ "github.com/arangodb-helper/arangodb/client"
39-
service "github.com/arangodb-helper/arangodb/service"
4038
homedir "github.com/mitchellh/go-homedir"
4139
logging "github.com/op/go-logging"
4240
"github.com/pkg/errors"
4341
"github.com/spf13/cobra"
4442
"github.com/spf13/pflag"
43+
44+
_ "github.com/arangodb-helper/arangodb/client"
45+
"github.com/arangodb-helper/arangodb/pkg/net"
46+
service "github.com/arangodb-helper/arangodb/service"
4547
)
4648

4749
// Configuration data with defaults:
@@ -86,6 +88,7 @@ var (
8688
sslAutoOrganization string
8789
sslCAFile string
8890
rocksDBEncryptionKeyFile string
91+
disableIPv6 bool
8992
dockerEndpoint string
9093
dockerImage string
9194
dockerImagePullPolicy string
@@ -115,6 +118,7 @@ func init() {
115118
f.BoolVar(&allPortOffsetsUnique, "starter.unique-port-offsets", false, "If set, all peers will get a unique port offset. If false (default) only portOffset+peerAddress pairs will be unique.")
116119
f.StringVar(&dataDir, "starter.data-dir", getEnvVar("DATA_DIR", "."), "directory to store all data the starter generates (and holds actual database directories)")
117120
f.BoolVar(&debugCluster, "starter.debug-cluster", getEnvVar("DEBUG_CLUSTER", "") != "", "If set, log more information to debug a cluster")
121+
f.BoolVar(&disableIPv6, "starter.disable-ipv6", !net.IsIPv6Supported(), "If set, no IPv6 notation will be used. Use this only when IPv6 address family is disabled")
118122

119123
f.BoolVar(&verbose, "log.verbose", false, "Turn on debug logging")
120124

@@ -487,6 +491,7 @@ func mustPrepareService(generateAutoKeyFile bool) (*service.Service, service.Boo
487491
SslKeyFile: sslKeyFile,
488492
SslCAFile: sslCAFile,
489493
RocksDBEncryptionKeyFile: rocksDBEncryptionKeyFile,
494+
DisableIPv6: disableIPv6,
490495
}
491496
bsCfg.Initialize()
492497
serviceConfig := service.Config{

pkg/net/ipv6.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2017 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
// Author Ewout Prangsma
21+
//
22+
23+
// +build !linux
24+
25+
package net
26+
27+
// IsIPv6Supported returns true when IPv6 support is available,
28+
// false when it is not.
29+
// Note that it is not possible on all platforms to properly
30+
// detect IPv6 support.
31+
func IsIPv6Supported() bool {
32+
return true
33+
}

pkg/net/ipv6_linux.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2017 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
// Author Ewout Prangsma
21+
//
22+
23+
package net
24+
25+
import "os"
26+
27+
// IsIPv6Supported returns true when IPv6 support is available,
28+
// false when it is not.
29+
// Note that it is not possible on all platforms to properly
30+
// detect IPv6 support.
31+
func IsIPv6Supported() bool {
32+
if _, err := os.Stat("/proc/net/if_inet6"); err == nil {
33+
return true
34+
}
35+
return false
36+
}

service/arangod_config_builder.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,15 @@ func createArangodConf(log *logging.Logger, bsCfg BootstrapConfig, myHostDir, my
8484
threads = "16"
8585
v8Contexts = "4"
8686
}
87+
listenAddr := "[::]"
88+
if bsCfg.DisableIPv6 {
89+
listenAddr = "0.0.0.0"
90+
}
8791
scheme := NewURLSchemes(bsCfg.SslKeyFile != "").Arangod
8892
serverSection := &configSection{
8993
Name: "server",
9094
Settings: map[string]string{
91-
"endpoint": fmt.Sprintf("%s://[::]:%s", scheme, myPort),
95+
"endpoint": fmt.Sprintf("%s://%s:%s", scheme, listenAddr, myPort),
9296
"threads": threads,
9397
"authentication": "false",
9498
},

service/bootstrap_config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type BootstrapConfig struct {
3939
SslKeyFile string // Path containing an x509 certificate + private key to be used by the servers.
4040
SslCAFile string // Path containing an x509 CA certificate used to authenticate clients.
4141
RocksDBEncryptionKeyFile string // Path containing encryption key for RocksDB encryption.
42+
DisableIPv6 bool // If set, no IPv6 notation will be used
4243
}
4344

4445
// Initialize auto-configures some optional values

0 commit comments

Comments
 (0)