environment(docker): fix outgoing ip not changing

Fixes an issue where when a server has it's primary allocation
changed, the outgoing ip is not updated on the Docker network.

The only downside of this change is old networks are not cleaned up.

Closes https://github.com/pterodactyl/panel/issues/4547
This commit is contained in:
Matthew Penner 2022-11-21 14:59:53 -07:00
parent da94f750ad
commit 1457470fff
No known key found for this signature in database

View File

@ -196,7 +196,7 @@ func (e *Environment) Create() error {
networkMode := container.NetworkMode(cfg.Docker.Network.Mode)
if a.ForceOutgoingIP {
e.log().Debug("environment/docker: forcing outgoing IP address")
networkName := strings.ReplaceAll(e.Id, "-", "")
networkName := "ip-" + strings.ReplaceAll(strings.ReplaceAll(a.DefaultMapping.Ip, ".", "-"), ":", "-")
networkMode = container.NetworkMode(networkName)
if _, err := e.client.NetworkInspect(ctx, networkName, types.NetworkInspectOptions{}); err != nil {