mirror of
https://github.com/vmorganp/Lazytainer.git
synced 2025-12-21 13:23:02 +01:00
toggles for ipv4 and ipv6
This commit is contained in:
14
README.md
14
README.md
@@ -87,7 +87,7 @@ Group properties that can be changed include:
|
||||
|
||||
#### Verbose Logging
|
||||
|
||||
If you would like more verbose logging, you can apply the environment variable `VERBOSE=true` to lazytainer like so
|
||||
For more verbose logging, you can apply the environment variable `VERBOSE=true` to lazytainer:
|
||||
|
||||
```yaml
|
||||
lazytainer:
|
||||
@@ -96,6 +96,18 @@ lazytainer:
|
||||
- VERBOSE=true
|
||||
```
|
||||
|
||||
#### ipv4/ipv6 toggles
|
||||
|
||||
To disable ipv4 or ipv6, pass environment variables:
|
||||
|
||||
```yaml
|
||||
lazytainer:
|
||||
# ... configuration omitted for brevity
|
||||
environment:
|
||||
- IPV6_DISABLED=true
|
||||
- IPV4_DISABLED=true
|
||||
```
|
||||
|
||||
#### Volumes
|
||||
|
||||
If using lazytainer, you MUST provide the following volume to lazytainer
|
||||
|
||||
@@ -10,6 +10,8 @@ services:
|
||||
# build: .
|
||||
environment:
|
||||
- VERBOSE=true # probably set this to false unless you're debugging or doing the initial demo
|
||||
- IPV4_DISABLED=false
|
||||
- IPV6_DISABLED=false
|
||||
ports:
|
||||
- 81:81
|
||||
- 82:82
|
||||
|
||||
18
src/group.go
18
src/group.go
@@ -148,17 +148,29 @@ func (lg LazyGroup) getRxPackets(packetCount *int) {
|
||||
func (lg LazyGroup) getActiveClients() int {
|
||||
// get active clients
|
||||
var allSocks []netstat.SockTabEntry
|
||||
|
||||
// ipv4
|
||||
if ipv6Enabled {
|
||||
udpSocks, err := netstat.UDPSocks(netstat.NoopFilter)
|
||||
check(err)
|
||||
udp6Socks, err := netstat.UDP6Socks(netstat.NoopFilter)
|
||||
check(err)
|
||||
allSocks = append(allSocks, udpSocks...)
|
||||
tcpSocks, err := netstat.TCPSocks(netstat.NoopFilter)
|
||||
check(err)
|
||||
allSocks = append(allSocks, tcpSocks...)
|
||||
}
|
||||
|
||||
// ipv6
|
||||
if ipv6Enabled {
|
||||
udp6Socks, err := netstat.UDP6Socks(netstat.NoopFilter)
|
||||
check(err)
|
||||
allSocks = append(allSocks, udp6Socks...)
|
||||
tcp6Socks, err := netstat.TCP6Socks(netstat.NoopFilter)
|
||||
check(err)
|
||||
allSocks = append(allSocks, tcp6Socks...)
|
||||
}
|
||||
|
||||
activeClients := 0
|
||||
for _, socketEntry := range append(append(append(append(allSocks, udp6Socks...), tcp6Socks...), tcpSocks...), udpSocks...) {
|
||||
for _, socketEntry := range allSocks {
|
||||
if socketEntry.State.String() == "ESTABLISHED" {
|
||||
for _, aPort := range lg.ports {
|
||||
if strconv.FormatUint(uint64(aPort), 10) == fmt.Sprintf("%v", socketEntry.LocalAddr.Port) {
|
||||
|
||||
@@ -17,6 +17,8 @@ import (
|
||||
var infoLogger *log.Logger
|
||||
var debugLogger *log.Logger
|
||||
var dockerClient *client.Client
|
||||
var ipv6Enabled bool
|
||||
var ipv4Enabled bool
|
||||
|
||||
func main() {
|
||||
flags := log.LstdFlags | log.Lshortfile
|
||||
@@ -29,6 +31,22 @@ func main() {
|
||||
debugLogger.SetOutput(io.Discard)
|
||||
}
|
||||
|
||||
// if the IPV6_DISABLED flag isn't set to true, leave ipv6 enabled
|
||||
envIpv6, existsEnvDisableIpv6 := os.LookupEnv("IPV6_DISABLED")
|
||||
if existsEnvDisableIpv6 && strings.ToLower(envIpv6) != "true" {
|
||||
ipv6Enabled = true
|
||||
} else {
|
||||
ipv6Enabled = false
|
||||
}
|
||||
|
||||
// if the IPV4_DISABLED flag isn't set to true, leave ipv4 enabled
|
||||
envIpv4, existsEnvDisableIpv4 := os.LookupEnv("IPV4_DISABLED")
|
||||
if existsEnvDisableIpv4 && strings.ToLower(envIpv4) != "true" {
|
||||
ipv4Enabled = true
|
||||
} else {
|
||||
ipv4Enabled = false
|
||||
}
|
||||
|
||||
// configure groups. eventually it might be nice to have file based config as well.
|
||||
groups := configureFromLabels()
|
||||
for _, v := range groups {
|
||||
|
||||
Reference in New Issue
Block a user