mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-16 14:53:12 +00:00
Time based user hash
This commit is contained in:
1 parent
89f9332abd
commit
097915bf7e
11 files changed
+142
-68
No files matched your search
+1
-1
@@ -14,7 +14,7 @@ type VMessUser struct {
|
||||
}
|
||||
|
||||
func (u *VMessUser) ToUser() (core.User, error) {
|
||||
id, err := core.UUIDToID(u.Id)
|
||||
id, err := core.NewID(u.Id)
|
||||
return core.User{id}, err
|
||||
}
|
||||
|
||||
|
||||
+12
-13
@@ -50,7 +50,7 @@ func (handler *VMessInboundHandler) AcceptConnections(listener net.Listener) err
|
||||
|
||||
func (handler *VMessInboundHandler) HandleConnection(connection net.Conn) error {
|
||||
defer connection.Close()
|
||||
|
||||
|
||||
reader := vmessio.NewVMessRequestReader(handler.clients)
|
||||
|
||||
request, err := reader.Read(connection)
|
||||
@@ -83,19 +83,19 @@ func (handler *VMessInboundHandler) HandleConnection(connection net.Conn) error
|
||||
ray := handler.vPoint.NewInboundConnectionAccepted(request.Address)
|
||||
input := ray.InboundInput()
|
||||
output := ray.InboundOutput()
|
||||
|
||||
|
||||
readFinish := make(chan bool)
|
||||
writeFinish := make(chan bool)
|
||||
writeFinish := make(chan bool)
|
||||
|
||||
go handler.dumpInput(requestReader, input, readFinish)
|
||||
go handler.dumpOutput(responseWriter, output, writeFinish)
|
||||
|
||||
<-writeFinish
|
||||
if tcpConn, ok := connection.(*net.TCPConn); ok {
|
||||
log.Debug("VMessIn closing write")
|
||||
tcpConn.CloseWrite();
|
||||
}
|
||||
<-readFinish
|
||||
|
||||
<-writeFinish
|
||||
if tcpConn, ok := connection.(*net.TCPConn); ok {
|
||||
log.Debug("VMessIn closing write")
|
||||
tcpConn.CloseWrite()
|
||||
}
|
||||
<-readFinish
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -103,17 +103,16 @@ func (handler *VMessInboundHandler) HandleConnection(connection net.Conn) error
|
||||
func (handler *VMessInboundHandler) dumpInput(reader io.Reader, input chan<- []byte, finish chan<- bool) {
|
||||
v2net.ReaderToChan(input, reader)
|
||||
close(input)
|
||||
log.Debug("VMessIn closing input")
|
||||
log.Debug("VMessIn closing input")
|
||||
finish <- true
|
||||
}
|
||||
|
||||
func (handler *VMessInboundHandler) dumpOutput(writer io.Writer, output <-chan []byte, finish chan<- bool) {
|
||||
v2net.ChanToWriter(writer, output)
|
||||
log.Debug("VMessOut closing output")
|
||||
log.Debug("VMessOut closing output")
|
||||
finish <- true
|
||||
}
|
||||
|
||||
|
||||
type VMessInboundHandlerFactory struct {
|
||||
}
|
||||
|
||||
|
||||
@@ -110,28 +110,28 @@ func (handler *VMessOutboundHandler) startCommunicate(request *vmessio.VMessRequ
|
||||
input := ray.OutboundInput()
|
||||
output := ray.OutboundOutput()
|
||||
readFinish := make(chan bool)
|
||||
writeFinish := make(chan bool)
|
||||
writeFinish := make(chan bool)
|
||||
|
||||
go handler.dumpInput(encryptRequestWriter, input, readFinish)
|
||||
go handler.dumpOutput(decryptResponseReader, output, writeFinish)
|
||||
|
||||
<-readFinish
|
||||
conn.CloseWrite()
|
||||
log.Debug("VMessOut closing write")
|
||||
<-writeFinish
|
||||
return nil
|
||||
|
||||
<-readFinish
|
||||
conn.CloseWrite()
|
||||
log.Debug("VMessOut closing write")
|
||||
<-writeFinish
|
||||
return nil
|
||||
}
|
||||
|
||||
func (handler *VMessOutboundHandler) dumpOutput(reader io.Reader, output chan<- []byte, finish chan<- bool) {
|
||||
v2net.ReaderToChan(output, reader)
|
||||
close(output)
|
||||
log.Debug("VMessOut closing output")
|
||||
log.Debug("VMessOut closing output")
|
||||
finish <- true
|
||||
}
|
||||
|
||||
func (handler *VMessOutboundHandler) dumpInput(writer io.Writer, input <-chan []byte, finish chan<- bool) {
|
||||
v2net.ChanToWriter(writer, input)
|
||||
log.Debug("VMessOut closing input")
|
||||
log.Debug("VMessOut closing input")
|
||||
finish <- true
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user