You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
515 B
Go
34 lines
515 B
Go
11 months ago
|
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
|
||
|
}
|
||
|
return
|
||
|
}
|
||
|
}
|