2023-06-08 10:46:33 -04:00
|
|
|
package hy
|
|
|
|
|
|
|
|
import (
|
2023-06-24 20:22:05 -04:00
|
|
|
"encoding/base64"
|
2023-07-27 21:13:11 -04:00
|
|
|
"log"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2023-06-08 10:46:33 -04:00
|
|
|
"github.com/Yuzuki616/V2bX/api/panel"
|
|
|
|
"github.com/Yuzuki616/V2bX/conf"
|
2023-06-24 20:22:05 -04:00
|
|
|
"github.com/Yuzuki616/V2bX/limiter"
|
2023-06-09 00:36:49 -04:00
|
|
|
"github.com/sirupsen/logrus"
|
2023-06-08 10:46:33 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestServer(t *testing.T) {
|
2023-06-09 00:36:49 -04:00
|
|
|
logrus.SetLevel(logrus.DebugLevel)
|
2023-06-24 20:22:05 -04:00
|
|
|
limiter.Init()
|
|
|
|
l := limiter.AddLimiter("test", &conf.LimitConfig{}, nil)
|
|
|
|
s := NewServer("test", l)
|
2023-06-08 10:46:33 -04:00
|
|
|
t.Log(s.runServer(&panel.NodeInfo{
|
2023-06-24 20:22:05 -04:00
|
|
|
Port: 1145,
|
2023-06-08 10:46:33 -04:00
|
|
|
UpMbps: 100,
|
|
|
|
DownMbps: 100,
|
|
|
|
HyObfs: "atresssdaaaadd",
|
2023-07-29 06:47:47 -04:00
|
|
|
}, &conf.Options{
|
2023-06-08 10:46:33 -04:00
|
|
|
ListenIP: "127.0.0.1",
|
2023-06-09 00:36:49 -04:00
|
|
|
HyOptions: conf.HyOptions{},
|
2023-06-08 10:46:33 -04:00
|
|
|
CertConfig: &conf.CertConfig{
|
|
|
|
CertFile: "../../test_data/1.pem",
|
|
|
|
KeyFile: "../../test_data/1.key",
|
|
|
|
},
|
|
|
|
}))
|
2023-06-09 00:36:49 -04:00
|
|
|
s.users.Store("test1111", struct{}{})
|
2023-06-24 20:22:05 -04:00
|
|
|
go func() {
|
|
|
|
for {
|
|
|
|
time.Sleep(10 * time.Second)
|
|
|
|
auth := base64.StdEncoding.EncodeToString([]byte("test1111"))
|
|
|
|
log.Println(auth)
|
2023-07-29 06:47:47 -04:00
|
|
|
log.Println(s.counter.GetUpCount(auth))
|
2023-06-24 20:22:05 -04:00
|
|
|
}
|
|
|
|
}()
|
2023-06-08 10:46:33 -04:00
|
|
|
select {}
|
|
|
|
}
|