2022-07-28 11:00:05 -04:00
|
|
|
package node_test
|
2022-06-01 13:35:41 -04:00
|
|
|
|
|
|
|
import (
|
2022-08-16 01:04:33 -04:00
|
|
|
"github.com/Yuzuki616/V2bX/api/panel"
|
2022-07-28 11:00:05 -04:00
|
|
|
. "github.com/Yuzuki616/V2bX/node"
|
2022-06-01 13:35:41 -04:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestBuildV2ray(t *testing.T) {
|
2022-08-16 01:04:33 -04:00
|
|
|
nodeInfo := &panel.NodeInfo{
|
2022-06-01 13:35:41 -04:00
|
|
|
NodeType: "V2ray",
|
|
|
|
NodeID: 1,
|
|
|
|
Port: 1145,
|
|
|
|
SpeedLimit: 0,
|
|
|
|
AlterID: 2,
|
|
|
|
TransportProtocol: "ws",
|
|
|
|
Host: "test.test.tk",
|
|
|
|
Path: "v2ray",
|
|
|
|
EnableTLS: false,
|
|
|
|
TLSType: "tls",
|
|
|
|
}
|
|
|
|
certConfig := &CertConfig{
|
|
|
|
CertMode: "http",
|
|
|
|
CertDomain: "test.test.tk",
|
|
|
|
Provider: "alidns",
|
|
|
|
Email: "test@gmail.com",
|
|
|
|
}
|
|
|
|
config := &Config{
|
|
|
|
CertConfig: certConfig,
|
|
|
|
}
|
|
|
|
_, err := InboundBuilder(config, nodeInfo)
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestBuildTrojan(t *testing.T) {
|
2022-08-16 01:04:33 -04:00
|
|
|
nodeInfo := &panel.NodeInfo{
|
2022-06-01 13:35:41 -04:00
|
|
|
NodeType: "Trojan",
|
|
|
|
NodeID: 1,
|
|
|
|
Port: 1145,
|
|
|
|
SpeedLimit: 0,
|
|
|
|
AlterID: 2,
|
|
|
|
TransportProtocol: "tcp",
|
|
|
|
Host: "trojan.test.tk",
|
|
|
|
Path: "v2ray",
|
|
|
|
EnableTLS: false,
|
|
|
|
TLSType: "tls",
|
|
|
|
}
|
|
|
|
DNSEnv := make(map[string]string)
|
|
|
|
DNSEnv["ALICLOUD_ACCESS_KEY"] = "aaa"
|
|
|
|
DNSEnv["ALICLOUD_SECRET_KEY"] = "bbb"
|
|
|
|
certConfig := &CertConfig{
|
|
|
|
CertMode: "dns",
|
|
|
|
CertDomain: "trojan.test.tk",
|
|
|
|
Provider: "alidns",
|
|
|
|
Email: "test@gmail.com",
|
|
|
|
DNSEnv: DNSEnv,
|
|
|
|
}
|
|
|
|
config := &Config{
|
|
|
|
CertConfig: certConfig,
|
|
|
|
}
|
|
|
|
_, err := InboundBuilder(config, nodeInfo)
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestBuildSS(t *testing.T) {
|
2022-08-16 01:04:33 -04:00
|
|
|
nodeInfo := &panel.NodeInfo{
|
2022-06-01 13:35:41 -04:00
|
|
|
NodeType: "Shadowsocks",
|
|
|
|
NodeID: 1,
|
|
|
|
Port: 1145,
|
|
|
|
SpeedLimit: 0,
|
|
|
|
AlterID: 2,
|
|
|
|
TransportProtocol: "tcp",
|
|
|
|
Host: "test.test.tk",
|
|
|
|
Path: "v2ray",
|
|
|
|
EnableTLS: false,
|
|
|
|
TLSType: "tls",
|
|
|
|
}
|
|
|
|
DNSEnv := make(map[string]string)
|
|
|
|
DNSEnv["ALICLOUD_ACCESS_KEY"] = "aaa"
|
|
|
|
DNSEnv["ALICLOUD_SECRET_KEY"] = "bbb"
|
|
|
|
certConfig := &CertConfig{
|
|
|
|
CertMode: "dns",
|
|
|
|
CertDomain: "trojan.test.tk",
|
|
|
|
Provider: "alidns",
|
|
|
|
Email: "test@me.com",
|
|
|
|
DNSEnv: DNSEnv,
|
|
|
|
}
|
|
|
|
config := &Config{
|
|
|
|
CertConfig: certConfig,
|
|
|
|
}
|
|
|
|
_, err := InboundBuilder(config, nodeInfo)
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
}
|