Skip to content

Fix many panic - #7564

Open
Fangliding wants to merge 1 commit into
mainfrom
panic
Open

Fangliding wants to merge 1 commit into
mainfrom
panic

Conversation

@Fangliding

Copy link
Copy Markdown
Member

7556~7559 大概是机器发的一大堆

@svlavr

svlavr commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

@Fangliding, for VLESS, could we extract just the padding and key parsing into a shared helper? The inbound and outbound builders would keep their existing mode and timing parsing. The helper would use the already split segments and reject missing or malformed keys.

Proposed helper
func parseVLESSPaddingAndKeys(parts []string, mlkemKeySize int) (padding, keys string, ok bool) {
	firstKey := 0
	for firstKey < len(parts) && len(parts[firstKey]) < 20 {
		firstKey++
	}
	if firstKey == len(parts) {
		return "", "", false
	}
	for _, part := range parts[firstKey:] {
		key, err := base64.RawURLEncoding.DecodeString(part)
		if err != nil || (len(key) != 32 && len(key) != mlkemKeySize) {
			return "", "", false
		}
	}
	return strings.Join(parts[:firstKey], "."), strings.Join(parts[firstKey:], "."), true
}

The inbound builder passes 64 and the outbound builder passes 1184. Both builders return a configuration error when ok is false.

@Fangliding

Copy link
Copy Markdown
Member Author

已经是共用的解析函数了啊

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