Skip to content

Commit

Permalink
fix(xo-web): better handling of ipv6 when creating a nfs iso SR
Browse files Browse the repository at this point in the history
  • Loading branch information
fbeauchamp committed Nov 14, 2024
1 parent cb2a82f commit 02cd070
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/xo-web/src/xo-app/new/sr/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ const NFS_VERSIONS = ['4', '4.1']

// ===================================================================

// from https://github.com/Karbashevskyi/thiis/blob/cb7df127a8afcb6ede7f66f110577d535567af6b/src/regexp.ts
function isIpv6(string) {
return /^((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?$/.test(
string
)
}

class SelectScsiId extends Component {
static propTypes = {
onChange: PropTypes.func.isRequired,
Expand Down Expand Up @@ -327,7 +334,7 @@ export default class New extends Component {
host.id,
name.value,
description.value,
`${server.value}:${path}`,
isIpv6(server.value) ? `[${server.value}]:${path}` : `${server.value}:${path}`,
'nfs',
username && username.value,
password && password.value,
Expand Down

0 comments on commit 02cd070

Please sign in to comment.