Skip to content

Commit

Permalink
fix: join configurations null handling fixed, no longer interferes wi…
Browse files Browse the repository at this point in the history
…th other config generations
  • Loading branch information
joesturge committed Oct 30, 2024
1 parent 70f91ac commit baca294
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Fixed bug where servers started when they shouldn't

## [2.6.0] - 2024-10-30

### Changed
Expand Down
32 changes: 31 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,33 @@
# Lazymc requires that the minecraft server have a static IP.
#
# To ensure that our servers have a static IP we need to create
# a network for our services to use.
#
# By default, Docker uses 172.17.0.0/16 subnet range.
# So we need to create a new network in a different subnet
# See the readme for more information.
#
# Please ensure that the subnet falls within the private CIDRs:
# https://datatracker.ietf.org/doc/html/rfc1918#section-3
#
# And that it is not in use by anything else.
networks:
minecraft-network:
driver: bridge
ipam:
config:
- subnet: 172.18.0.0/16

services:
lazymc:
image: ghcr.io/joesturge/lazymc-docker-proxy:latest
build: .
# the IPs should start at .2 as .1 is reserved for the gateway
networks:
minecraft-network:
ipv4_address: 172.18.0.2
restart: unless-stopped
environment:
RUST_LOG: "debug"
volumes:
# you should mount the minecraft server dir under /server, using read only.
- data:/server:ro
Expand All @@ -15,6 +41,10 @@ services:
# Standard Docker Minecraft server, also works with other server types
mc:
image: itzg/minecraft-server:java21
# Assign a static IP to the server container
networks:
minecraft-network:
ipv4_address: 172.18.0.3
# We need to add a label here so that lazymc-docker-proxy knows which
# container to manage
labels:
Expand Down
12 changes: 2 additions & 10 deletions src/entrypoint/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,7 @@ impl Config {

let join_forward_section: JoinForwardSection = JoinForwardSection {
address: labels
.get("lazymc.join.forward.address")
.and_then(|address| address.to_socket_addrs().ok())
.and_then(|addrs| addrs.filter(|addr| addr.is_ipv4()).next())
.and_then(|addr| addr.to_string().parse().ok())
.or_else(|| {
warn!(target: "lazymc-docker-proxy::entrypoint::config", "Failed to resolve IP address from lazymc.join.forward.address. Falling back to the value provided.");
resolved_ip = false;
labels.get("lazymc.join.forward.address").cloned()
}),
.get("lazymc.join.forward.address").cloned(),
send_proxy_v2: labels
.get("lazymc.join.forward.send_proxy_v2")
.map(|x| x == "true"),
Expand All @@ -286,7 +278,7 @@ impl Config {
.map(|s| s.to_string())
.collect())
.filter(|m: &Vec<String>| !m.is_empty())
}),
}).or_else(|| None),
kick: join_kick_section.clone(),
hold: join_hold_section.clone(),
forward: join_forward_section.clone(),
Expand Down

0 comments on commit baca294

Please sign in to comment.