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

VMess protocol support #632

Merged
merged 1 commit into from
Dec 16, 2024
Merged

VMess protocol support #632

merged 1 commit into from
Dec 16, 2024

Conversation

reflog
Copy link
Contributor

@reflog reflog commented Nov 14, 2024

This PR adds VMess protocol support based on https://github.com/SagerNet/sing-vmess package.

Copy link
Contributor

@garmr-ulfr garmr-ulfr left a comment

Choose a reason for hiding this comment

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

LG! Just a few comments, and VMessAddr should be added here.

For the code in outbound.go and server.go that was copied over, is every function needed? Some aren't referenced anywhere else. Would it still work if we removed them?

v2ray/vmess/outbound.go Outdated Show resolved Hide resolved
v2ray/vmess/outbound.go Outdated Show resolved Hide resolved
v2ray/router.go Outdated Show resolved Hide resolved
v2ray/router.go Outdated Show resolved Hide resolved
v2ray/router.go Outdated
return err
} else {
if onClose != nil {
onClose(nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

v2ray/vmess/outbound.go Outdated Show resolved Hide resolved
v2ray/vmess/server.go Outdated Show resolved Hide resolved
v2ray/vmess/listener_test.go Outdated Show resolved Hide resolved
v2ray/vmess/listener_test.go Outdated Show resolved Hide resolved
v2ray/vmess/listener_test.go Outdated Show resolved Hide resolved
@reflog
Copy link
Contributor Author

reflog commented Nov 21, 2024

@garmr-ulfr thanks for the review. all points addressed

@reflog
Copy link
Contributor Author

reflog commented Nov 26, 2024

complements getlantern/flashlight#1453

@reflog
Copy link
Contributor Author

reflog commented Nov 26, 2024

@garmr-ulfr @hwh33
I've rewritten the PR as we've discussed.
It now ignores the 'destination' part of the protocol (like shadowsocks) and instead handles only the obfuscation

It's been tested with the linked Flashlight PR

Copy link
Contributor

@garmr-ulfr garmr-ulfr left a comment

Choose a reason for hiding this comment

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

I haven't got through it all in detail yet, there's a lot going on here.

Side note: why did the author copy and include stuff from the go stdlib?? Some, like common.format is basically a stripped down fmt, common/binary.go even still has the Go Author copyright header. And they call panic quite a bit, be it directly or through helper functions. So there's a plethora of places a panic can happen, and with nothing to let consumers know so caller can handler it. It's mental...

@@ -30,5 +30,6 @@ func getProtoListenersArgs(p *Proxy) []protoListenerArgs {
p.wrapMultiplexing(p.listenShadowsocks),
},
{"water", p.WaterAddr, p.listenWATER},
{"vmess", p.VMessAddr, p.listenVMess(p.listenTCP)},
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to enable multiplexing for vmess?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

honestly - I don't know. any pointers?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not really sure either. I faintly remember @hwh33 saying that we multiplex everything, but I don't know. He'd be the one to answer this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah we multiplex everything at this point. I would just bake that in here and on the flashlight side.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch @garmr-ulfr!

Copy link
Contributor

Choose a reason for hiding this comment

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

This is the only remaining item needed on this PR @reflog

v2ray/vmess/listener.go Outdated Show resolved Hide resolved
v2ray/vmess/listener.go Outdated Show resolved Hide resolved
v2ray/vmess/listener.go Outdated Show resolved Hide resolved
v2ray/vmess/listener.go Outdated Show resolved Hide resolved
v2ray/vmess/listener.go Outdated Show resolved Hide resolved
v2ray/vmess/listener.go Outdated Show resolved Hide resolved
v2ray/vmess/listener.go Outdated Show resolved Hide resolved
v2ray/vmess/listener.go Show resolved Hide resolved
service *vmess.Service[int]
}

func NewVMessListener(baseListener net.Listener, uuids []string) (net.Listener, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add documentation? Specifically, what are the UUIDs? How are we supposed to know what to configure here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at the test, it appears that each client would have to present its own UUID which needs to be pre-configured on the proxy. Is that correct? How do you plan to achieve that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hwh33 each proxy is configured with X UUIDs.
A random UUID from those X is returned when client requests proxy config.

I'll add a comment

Copy link
Contributor

Choose a reason for hiding this comment

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

What happens when two clients are assigned the same UUID for a proxy? Or do we just assign so many that the odds of that are negligible?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hwh33 no, it's no 1-to-1, think of it more of a 'password' and less 'user-id'.
you can have just one, but I think adding some entropy is always nicer

Copy link
Contributor

Choose a reason for hiding this comment

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

There's still no documentation @reflog ☹️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hwh33 doh. slipped my mind. will add in a followup PR

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you!

Comment on lines +57 to +66
conn, err := l.Listener.Accept()
if err != nil {
return nil, err
}
h := &handler{}
err = l.service.NewConnection(context.Background(), conn, metadata.Socksaddr{}, nil, h)
if err != nil {
return nil, err
}
return h.conn, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

This is nice and simple compared to what we expected!

@reflog
Copy link
Contributor Author

reflog commented Dec 16, 2024

@hwh33 done

@reflog reflog merged commit 2bd3d26 into main Dec 16, 2024
1 check passed
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