Add shadowsocks 2022 multi-user inbound

This commit is contained in:
世界 2022-05-24 07:25:12 +08:00
parent b6391cbbe1
commit cf7e675c45
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
6 changed files with 427 additions and 50 deletions

View file

@ -30,6 +30,7 @@ func init() {
type Inbound struct {
networks []net.Network
service shadowsocks.Service
email string
}
func NewServer(ctx context.Context, config *ServerConfig) (*Inbound, error) {
@ -42,6 +43,7 @@ func NewServer(ctx context.Context, config *ServerConfig) (*Inbound, error) {
}
inbound := &Inbound{
networks: networks,
email: config.Email,
}
if !C.Contains(shadowaead_2022.List, config.Method) {
return nil, newError("unsupported method ", config.Method)
@ -103,6 +105,7 @@ func (i *Inbound) NewConnection(ctx context.Context, conn net.Conn, metadata M.M
From: metadata.Source,
To: metadata.Destination,
Status: log.AccessAccepted,
Email: i.email,
})
newError("tunnelling request to tcp:", metadata.Destination).WriteToLog(session.ExportIDToError(ctx))
dispatcher := session.DispatcherFromContext(ctx)
@ -123,6 +126,7 @@ func (i *Inbound) NewPacketConnection(ctx context.Context, conn N.PacketConn, me
From: metadata.Source,
To: metadata.Destination,
Status: log.AccessAccepted,
Email: i.email,
})
newError("tunnelling request to udp:", metadata.Destination).WriteToLog(session.ExportIDToError(ctx))
dispatcher := session.DispatcherFromContext(ctx)