Skip to content

Conversation

@ejona86
Copy link
Member

@ejona86 ejona86 commented Jul 7, 2022

Fix for ipv6 link local with scope. If you try to connect passing address like "ipv6%wlan0" it will use

public SNIHostName(String hostname) {
        super(0, (hostname = IDN.toASCII((String)Objects.requireNonNull(hostname, "Server name value of host_name cannot be null"), 2)).getBytes(StandardCharsets.US_ASCII));
        this.hostname = hostname;
        this.checkHostName();
    }

Which raises hostname is not valid because this method doesn't accept non ASCII characters. With the change it will use

public SNIHostName(byte[] encoded) {
        super(0, encoded);

        try {
            CharsetDecoder decoder = StandardCharsets.UTF_8.newDecoder().onMalformedInput(CodingErrorAction.REPORT).onUnmappableCharacter(CodingErrorAction.REPORT);
            this.hostname = IDN.toASCII(decoder.decode(ByteBuffer.wrap(encoded)).toString());
        } catch (CharacterCodingException | RuntimeException var3) {
            throw new IllegalArgumentException("The encoded server name value is invalid", var3);
        }

        this.checkHostName();
    }

Now scoped ipv6 link is supported. 😄

Backport of #9326

@ejona86 ejona86 requested a review from YifeiZhuang July 7, 2022 14:47
@ejona86 ejona86 merged commit 0b3a0b4 into grpc:v1.48.x Jul 7, 2022
@ejona86 ejona86 deleted the backport-master-1.48 branch July 7, 2022 17:40
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants