Skip to content

SS2022 proxy: Refactor to fix some issues - #6866

Merged
RPRX merged 2 commits into
mainfrom
ss2022
Sep 30, 2026
Merged

RPRX merged 2 commits into
mainfrom
ss2022

Conversation

@Fangliding

Copy link
Copy Markdown
Member

之前只初始化了一个buff读一帧 测试的时候双端都是新版本测的就没问题 但是旧版本singss实现和其他实现会发大包然后会丢
还有写多用户的时候漏了udp(

@svlavr

svlavr commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

more:
1. The client cannot decrypt multi-user UDP responses. The response header is encrypted with the master key instead of the user key:

- EnsureServerState(i.method, i.udpMasterCipher, nil, userPSK)
+ EnsureServerState(i.method, userBlock, nil, userPSK)

userBlock is created from userPSK. The test passes after this change.
2. After RemoveUser, fresh packets from the existing UDP session are still accepted. The cached user is reused:

currentUser = sessionItem.User
userPSK = sessionItem.UserPSK

If removal should reject further UDP packets, EIH should be checked against the current usersByHash before accessing the session cache?

@RPRX

RPRX commented Sep 29, 2026

Copy link
Copy Markdown
Member

@Fangliding 再看看

@Fangliding

Copy link
Copy Markdown
Member Author

我在重新整

@RPRX

RPRX commented Sep 29, 2026

Copy link
Copy Markdown
Member

@Fangliding 上面他提到的问题解决了吗

@RPRX

RPRX commented Sep 29, 2026

Copy link
Copy Markdown
Member

2. After RemoveUser, fresh packets from the existing UDP session are still accepted. The cached user is reused:

对 TCP 来说倒是所有入站共有的问题,不过这里说的是 UDP 所以,没记错的话每个 UDP 包都要鉴权,所以可以避免

@svlavr

svlavr commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

I checked: each UDP packet is authenticated using the session’s cached key, but the user’s presence is not checked again. So an existing session continues working after RemoveUser. Is this intended?

@svlavr

svlavr commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

The user is taken from the session cache, so the user lookup is skipped:

currentUser = sessionItem.User
userPSK = sessionItem.UserPSK

if currentUser == nil {
    // ...
    user, ok := i.usersByHash.Load(decryptedHash)
}

RemoveUser doesn't clear sessionItem.User, so currentUser is still non-nil. As long as packets keep coming, the idle timeout keeps getting refreshed.

@RPRX

RPRX commented Sep 30, 2026

Copy link
Copy Markdown
Member

不知道是为了性能还是,虽然加上 check user 应该也不太影响公网环境性能(除了本地斗蛐蛐),可以先这样合了,发版测测

@RPRX

RPRX commented Sep 30, 2026

Copy link
Copy Markdown
Member

另外 TCP 也是 #6866 (comment) ,所以第二点问题也可以放到以后一并解决

@RPRX RPRX changed the title Fix ss2022 big buffer && udp mult user SS2022 proxy: Refactor to fix some issues Sep 30, 2026
@Fangliding

Copy link
Copy Markdown
Member Author

@Fangliding 上面他提到的问题解决了吗

psk的问题解决了 我主要是在修别的bug
removeuser那个我没管 因为其他udp中继是一个行为

@RPRX
RPRX merged commit 9294ca8 into main Sep 30, 2026
48 checks passed
@RPRX

RPRX commented Sep 30, 2026

Copy link
Copy Markdown
Member

搜了下,应该不是这个 commit 导致的 Windows test FAIL

@Fangliding

Copy link
Copy Markdown
Member Author

history里不是正常的 40/40么

@Fangliding

Copy link
Copy Markdown
Member Author

btw 顺便测试这玩意还给我服务器搞墙了 应该算工伤

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.

3 participants