mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-12-16 20:27:04 +03:00
Some checks failed
Scheduled assets update / geodat (push) Has been cancelled
Build and Release for Windows 7 / check-assets (push) Has been cancelled
Build and Release / check-assets (push) Has been cancelled
Test / check-assets (push) Has been cancelled
Build and Release for Windows 7 / build (win7-32, 386, windows) (push) Has been cancelled
Build and Release for Windows 7 / build (win7-64, amd64, windows) (push) Has been cancelled
Build and Release / build (386, freebsd, ) (push) Has been cancelled
Build and Release / build (386, linux, ) (push) Has been cancelled
Build and Release / build (386, openbsd, ) (push) Has been cancelled
Build and Release / build (386, windows, ) (push) Has been cancelled
Build and Release / build (amd64, android, android-amd64) (push) Has been cancelled
Build and Release / build (amd64, darwin, ) (push) Has been cancelled
Build and Release / build (amd64, freebsd, ) (push) Has been cancelled
Build and Release / build (amd64, linux, ) (push) Has been cancelled
Build and Release / build (amd64, openbsd, ) (push) Has been cancelled
Build and Release / build (amd64, windows, ) (push) Has been cancelled
Build and Release / build (arm, 5, linux) (push) Has been cancelled
Build and Release / build (arm, 6, linux) (push) Has been cancelled
Build and Release / build (arm, 7, freebsd) (push) Has been cancelled
Build and Release / build (arm, 7, linux) (push) Has been cancelled
Build and Release / build (arm, 7, openbsd) (push) Has been cancelled
Build and Release / build (arm, 7, windows) (push) Has been cancelled
Build and Release / build (arm64, android) (push) Has been cancelled
Build and Release / build (arm64, darwin) (push) Has been cancelled
Build and Release / build (arm64, freebsd) (push) Has been cancelled
Build and Release / build (arm64, linux) (push) Has been cancelled
Build and Release / build (arm64, openbsd) (push) Has been cancelled
Build and Release / build (arm64, windows) (push) Has been cancelled
Build and Release / build (loong64, linux) (push) Has been cancelled
Build and Release / build (mips, linux) (push) Has been cancelled
Build and Release / build (mips64, linux) (push) Has been cancelled
Build and Release / build (mips64le, linux) (push) Has been cancelled
Build and Release / build (mipsle, linux) (push) Has been cancelled
Build and Release / build (ppc64, linux) (push) Has been cancelled
Build and Release / build (ppc64le, linux) (push) Has been cancelled
Build and Release / build (riscv64, linux) (push) Has been cancelled
Build and Release / build (s390x, linux) (push) Has been cancelled
Test / test (macos-latest) (push) Has been cancelled
Test / test (ubuntu-latest) (push) Has been cancelled
Test / test (windows-latest) (push) Has been cancelled
https://github.com/XTLS/Xray-core/pull/5124#issuecomment-3281091009 Fixes https://github.com/XTLS/Xray-core/pull/5124#pullrequestreview-3218097421
114 lines
2.3 KiB
Go
114 lines
2.3 KiB
Go
package conf_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/xtls/xray-core/common/net"
|
|
"github.com/xtls/xray-core/common/protocol"
|
|
"github.com/xtls/xray-core/common/serial"
|
|
. "github.com/xtls/xray-core/infra/conf"
|
|
"github.com/xtls/xray-core/proxy/socks"
|
|
)
|
|
|
|
func TestSocksInboundConfig(t *testing.T) {
|
|
creator := func() Buildable {
|
|
return new(SocksServerConfig)
|
|
}
|
|
|
|
runMultiTestCase(t, []TestCase{
|
|
{
|
|
Input: `{
|
|
"auth": "password",
|
|
"accounts": [
|
|
{
|
|
"user": "my-username",
|
|
"pass": "my-password"
|
|
}
|
|
],
|
|
"udp": false,
|
|
"ip": "127.0.0.1",
|
|
"userLevel": 1
|
|
}`,
|
|
Parser: loadJSON(creator),
|
|
Output: &socks.ServerConfig{
|
|
AuthType: socks.AuthType_PASSWORD,
|
|
Accounts: map[string]string{
|
|
"my-username": "my-password",
|
|
},
|
|
UdpEnabled: false,
|
|
Address: &net.IPOrDomain{
|
|
Address: &net.IPOrDomain_Ip{
|
|
Ip: []byte{127, 0, 0, 1},
|
|
},
|
|
},
|
|
UserLevel: 1,
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
func TestSocksOutboundConfig(t *testing.T) {
|
|
creator := func() Buildable {
|
|
return new(SocksClientConfig)
|
|
}
|
|
|
|
runMultiTestCase(t, []TestCase{
|
|
{
|
|
Input: `{
|
|
"servers": [{
|
|
"address": "127.0.0.1",
|
|
"port": 1234,
|
|
"users": [
|
|
{"user": "test user", "pass": "test pass", "email": "test@email.com"}
|
|
]
|
|
}]
|
|
}`,
|
|
Parser: loadJSON(creator),
|
|
Output: &socks.ClientConfig{
|
|
Server: &protocol.ServerEndpoint{
|
|
Address: &net.IPOrDomain{
|
|
Address: &net.IPOrDomain_Ip{
|
|
Ip: []byte{127, 0, 0, 1},
|
|
},
|
|
},
|
|
Port: 1234,
|
|
User: &protocol.User{
|
|
Email: "test@email.com",
|
|
Account: serial.ToTypedMessage(&socks.Account{
|
|
Username: "test user",
|
|
Password: "test pass",
|
|
}),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
Input: `{
|
|
"address": "127.0.0.1",
|
|
"port": 1234,
|
|
"user": "test user",
|
|
"pass": "test pass",
|
|
"email": "test@email.com"
|
|
}`,
|
|
Parser: loadJSON(creator),
|
|
Output: &socks.ClientConfig{
|
|
Server: &protocol.ServerEndpoint{
|
|
Address: &net.IPOrDomain{
|
|
Address: &net.IPOrDomain_Ip{
|
|
Ip: []byte{127, 0, 0, 1},
|
|
},
|
|
},
|
|
Port: 1234,
|
|
User: &protocol.User{
|
|
Email: "test@email.com",
|
|
Account: serial.ToTypedMessage(&socks.Account{
|
|
Username: "test user",
|
|
Password: "test pass",
|
|
}),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
}
|