2020-11-25 11:01:53 +00:00
|
|
|
package internet_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-12-04 01:36:16 +00:00
|
|
|
"github.com/xtls/xray-core/common"
|
|
|
|
. "github.com/xtls/xray-core/transport/internet"
|
|
|
|
"github.com/xtls/xray-core/transport/internet/headers/noop"
|
|
|
|
"github.com/xtls/xray-core/transport/internet/headers/srtp"
|
|
|
|
"github.com/xtls/xray-core/transport/internet/headers/utp"
|
|
|
|
"github.com/xtls/xray-core/transport/internet/headers/wechat"
|
|
|
|
"github.com/xtls/xray-core/transport/internet/headers/wireguard"
|
2020-11-25 11:01:53 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestAllHeadersLoadable(t *testing.T) {
|
|
|
|
testCases := []struct {
|
|
|
|
Input interface{}
|
|
|
|
Size int32
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
Input: new(noop.Config),
|
|
|
|
Size: 0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Input: new(srtp.Config),
|
|
|
|
Size: 4,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Input: new(utp.Config),
|
|
|
|
Size: 4,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Input: new(wechat.VideoConfig),
|
|
|
|
Size: 13,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Input: new(wireguard.WireguardConfig),
|
|
|
|
Size: 4,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, testCase := range testCases {
|
|
|
|
header, err := CreatePacketHeader(testCase.Input)
|
|
|
|
common.Must(err)
|
|
|
|
if header.Size() != testCase.Size {
|
|
|
|
t.Error("expected size ", testCase.Size, " but got ", header.Size())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|