Skip to content

Commit 7a527ec

Browse files
authored
Merge pull request #140 from joesturge/134-lazymc-docker-proxy-doesnt-allow-me-to-connect-to-the-minecraft-game-server
fix: join configurations null handling fixed, no longer interferes wi…
2 parents 70f91ac + baca294 commit 7a527ec

File tree

3 files changed

+37
-11
lines changed

3 files changed

+37
-11
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- Fixed bug where servers started when they shouldn't
13+
1014
## [2.6.0] - 2024-10-30
1115

1216
### Changed

docker-compose.yaml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,33 @@
1+
# Lazymc requires that the minecraft server have a static IP.
2+
#
3+
# To ensure that our servers have a static IP we need to create
4+
# a network for our services to use.
5+
#
6+
# By default, Docker uses 172.17.0.0/16 subnet range.
7+
# So we need to create a new network in a different subnet
8+
# See the readme for more information.
9+
#
10+
# Please ensure that the subnet falls within the private CIDRs:
11+
# https://datatracker.ietf.org/doc/html/rfc1918#section-3
12+
#
13+
# And that it is not in use by anything else.
14+
networks:
15+
minecraft-network:
16+
driver: bridge
17+
ipam:
18+
config:
19+
- subnet: 172.18.0.0/16
20+
121
services:
222
lazymc:
3-
image: ghcr.io/joesturge/lazymc-docker-proxy:latest
23+
build: .
24+
# the IPs should start at .2 as .1 is reserved for the gateway
25+
networks:
26+
minecraft-network:
27+
ipv4_address: 172.18.0.2
428
restart: unless-stopped
29+
environment:
30+
RUST_LOG: "debug"
531
volumes:
632
# you should mount the minecraft server dir under /server, using read only.
733
- data:/server:ro
@@ -15,6 +41,10 @@ services:
1541
# Standard Docker Minecraft server, also works with other server types
1642
mc:
1743
image: itzg/minecraft-server:java21
44+
# Assign a static IP to the server container
45+
networks:
46+
minecraft-network:
47+
ipv4_address: 172.18.0.3
1848
# We need to add a label here so that lazymc-docker-proxy knows which
1949
# container to manage
2050
labels:

src/entrypoint/config.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -254,15 +254,7 @@ impl Config {
254254

255255
let join_forward_section: JoinForwardSection = JoinForwardSection {
256256
address: labels
257-
.get("lazymc.join.forward.address")
258-
.and_then(|address| address.to_socket_addrs().ok())
259-
.and_then(|addrs| addrs.filter(|addr| addr.is_ipv4()).next())
260-
.and_then(|addr| addr.to_string().parse().ok())
261-
.or_else(|| {
262-
warn!(target: "lazymc-docker-proxy::entrypoint::config", "Failed to resolve IP address from lazymc.join.forward.address. Falling back to the value provided.");
263-
resolved_ip = false;
264-
labels.get("lazymc.join.forward.address").cloned()
265-
}),
257+
.get("lazymc.join.forward.address").cloned(),
266258
send_proxy_v2: labels
267259
.get("lazymc.join.forward.send_proxy_v2")
268260
.map(|x| x == "true"),
@@ -286,7 +278,7 @@ impl Config {
286278
.map(|s| s.to_string())
287279
.collect())
288280
.filter(|m: &Vec<String>| !m.is_empty())
289-
}),
281+
}).or_else(|| None),
290282
kick: join_kick_section.clone(),
291283
hold: join_hold_section.clone(),
292284
forward: join_forward_section.clone(),

0 commit comments

Comments
 (0)