本文整理匯總了Golang中github.com/v2ray/v2ray-core/io/vmess.VMessRequest.Command方法的典型用法代碼示例。如果您正苦於以下問題:Golang VMessRequest.Command方法的具體用法?Golang VMessRequest.Command怎麽用?Golang VMessRequest.Command使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/v2ray/v2ray-core/io/vmess.VMessRequest
的用法示例。
在下文中一共展示了VMessRequest.Command方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Start
func (handler *VMessOutboundHandler) Start(ray core.OutboundRay) error {
vNextAddress, vNextUser := handler.pickVNext()
request := new(vmessio.VMessRequest)
request.Version = vmessio.Version
request.UserId = vNextUser.Id
rand.Read(request.RequestIV[:])
rand.Read(request.RequestKey[:])
rand.Read(request.ResponseHeader[:])
request.Command = byte(0x01)
request.Address = handler.dest
go handler.startCommunicate(request, vNextAddress, ray)
return nil
}
示例2: Start
func (handler *VMessOutboundHandler) Start(ray core.OutboundVRay) error {
vNextAddress, vNextUser := handler.pickVNext()
request := new(vmessio.VMessRequest)
request.Version = vmessio.Version
request.UserId = vNextUser.Id
rand.Read(request.RequestIV[:])
rand.Read(request.RequestKey[:])
rand.Read(request.ResponseHeader[:])
request.Command = byte(0x01)
request.Address = handler.dest
conn, err := net.Dial("tcp", vNextAddress.String())
if err != nil {
return err
}
defer conn.Close()
requestWriter := vmessio.NewVMessRequestWriter()
requestWriter.Write(conn, request)
requestKey := request.RequestKey[:]
requestIV := request.RequestIV[:]
responseKey := md5.Sum(requestKey)
responseIV := md5.Sum(requestIV)
encryptRequestWriter, err := v2io.NewAesEncryptWriter(requestKey, requestIV, conn)
if err != nil {
return err
}
responseReader, err := v2io.NewAesDecryptReader(responseKey[:], responseIV[:], conn)
if err != nil {
return err
}
input := ray.OutboundInput()
output := ray.OutboundOutput()
finish := make(chan bool, 2)
go handler.dumpInput(encryptRequestWriter, input, finish)
go handler.dumpOutput(responseReader, output, finish)
handler.waitForFinish(finish)
return nil
}