mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
TEST: Upgrade pion to v3.2.9. (#3567)
------ Co-authored-by: chundonglinlin <chundonglinlin@163.com>
This commit is contained in:
parent
104cf14d68
commit
df854339ea
1383 changed files with 118469 additions and 41421 deletions
|
@ -1,6 +1,6 @@
|
|||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2021 Winlin
|
||||
// # Copyright (c) 2021 Winlin
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// this software and associated documentation files (the "Software"), to deal in
|
||||
|
@ -25,14 +25,15 @@ import (
|
|||
|
||||
vnet_proxy "github.com/ossrs/srs-bench/vnet"
|
||||
"github.com/pion/logging"
|
||||
"github.com/pion/transport/vnet"
|
||||
"github.com/pion/transport/v2/vnet"
|
||||
)
|
||||
|
||||
// Proxy many vnet endpoint to one real server endpoint.
|
||||
// For example:
|
||||
// vnet(10.0.0.11:5787) => proxy => 192.168.1.10:8000
|
||||
// vnet(10.0.0.11:5788) => proxy => 192.168.1.10:8000
|
||||
// vnet(10.0.0.11:5789) => proxy => 192.168.1.10:8000
|
||||
//
|
||||
// vnet(10.0.0.11:5787) => proxy => 192.168.1.10:8000
|
||||
// vnet(10.0.0.11:5788) => proxy => 192.168.1.10:8000
|
||||
// vnet(10.0.0.11:5789) => proxy => 192.168.1.10:8000
|
||||
func ExampleUDPProxyManyToOne() { // nolint:govet
|
||||
var clientNetwork *vnet.Net
|
||||
|
||||
|
@ -105,8 +106,9 @@ func ExampleUDPProxyManyToOne() { // nolint:govet
|
|||
|
||||
// Proxy many vnet endpoint to one real server endpoint.
|
||||
// For example:
|
||||
// vnet(10.0.0.11:5787) => proxy => 192.168.1.10:8000
|
||||
// vnet(10.0.0.11:5788) => proxy => 192.168.1.10:8000
|
||||
//
|
||||
// vnet(10.0.0.11:5787) => proxy => 192.168.1.10:8000
|
||||
// vnet(10.0.0.11:5788) => proxy => 192.168.1.10:8000
|
||||
func ExampleUDPProxyMultileTimes() { // nolint:govet
|
||||
var clientNetwork *vnet.Net
|
||||
|
||||
|
@ -184,9 +186,10 @@ func ExampleUDPProxyMultileTimes() { // nolint:govet
|
|||
|
||||
// Proxy one vnet endpoint to one real server endpoint.
|
||||
// For example:
|
||||
// vnet(10.0.0.11:5787) => proxy0 => 192.168.1.10:8000
|
||||
// vnet(10.0.0.11:5788) => proxy1 => 192.168.1.10:8001
|
||||
// vnet(10.0.0.11:5789) => proxy2 => 192.168.1.10:8002
|
||||
//
|
||||
// vnet(10.0.0.11:5787) => proxy0 => 192.168.1.10:8000
|
||||
// vnet(10.0.0.11:5788) => proxy1 => 192.168.1.10:8001
|
||||
// vnet(10.0.0.11:5789) => proxy2 => 192.168.1.10:8002
|
||||
func ExampleUDPProxyOneToOne() { // nolint:govet
|
||||
var clientNetwork *vnet.Net
|
||||
|
||||
|
|
32
trunk/3rdparty/srs-bench/vnet/udpproxy.go
vendored
32
trunk/3rdparty/srs-bench/vnet/udpproxy.go
vendored
|
@ -10,19 +10,20 @@ import (
|
|||
// UDPProxy is a proxy between real server(net.UDPConn) and vnet.UDPConn.
|
||||
//
|
||||
// High level design:
|
||||
// ..............................................
|
||||
// : Virtual Network (vnet) :
|
||||
// : :
|
||||
// +-------+ * 1 +----+ +--------+ :
|
||||
// | :App |------------>|:Net|--o<-----|:Router | .............................
|
||||
// +-------+ +----+ | | : UDPProxy :
|
||||
// : | | +----+ +---------+ +---------+ +--------+
|
||||
// : | |--->o--|:Net|-->o-| vnet. |-->o-| net. |--->-| :Real |
|
||||
// : | | +----+ | UDPConn | | UDPConn | | Server |
|
||||
// : | | : +---------+ +---------+ +--------+
|
||||
// : | | ............................:
|
||||
// : +--------+ :
|
||||
// ...............................................
|
||||
//
|
||||
// ..............................................
|
||||
// : Virtual Network (vnet) :
|
||||
// : :
|
||||
// +-------+ * 1 +----+ +--------+ :
|
||||
// | :App |------------>|:Net|--o<-----|:Router | .............................
|
||||
// +-------+ +----+ | | : UDPProxy :
|
||||
// : | | +----+ +---------+ +---------+ +--------+
|
||||
// : | |--->o--|:Net|-->o-| vnet. |-->o-| net. |--->-| :Real |
|
||||
// : | | +----+ | UDPConn | | UDPConn | | Server |
|
||||
// : | | : +---------+ +---------+ +--------+
|
||||
// : | | ............................:
|
||||
// : +--------+ :
|
||||
// ...............................................
|
||||
type UDPProxy struct {
|
||||
// The router bind to.
|
||||
router *Router
|
||||
|
@ -109,9 +110,12 @@ func (v *aUDPProxyWorker) Close() error {
|
|||
|
||||
func (v *aUDPProxyWorker) Proxy(ctx context.Context, client *Net, serverAddr *net.UDPAddr) error { // nolint:gocognit
|
||||
// Create vnet for real server by serverAddr.
|
||||
nw := NewNet(&NetConfig{
|
||||
nw, err := NewNet(&NetConfig{
|
||||
StaticIP: serverAddr.IP.String(),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := v.router.AddNet(nw); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
//go:build !wasm
|
||||
// +build !wasm
|
||||
|
||||
package vnet
|
||||
|
@ -15,9 +16,13 @@ import (
|
|||
)
|
||||
|
||||
// The vnet client:
|
||||
// 10.0.0.11:5787
|
||||
//
|
||||
// 10.0.0.11:5787
|
||||
//
|
||||
// which proxy to real server:
|
||||
// 192.168.1.10:8000
|
||||
//
|
||||
// 192.168.1.10:8000
|
||||
//
|
||||
// We should get a reply if directly deliver to proxy.
|
||||
func TestUDPProxyDirectDeliverTypical(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
|
31
trunk/3rdparty/srs-bench/vnet/udpproxy_test.go
vendored
31
trunk/3rdparty/srs-bench/vnet/udpproxy_test.go
vendored
|
@ -1,3 +1,4 @@
|
|||
//go:build !wasm
|
||||
// +build !wasm
|
||||
|
||||
package vnet
|
||||
|
@ -90,9 +91,12 @@ func TestMain(m *testing.M) {
|
|||
}
|
||||
|
||||
// vnet client:
|
||||
// 10.0.0.11:5787
|
||||
//
|
||||
// 10.0.0.11:5787
|
||||
//
|
||||
// proxy to real server:
|
||||
// 192.168.1.10:8000
|
||||
//
|
||||
// 192.168.1.10:8000
|
||||
func TestUDPProxyOne2One(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
|
@ -235,10 +239,13 @@ func TestUDPProxyOne2One(t *testing.T) {
|
|||
}
|
||||
|
||||
// vnet client:
|
||||
// 10.0.0.11:5787
|
||||
// 10.0.0.11:5788
|
||||
//
|
||||
// 10.0.0.11:5787
|
||||
// 10.0.0.11:5788
|
||||
//
|
||||
// proxy to real server:
|
||||
// 192.168.1.10:8000
|
||||
//
|
||||
// 192.168.1.10:8000
|
||||
func TestUDPProxyTwo2One(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
|
@ -409,14 +416,20 @@ func TestUDPProxyTwo2One(t *testing.T) {
|
|||
}
|
||||
|
||||
// vnet client:
|
||||
// 10.0.0.11:5787
|
||||
//
|
||||
// 10.0.0.11:5787
|
||||
//
|
||||
// proxy to real server:
|
||||
// 192.168.1.10:8000
|
||||
//
|
||||
// 192.168.1.10:8000
|
||||
//
|
||||
// vnet client:
|
||||
// 10.0.0.11:5788
|
||||
//
|
||||
// 10.0.0.11:5788
|
||||
//
|
||||
// proxy to real server:
|
||||
// 192.168.1.10:8000
|
||||
//
|
||||
// 192.168.1.10:8000
|
||||
func TestUDPProxyProxyTwice(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
|
|
6
trunk/3rdparty/srs-bench/vnet/vnet.go
vendored
6
trunk/3rdparty/srs-bench/vnet/vnet.go
vendored
|
@ -1,6 +1,6 @@
|
|||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2021 Winlin
|
||||
// # Copyright (c) 2021 Winlin
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// this software and associated documentation files (the "Software"), to deal in
|
||||
|
@ -21,7 +21,7 @@
|
|||
package vnet
|
||||
|
||||
import (
|
||||
"github.com/pion/transport/vnet"
|
||||
"github.com/pion/transport/v2/vnet"
|
||||
)
|
||||
|
||||
type Router = vnet.Router
|
||||
|
@ -30,7 +30,7 @@ type Net = vnet.Net
|
|||
type NetConfig = vnet.NetConfig
|
||||
type RouterConfig = vnet.RouterConfig
|
||||
|
||||
func NewNet(config *NetConfig) *Net {
|
||||
func NewNet(config *NetConfig) (*Net, error) {
|
||||
return vnet.NewNet(config)
|
||||
}
|
||||
func NewRouter(config *RouterConfig) (*Router, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue