transx/main_test.go

49 lines
737 B
Go
Raw Normal View History

package main
import(
"testing"
"net"
)
func server(){
listener,err=net.Listen("tcp4","0.0.0.0:1234")
if err!=nil{
t.Fatal(err)
}
for {
conn,err:=listener.Accept()
if err!=nil{
t.Fatal(err)
}
bytes:=make([]byte,32)
n,err:=conn.Read(bytes)
t.Log("Server Receive ",bytes[:n])
_,err:=conn.Write([]byte("OK"))
if err!=nil{
t.Fatail(err)
}
conn.Close()
}
}
func client(){
conn,err:=net.Dial("tcp4","0.0.0.0:1234")
if err!=nil{
t.Fatail(err)
}
for{
conn.Write([]byte("Client"))
bytes:=make([]byte,32)
n,err:=conn.Read(byte)
if err!=nil{
t.Fatal(err)
}
t.Log("Client Receive ",bytes[:n])
conn.Close()
}
}
func TestTunnel(t *testing.T)
{
StartTunnel("0.0.0.0","1200","0.0.0.0",)
}