Skip to content

Conversation

@Freddo3000
Copy link
Contributor

This is pterodactyl/wings#203 cherrypicked onto current main branch.

Issue:
For macvlan driver default docker config assign first available ip. Game servers get ip assigned in order of container creation.

Solution proposal:
Wings support only one docker network for each game server. To assign correct IP default allocation could be used. Allocations > doesn't limit IPs at all, admin could set desired game server container ip and port by default allocation.

Tagging @madpeteguy for notice.

Issue:
For macvlan driver default docker config assign first available ip.
Game servers get ip assigned in order of container creation.

Solution proposal:
Wings support only one docker network for each game server.
To assign correct IP default allocation could be used.
Allocations doesn't limit IPs at all, admin could set desired game server container ip and port by default allocation.
@QuintenQVD0
Copy link
Contributor

This seems fine to me. I don't think it would work yet as our config loading order still first loads the default struct

@madpeteguy
Copy link
Contributor

I can test if it will work with pelican.
This would be a good reason for me to switch from pterodactyl.
For my setup this feature is a must, and I'm tired of building own images. Using official ones is more convenient for my homelab cd.

@Freddo3000
Copy link
Contributor Author

I can test if it will work with pelican. This would be a good reason for me to switch from pterodactyl. For my setup this feature is a must, and I'm tired of building own images. Using official ones is more convenient for my homelab cd.

I've been running it for more than a month now without any noteworthy issue.

@QuintenQVD0
Copy link
Contributor

I can test if it will work with pelican. This would be a good reason for me to switch from pterodactyl. For my setup this feature is a must, and I'm tired of building own images. Using official ones is more convenient for my homelab cd.

I've been running it for more than a month now without any noteworthy issue.

The question is does it still work for people that does not use macvlan.

@madpeteguy
Copy link
Contributor

madpeteguy commented Dec 4, 2024

I can test if it will work with pelican. This would be a good reason for me to switch from pterodactyl. For my setup this feature is a must, and I'm tired of building own images. Using official ones is more convenient for my homelab cd.

I've been running it for more than a month now without any noteworthy issue.

The question is does it still work for people that does not use macvlan.

In short: the proposed change applies only to wings that set docker.network.driver == “macvlan” in the configuration, for standard bridge and host allocations work as before.

The current implementation does not work for an interface of type macvlan, because server containers that connect to this type of network receive the first free IP address from the network pool, so there is no way to determine on which IP the game server will be available (unless we have only one server on this network).

My proposed fix makes the containers assigned to macvlan receive an IP address from the Default Allocation in the server configuration.
If the other allocations are assigned other IP addresses then those IP addresses will be ignored.

It is worth remembering that the use of macvlan has its security downsides, I can describe the ones I know of if necessary.
In addition, port allocations in the case of macvlan are only for informational purposes in the panel, in the network configuration they have no meaning.

Edit:
I am not a GO programmer, but i think this line may not be null safe: var serverNetConfig = config.Get().Docker.Network.
It's worth checking whether there will be a problem in the absence of a docker network configuration.

@QuintenQVD0
Copy link
Contributor

I can test if it will work with pelican. This would be a good reason for me to switch from pterodactyl. For my setup this feature is a must, and I'm tired of building own images. Using official ones is more convenient for my homelab cd.

I've been running it for more than a month now without any noteworthy issue.

The question is does it still work for people that does not use macvlan.

In short: the proposed change applies only to wings that set docker.network.driver == “macvlan” in the configuration, for standard bridge and host allocations work as before.

The current implementation does not work for an interface of type macvlan, because server containers that connect to this type of network receive the first free IP address from the network pool, so there is no way to determine on which IP the game server will be available (unless we have only one server on this network).

My proposed fix makes the containers assigned to macvlan receive an IP address from the Default Allocation in the server configuration. If the other allocations are assigned other IP addresses then those IP addresses will be ignored.

It is worth remembering that the use of macvlan has its security downsides, I can describe the ones I know of if necessary. In addition, port allocations in the case of macvlan are only for informational purposes in the panel, in the network configuration they have no meaning.

Edit: I am not a GO programmer, but i think this line may not be null safe: var serverNetConfig = config.Get().Docker.Network. It's worth checking whether there will be a problem in the absence of a docker network configuration.

The config logic should fil in all fields that are empty and can not be empty

@Crunch41
Copy link

Crunch41 commented Feb 15, 2025

@madpeteguy Would you happen to have a pelican build with this fix? Was using your pterodactyl build on unraid but want to move over to pelican & was bummed to find out pelican defaults to the default first available ip same as pterodactyl. Would love to see this officially merged into pelican whenever / if possible.

Edit: Made my own build here https://hub.docker.com/r/crunch41/pelican-wing hope that's alright, Have only tested on unraid but looks like it works as it should now with specified ip addresses being assigned. Only wish you could change the docker container names now haha

@madpeteguy
Copy link
Contributor

@Crunch41 Sorry, I did not have time to migrate to Pelican yet.

@KeyboardDabbler
Copy link

@Crunch41 Thank you for making this image available with the pull changes, and a big thanks to @madpeteguy for making it possible!

I’m currently using this build on Unraid after also encountering issues with the way the default egg/container is created and how IPs are assigned sequentially on a macvlan network.

So far, everything has worked great on a fresh install. However, when migrating from an existing install to this image, I noticed SQL database errors when deleting existing port allocations and attempting to remove allocations. I’ll do further testing and provide more details to help investigate.

This comment was marked as outdated.

@QuintenQVD0 QuintenQVD0 requested a review from Copilot June 26, 2025 06:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR cherry-picks support for assigning a specific IP from the default allocation when using the macvlan Docker driver, ensuring game servers receive the intended address.

  • Imported Docker’s network types and added logic to detect macvlan driver.
  • Constructed a NetworkingConfig using the server’s default allocation IP and gateway.
  • Updated both server/install.go and environment/docker/container.go to pass the new config into ContainerCreate.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
server/install.go Added macvlan network config generation and passed it into the container creation call.
environment/docker/container.go Mirrored macvlan networking logic in the environment’s Create method for consistency.
Comments suppressed due to low confidence (2)

server/install.go:464

  • [nitpick] Consider renaming defaultMapping to something more descriptive like ipAllocation to improve readability.
		var defaultMapping = ip.Server.Config().Allocations.DefaultMapping

environment/docker/container.go:264

  • There are no tests covering the newly added macvlan network configuration path; consider adding unit tests to verify correct behavior.
	var netConf *network.NetworkingConfig = nil //In case when no networking config is needed set nil

}()

r, err := ip.client.ContainerCreate(ctx, conf, hostConf, nil, nil, ip.Server.ID()+"_installer")
var netConf *network.NetworkingConfig = nil //In case when no networking config is needed set nil
Copy link

Copilot AI Jun 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simplify the nil initialization by declaring var netConf *network.NetworkingConfig without explicitly assigning nil.

Suggested change
var netConf *network.NetworkingConfig = nil //In case when no networking config is needed set nil
var netConf *network.NetworkingConfig // In case when no networking config is needed, defaults to nil

Copilot uses AI. Check for mistakes.
var serverNetConfig = config.Get().Docker.Network
if "macvlan" == serverNetConfig.Driver { //Generate networking config for macvlan driver
var defaultMapping = ip.Server.Config().Allocations.DefaultMapping
ip.Server.Log().Debug("Set macvlan " + serverNetConfig.Name + " IP to " + defaultMapping.Ip)
Copy link

Copilot AI Jun 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Use formatted logging (e.g., Debugf) instead of string concatenation for better readability and performance.

Suggested change
ip.Server.Log().Debug("Set macvlan " + serverNetConfig.Name + " IP to " + defaultMapping.Ip)
ip.Server.Log().Debugf("Set macvlan %s IP to %s", serverNetConfig.Name, defaultMapping.Ip)

Copilot uses AI. Check for mistakes.
@Freddo3000 Freddo3000 requested a review from a team as a code owner July 11, 2025 11:47
@QuintenQVD0 QuintenQVD0 requested a review from parkervcp October 11, 2025 07:40
Copy link
Contributor

@parkervcp parkervcp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@parkervcp parkervcp merged commit 2647985 into pelican-dev:main Dec 19, 2025
6 checks passed
@Freddo3000 Freddo3000 deleted the feature/macvlan branch December 22, 2025 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants