Skip to content

Commit

Permalink
feat: ipv6 test
Browse files Browse the repository at this point in the history
如果是使用 ipv6 访问的服务,则和使用 ipv4 的时候一样

一般只用在开发环境中,这和 ipv4 的情况一样
  • Loading branch information
menghuu committed Aug 7, 2024
1 parent 3a9c556 commit 8bcd7bd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default {

let upstream;
const ipv4Pattern = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
const ipv6Pattern = /^([[:xdigit:]]{1,4}(?::[[:xdigit:]]{1,4}){7}|::|:(?::[[:xdigit:]]{1,4}){1,6}|[[:xdigit:]]{1,4}:(?::[[:xdigit:]]{1,4}){1,5}|(?:[[:xdigit:]]{1,4}:){2}(?::[[:xdigit:]]{1,4}){1,4}|(?:[[:xdigit:]]{1,4}:){3}(?::[[:xdigit:]]{1,4}){1,3}|(?:[[:xdigit:]]{1,4}:){4}(?::[[:xdigit:]]{1,4}){1,2}|(?:[[:xdigit:]]{1,4}:){5}:[[:xdigit:]]{1,4}|(?:[[:xdigit:]]{1,4}:){1,6}:)$/
const subDomainVSUpstreamDomain = {
'hub': DEFAULT_DOCKER_REGISTRY_URL,

Expand All @@ -22,7 +23,7 @@ export default {

'docker-staging': DEFAULT_DOCKER_REGISTRY_URL
};
if (url.hostname.match(ipv4Pattern)) {
if (url.hostname.match(ipv4Pattern) || url.hostname.match(ipv6Pattern)) {
// 使用默认的 docker registry
upstream = DEFAULT_DOCKER_REGISTRY_URL;
} else {
Expand Down

0 comments on commit 8bcd7bd

Please sign in to comment.