star/netforward/forward_test.go
2024-06-29 20:06:14 +08:00

35 lines
543 B
Go

package netforward
import (
"fmt"
"testing"
"time"
)
func TestForward(t *testing.T) {
var f = NetForward{
LocalAddr: "127.0.0.1",
LocalPort: 22232,
RemoteURI: "192.168.2.1:80",
EnableTCP: true,
EnableUDP: true,
DialTimeout: 6 * time.Second,
UDPTimeout: 7 * time.Second,
}
f.Run()
go func() {
time.Sleep(time.Second * 10)
fmt.Println("closing")
f.Close()
}()
for {
time.Sleep(time.Second * 2)
if f.Status() > 0 {
fmt.Println(f.Status())
continue
}
break
}
time.Sleep(time.Second * 5)
}