Skip to content

logging: add square brackets when print raw ipv6 addresses - #477

Merged
mkj merged 1 commit into
mkj:mainfrom
orangepizza:ipv6-logging
Jul 23, 2026
Merged

logging: add square brackets when print raw ipv6 addresses#477
mkj merged 1 commit into
mkj:mainfrom
orangepizza:ipv6-logging

Conversation

@orangepizza

Copy link
Copy Markdown
Contributor

otherwise it'll print malformed IPv6 address in log like "Connection to fe80:3221::1:32514 closed"
RFC3986 requires literal ipv6 address in hostname context need to be warped in a square brackets

@mkj mkj left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks, that makes sense. A couple of small things.

Comment thread src/cli-session.c Outdated
Comment on lines +379 to +386
fprintf(stderr, "Connection to %s@%s:%s closed.\n", cli_opts.username,
/* IPv6 need to be captuled by [] */
if (strchr(cli_opts.remotehost, ':') != NULL) {
fprintf(stderr, "Connection to %s@[%s]:%s closed.\n", cli_opts.username,
cli_opts.remotehost, cli_opts.remoteport);
} else {
fprintf(stderr, "Connection to %s@%s:%s closed.\n", cli_opts.username,
cli_opts.remotehost, cli_opts.remoteport);
}

@mkj mkj Jul 23, 2026

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Can skip this change, just now I realised the print never actually worked, I'll sort out removing it in a separate commit. (session_cleanup() has already closed stderr)

Comment thread src/cli-session.c Outdated
Comment on lines 431 to 434

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Could add this one too?

Comment thread src/svr-session.c
Comment on lines +125 to +129
if (strchr(host, ':') != NULL) {
snprintf(svr_ses.addrstring, len, "[%s]:%s", host, port);
} else {
snprintf(svr_ses.addrstring, len, "%s:%s", host, port);
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Looks like indentation isn't right here, should be tabs.

@orangepizza
orangepizza force-pushed the ipv6-logging branch 2 times, most recently from 2205ff6 to 800c605 Compare July 23, 2026 05:51
otherwise it'll print malformed ip in log like
"Connection to fe80:3221::1:32514 closed"
@mkj
mkj merged commit 6c293a3 into mkj:main Jul 23, 2026
17 of 18 checks passed
@mkj

mkj commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Thanks!

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.

2 participants