Skip to content

Conversation

@ari-ahm
Copy link
Contributor

@ari-ahm ari-ahm commented Dec 15, 2025

The fmt.Printf call inside UClient's DialTLSContext was executing unconditionally.
This caused log pollution when using xray-core as a library dependency, printing to stdout even when debug mode was disabled.(REALITY localAddr: xxx DialTLSContext)

This patch wraps the print statement with if config.Show, consistent with other debug logs in the file.
This cleans up the output when using the package as a library.

@RPRX
Copy link
Member

RPRX commented Dec 16, 2025

如果有人看到了这个 log 那说明有福报了 #5066 (comment)

要改成先判断 if show 的话要在外面再加个 error 级别的警报,比如你的连接被重定向了/你正在遭受中间人攻击

@ari-ahm
Copy link
Contributor Author

ari-ahm commented Dec 16, 2025

I have updated the code based on your feedback.

I added errors.LogError outside the spider loop. This ensures the user receives a clear, high-severity warning about the verification failure (potential MITM/Redirection) exactly once.
I kept the if config.Show guard on the internal DialTLSContext log.

To be honest, the raw DialTLSContext print message didn't mean much to 99% of users and was mostly seen as log spam. By replacing the repetitive prints with a single, clear Error log, we keep the "blessing" of the security warning, but in a format that users can actually understand and act upon.

@RPRX RPRX changed the title fix: guard debug log in DialTLSContext with config.Show REALITY client: Clearer log when receiving real certificate Dec 23, 2025
@RPRX RPRX merged commit 3572209 into XTLS:main Dec 23, 2025
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