12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- package main
- import (
- "net/netip"
- "testing"
- C "github.com/sagernet/sing-box/constant"
- "github.com/sagernet/sing-box/option"
- "github.com/sagernet/sing/common"
- "github.com/sagernet/sing/common/json/badoption"
- "github.com/gofrs/uuid/v5"
- )
- func TestTUICDomainUDP(t *testing.T) {
- _, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
- startInstance(t, option.Options{
- Inbounds: []option.Inbound{
- {
- Type: C.TypeMixed,
- Tag: "mixed-in",
- Options: &option.HTTPMixedInboundOptions{
- ListenOptions: option.ListenOptions{
- Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
- ListenPort: clientPort,
- },
- },
- },
- {
- Type: C.TypeTUIC,
- Options: &option.TUICInboundOptions{
- ListenOptions: option.ListenOptions{
- Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())),
- ListenPort: serverPort,
- InboundOptions: option.InboundOptions{
- DomainStrategy: option.DomainStrategy(C.DomainStrategyIPv6Only),
- },
- },
- Users: []option.TUICUser{{
- UUID: uuid.Nil.String(),
- }},
- InboundTLSOptionsContainer: option.InboundTLSOptionsContainer{
- TLS: &option.InboundTLSOptions{
- Enabled: true,
- ServerName: "example.org",
- CertificatePath: certPem,
- KeyPath: keyPem,
- },
- },
- },
- },
- },
- Outbounds: []option.Outbound{
- {
- Type: C.TypeDirect,
- },
- {
- Type: C.TypeTUIC,
- Tag: "tuic-out",
- Options: &option.TUICOutboundOptions{
- ServerOptions: option.ServerOptions{
- Server: "127.0.0.1",
- ServerPort: serverPort,
- },
- UUID: uuid.Nil.String(),
- OutboundTLSOptionsContainer: option.OutboundTLSOptionsContainer{
- TLS: &option.OutboundTLSOptions{
- Enabled: true,
- ServerName: "example.org",
- CertificatePath: certPem,
- },
- },
- },
- },
- },
- Route: &option.RouteOptions{
- Rules: []option.Rule{
- {
- Type: C.RuleTypeDefault,
- DefaultOptions: option.DefaultRule{
- RawDefaultRule: option.RawDefaultRule{
- Inbound: []string{"mixed-in"},
- },
- RuleAction: option.RuleAction{
- Action: C.RuleActionTypeRoute,
- RouteOptions: option.RouteActionOptions{
- Outbound: "tuic-out",
- },
- },
- },
- },
- },
- },
- })
- testQUIC(t, clientPort)
- }
|