Browse Source

load srtp in main

pull/2034/head
v2ray 8 years ago
parent
commit
c7d6302292
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
  1. 2
      shell/point/main/main.go
  2. 2
      transport/internet/authenticators/srtp/srtp.go
  3. 9
      transport/internet/kcp/config_json.go
  4. 4
      transport/internet/kcp/connection_test.go
  5. 4
      transport/internet/kcp/dialer.go

2
shell/point/main/main.go

@ -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 (

2
transport/internet/internal/obsrtp/obsrtp.go → transport/internet/authenticators/srtp/srtp.go

@ -1,4 +1,4 @@
package obsrtp
package srtp
import (
"math/rand"

9
transport/internet/kcp/config_json.go

@ -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

4
transport/internet/kcp/connection_test.go

@ -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)

4
transport/internet/kcp/dialer.go

@ -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…
Cancel
Save