1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- package main
- import (
- "net/netip"
- "testing"
- C "github.com/sagernet/sing-box/constant"
- "github.com/sagernet/sing-box/option"
- "github.com/sagernet/sing-shadowsocks/shadowaead_2022"
- )
- func TestChainedInbound(t *testing.T) {
- method := shadowaead_2022.List[0]
- password := mkBase64(t, 16)
- startInstance(t, option.Options{
- Inbounds: []option.Inbound{
- {
- Type: C.TypeMixed,
- Tag: "mixed-in",
- MixedOptions: option.HTTPMixedInboundOptions{
- ListenOptions: option.ListenOptions{
- Listen: option.NewListenAddress(netip.IPv4Unspecified()),
- ListenPort: clientPort,
- },
- },
- },
- {
- Type: C.TypeShadowsocks,
- ShadowsocksOptions: option.ShadowsocksInboundOptions{
- ListenOptions: option.ListenOptions{
- Listen: option.NewListenAddress(netip.IPv4Unspecified()),
- ListenPort: serverPort,
- Detour: "detour",
- },
- Method: method,
- Password: password,
- },
- },
- {
- Type: C.TypeShadowsocks,
- Tag: "detour",
- ShadowsocksOptions: option.ShadowsocksInboundOptions{
- ListenOptions: option.ListenOptions{
- Listen: option.NewListenAddress(netip.IPv4Unspecified()),
- ListenPort: otherPort,
- },
- Method: method,
- Password: password,
- },
- },
- },
- Outbounds: []option.Outbound{
- {
- Type: C.TypeDirect,
- },
- {
- Type: C.TypeShadowsocks,
- Tag: "ss-out",
- ShadowsocksOptions: option.ShadowsocksOutboundOptions{
- Method: method,
- Password: password,
- DialerOptions: option.DialerOptions{
- Detour: "detour-out",
- },
- },
- },
- {
- Type: C.TypeShadowsocks,
- Tag: "detour-out",
- ShadowsocksOptions: option.ShadowsocksOutboundOptions{
- ServerOptions: option.ServerOptions{
- Server: "127.0.0.1",
- ServerPort: serverPort,
- },
- Method: method,
- Password: password,
- },
- },
- },
- Route: &option.RouteOptions{
- Rules: []option.Rule{
- {
- DefaultOptions: option.DefaultRule{
- Inbound: []string{"mixed-in"},
- Outbound: "ss-out",
- },
- },
- },
- },
- })
- testTCP(t, clientPort, testPort)
- }
|