mirror of
https://github.com/portainer/portainer.git
synced 2025-08-02 20:35:25 +02:00
feat(networks): add ipv6 support (#3717)
* feat(portainer-core): add ipv6 support * feat(networks): add few changes * refacto(networks): write regex once * fix(networks): fix indentation * refacto(networks): use foreach instead map and pluralize ipvxconfig * refacto(networks): pluralize ipvxconfig * feat(networks): support ipv6 with ports * feat(networks): add an explicit error message * fix(networks): hide ipv6 configuration when creating macvlan
This commit is contained in:
parent
b2f36a3bbe
commit
3de533042d
16 changed files with 262 additions and 72 deletions
|
@ -135,10 +135,21 @@ angular.module('portainer.docker').factory('ContainerHelper', [
|
|||
let startHostPort = 0;
|
||||
let endHostPort = 0;
|
||||
if (hostPort) {
|
||||
if (hostPort.indexOf(':') > -1) {
|
||||
const hostAndPort = _.split(hostPort, ':');
|
||||
hostIp = hostAndPort[0];
|
||||
if (hostPort.indexOf('[') > -1) {
|
||||
const hostAndPort = _.split(hostPort, ']:');
|
||||
|
||||
if (hostAndPort.length < 2) {
|
||||
throw new Error('Invalid port specification: ' + portBinding.containerPort);
|
||||
}
|
||||
|
||||
hostIp = hostAndPort[0].replace('[', '');
|
||||
hostPort = hostAndPort[1];
|
||||
} else {
|
||||
if (hostPort.indexOf(':') > -1) {
|
||||
const hostAndPort = _.split(hostPort, ':');
|
||||
hostIp = hostAndPort[0];
|
||||
hostPort = hostAndPort[1];
|
||||
}
|
||||
}
|
||||
|
||||
const hostPortRange = parsePortRange(hostPort);
|
||||
|
|
13
app/docker/helpers/networkHelper.js
Normal file
13
app/docker/helpers/networkHelper.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
import _ from 'lodash-es';
|
||||
|
||||
class DockerNetworkHelper {
|
||||
static getIPV4Configs(configs) {
|
||||
return _.filter(configs, (config) => /^([0-9]{1,3}\.){3}[0-9]{1,3}(\/([0-9]|[1-2][0-9]|3[0-2]))?$/.test(config.Subnet));
|
||||
}
|
||||
|
||||
static getIPV6Configs(configs) {
|
||||
return _.without(configs, ...DockerNetworkHelper.getIPV4Configs(configs));
|
||||
}
|
||||
}
|
||||
|
||||
export default DockerNetworkHelper;
|
Loading…
Add table
Add a link
Reference in a new issue