Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ws transport writes/reads invalid data #3011

Open
frankli0324 opened this issue May 9, 2024 · 2 comments
Open

ws transport writes/reads invalid data #3011

frankli0324 opened this issue May 9, 2024 · 2 comments

Comments

@frankli0324
Copy link

frankli0324 commented May 9, 2024

What version of V2Ray are you using?

V2Ray 5.16.1 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.22.2 linux/amd64)
A unified platform for anti-censorship.

on both client and server side

What's your scenario of using V2Ray?

General

What problems have you encountered?

ws transport seems to be broken. See minimal verification below in config and logs

The reason I'm confident that it's ws transport that's misbehaving is because when $.inbounds|outbounds[].streamSettings.transport == "tcp", everything works fine. Haven't tried other transports so it could be not related to ws but some common codebase instead

What's your expectation?

n/a

Please attach your configuration here

Server configuration:

{
    "log": {
        "access": "/dev/stdout",
        "loglevel": "debug"
    },
    "inbounds": [
        {
            "protocol": "socks",
            "port": "16033",
            "listen": "127.0.0.1",
            "settings": {
                "auth": "noauth",
                "udp": true
            },
            "streamSettings": {
                "transport": "ws",
                "transportSettings": {
                    "path": "/1234"
                }
            }
        }
    ],
    "outbounds": [
        {
            "protocol": "freedom"
        }
    ]
}

Client configuration:

{
    "log": {
        "error": "/dev/stdout",
        "loglevel": "debug"
    },
    "inbounds": [
        {
            "listen": "127.0.0.1",
            "port": 1086,
            "protocol": "http"
        }
    ],
    "outbounds": [
        {
            "tag": "local",
            "protocol": "socks",
            "settings": {
                "servers": [
                    {
                        "address": "127.0.0.1",
                        "port": 16033
                    }
                ]
            },
            "streamSettings": {
                "wsSettings": {
                    "path": "/1234"
                },
                "network": "ws"
            }
        }
    ]
}

Please attach error logs here

Server error log:

V2Ray 5.16.1 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.22.2 darwin/amd64)
A unified platform for anti-censorship.
2024/05/10 03:14:49 [Debug] app/log: Logger started
2024/05/10 03:14:49 [Debug] app/proxyman/inbound: creating stream worker on 127.0.0.1:16033
2024/05/10 03:14:49 [Info] transport/internet/tcp: listening TCP on 127.0.0.1:16033
2024/05/10 03:14:49 [Info] transport/internet/udp: listening UDP on 127.0.0.1:16033
2024/05/10 03:14:49 [Warning] V2Ray 5.16.1 started
2024/05/10 03:15:06 [Info] [2906254124] app/proxyman/inbound: connection ends > proxy/socks: failed to read request > proxy/socks: unknown Socks version: 71
2024/05/10 03:15:06 tcp:127.0.0.1:62564 rejected  proxy/socks: unknown Socks version: 71
2024/05/10 03:15:06 tcp:127.0.0.1:62565 rejected  proxy/socks: unknown Socks version: 71
2024/05/10 03:15:06 [Info] [2340291187] app/proxyman/inbound: connection ends > proxy/socks: failed to read request > proxy/socks: unknown Socks version: 71
2024/05/10 03:15:06 [Info] [3224243794] app/proxyman/inbound: connection ends > proxy/socks: failed to read request > proxy/socks: unknown Socks version: 71
2024/05/10 03:15:06 tcp:127.0.0.1:62566 rejected  proxy/socks: unknown Socks version: 71
2024/05/10 03:15:07 tcp:127.0.0.1:62567 rejected  proxy/socks: unknown Socks version: 71
2024/05/10 03:15:07 [Info] [176814467] app/proxyman/inbound: connection ends > proxy/socks: failed to read request > proxy/socks: unknown Socks version: 71
2024/05/10 03:15:07 [Info] [566545438] app/proxyman/inbound: connection ends > proxy/socks: failed to read request > proxy/socks: unknown Socks version: 71
2024/05/10 03:15:07 tcp:127.0.0.1:62568 rejected  proxy/socks: unknown Socks version: 71

Client error log:

V2Ray 5.16.1 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.22.2 darwin/amd64)
A unified platform for anti-censorship.
2024/05/10 03:14:50 [Debug] app/log: Logger started
2024/05/10 03:14:50 [Debug] app/proxyman/inbound: creating stream worker on 127.0.0.1:1086
2024/05/10 03:14:50 [Info] transport/internet/tcp: listening TCP on 127.0.0.1:1086
2024/05/10 03:14:50 [Warning] V2Ray 5.16.1 started
2024/05/10 03:15:06 [Info] [543596908] proxy/http: request to Method [GET] Host [www.baidu.com] with URL [http://www.baidu.com/]
2024/05/10 03:15:06 [Warning] [543596908] app/dispatcher: default route for tcp:www.baidu.com:80
2024/05/10 03:15:06 127.0.0.1:62563 accepted http://www.baidu.com/ [local]
2024/05/10 03:15:06 [Info] [543596908] transport/internet/websocket: creating connection to tcp:127.0.0.1:16033
2024/05/10 03:15:06 [Info] [543596908] transport/internet/websocket: creating connection to tcp:127.0.0.1:16033
2024/05/10 03:15:06 [Info] [543596908] transport/internet/websocket: creating connection to tcp:127.0.0.1:16033
2024/05/10 03:15:07 [Info] [543596908] transport/internet/websocket: creating connection to tcp:127.0.0.1:16033
2024/05/10 03:15:07 [Info] [543596908] transport/internet/websocket: creating connection to tcp:127.0.0.1:16033
2024/05/10 03:15:07 [Info] [543596908] app/proxyman/outbound: failed to process outbound traffic > proxy/socks: failed to find an available destination > common/retry: [transport/internet/websocket: failed to dial WebSocket > transport/internet/websocket: failed to dial to (ws://127.0.0.1:16033/1234):  > unexpected EOF] > common/retry: all retry attempts failed
2024/05/10 03:15:07 [Warning] [543596908] proxy/http: failed to read response from www.baidu.com > io: read/write on closed pipe
2024/05/10 03:15:07 [Info] [543596908] app/proxyman/inbound: connection ends > proxy/http: failed to read http request > EOF
@frankli0324
Copy link
Author

frankli0324 commented May 9, 2024

The issue is encountered on protocols including vless, vmess, shadowsocks, with TLS on or off so quite confident it's a transport issue. also, "unknown Socks version: 71" indicates that it may have been used as a http proxy, that may give some clues. I suspect that the transport is reading from the wrong io.Reader which is used for raw inbound

I guess that this error is propagated to shadowrocket codebase since I first got this error about after I update the app, I'm not quite sure about the exact action triggering the issue tho, it could also be a server issue since I also updated the server side afterwards

@frankli0324
Copy link
Author

frankli0324 commented May 9, 2024

update: when using http protocol with ws transport, the http outbound destination seems to have been overwritten, I guess this speaks a lot
image

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

No branches or pull requests

1 participant