mirror of https://github.com/v2ray/v2ray-core
load srtp in main
parent
6ffc24f895
commit
c7d6302292
|
@ -25,6 +25,8 @@ import (
|
|||
_ "github.com/v2ray/v2ray-core/transport/internet/kcp"
|
||||
_ "github.com/v2ray/v2ray-core/transport/internet/tcp"
|
||||
_ "github.com/v2ray/v2ray-core/transport/internet/udp"
|
||||
|
||||
_ "github.com/v2ray/v2ray-core/transport/internet/authenticators/srtp"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package obsrtp
|
||||
package srtp
|
||||
|
||||
import (
|
||||
"math/rand"
|
|
@ -7,6 +7,7 @@ import (
|
|||
|
||||
"github.com/v2ray/v2ray-core/common"
|
||||
"github.com/v2ray/v2ray-core/common/log"
|
||||
"github.com/v2ray/v2ray-core/transport/internet"
|
||||
)
|
||||
|
||||
func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
|
@ -66,7 +67,13 @@ func (this *Config) UnmarshalJSON(data []byte) error {
|
|||
}
|
||||
}
|
||||
if len(jsonConfig.HeaderConfig) > 0 {
|
||||
this.HeaderConfig = jsonConfig.HeaderConfig
|
||||
name, config, err := internet.CreateAuthenticatorConfig(jsonConfig.HeaderConfig)
|
||||
if err != nil {
|
||||
log.Error("KCP|Config: Failed to parse header config: ", err)
|
||||
return err
|
||||
}
|
||||
this.HeaderType = name
|
||||
this.HeaderConfig = config
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||
"github.com/v2ray/v2ray-core/testing/assert"
|
||||
"github.com/v2ray/v2ray-core/transport/internet"
|
||||
"github.com/v2ray/v2ray-core/transport/internet/internal/obsrtp"
|
||||
"github.com/v2ray/v2ray-core/transport/internet/authenticators/srtp"
|
||||
. "github.com/v2ray/v2ray-core/transport/internet/kcp"
|
||||
)
|
||||
|
||||
|
@ -42,7 +42,7 @@ func TestConnectionReadWrite(t *testing.T) {
|
|||
upReader, upWriter := io.Pipe()
|
||||
downReader, downWriter := io.Pipe()
|
||||
|
||||
auth := internet.NewAuthenticatorChain(obsrtp.ObfuscatorSRTPFactory{}.Create(nil), NewSimpleAuthenticator())
|
||||
auth := internet.NewAuthenticatorChain(srtp.ObfuscatorSRTPFactory{}.Create(nil), NewSimpleAuthenticator())
|
||||
|
||||
connClient := NewConnection(1, upWriter, &net.UDPAddr{IP: v2net.LocalHostIP.IP(), Port: 1}, &net.UDPAddr{IP: v2net.LocalHostIP.IP(), Port: 2}, auth)
|
||||
connClient.FetchInputFrom(downReader)
|
||||
|
|
|
@ -16,14 +16,16 @@ var (
|
|||
|
||||
func DialKCP(src v2net.Address, dest v2net.Destination) (internet.Connection, error) {
|
||||
udpDest := v2net.UDPDestination(dest.Address(), dest.Port())
|
||||
log.Info("Dialling KCP to ", udpDest)
|
||||
log.Info("KCP|Dialer: Dialing KCP to ", udpDest)
|
||||
conn, err := internet.DialToDest(src, udpDest)
|
||||
if err != nil {
|
||||
log.Error("KCP|Dialer: Failed to dial to dest: ", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cpip, err := effectiveConfig.GetAuthenticator()
|
||||
if err != nil {
|
||||
log.Error("KCP|Dialer: Failed to create authenticator: ", err)
|
||||
return nil, err
|
||||
}
|
||||
conv := uint16(atomic.AddUint32(&globalConv, 1))
|
||||
|
|
Loading…
Reference in New Issue