mirror of
https://github.com/schollz/croc.git
synced 2024-11-28 17:44:51 +03:00
commit
8ee1825f84
@ -37,10 +37,9 @@ type roomMap struct {
|
|||||||
sync.Mutex
|
sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const pingRoom = "pinglkasjdlfjsaldjf"
|
||||||
timeToRoomDeletion = 10 * time.Minute
|
|
||||||
pingRoom = "pinglkasjdlfjsaldjf"
|
var timeToRoomDeletion = 10 * time.Minute
|
||||||
)
|
|
||||||
|
|
||||||
// Run starts a tcp listener, run async
|
// Run starts a tcp listener, run async
|
||||||
func Run(debugLevel, host, port, password string, banner ...string) (err error) {
|
func Run(debugLevel, host, port, password string, banner ...string) (err error) {
|
||||||
|
@ -25,13 +25,13 @@ func TestTCP(t *testing.T) {
|
|||||||
log.SetLevel("error")
|
log.SetLevel("error")
|
||||||
timeToRoomDeletion = 100 * time.Millisecond
|
timeToRoomDeletion = 100 * time.Millisecond
|
||||||
go Run("debug", "localhost", "8281", "pass123", "8282")
|
go Run("debug", "localhost", "8281", "pass123", "8282")
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(timeToRoomDeletion)
|
||||||
err := PingServer("localhost:8281")
|
err := PingServer("localhost:8281")
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
err = PingServer("localhost:8333")
|
err = PingServer("localhost:8333")
|
||||||
assert.NotNil(t, err)
|
assert.NotNil(t, err)
|
||||||
|
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(timeToRoomDeletion)
|
||||||
c1, banner, _, err := ConnectToTCPServer("localhost:8281", "pass123", "testRoom", 1*time.Minute)
|
c1, banner, _, err := ConnectToTCPServer("localhost:8281", "pass123", "testRoom", 1*time.Minute)
|
||||||
assert.Equal(t, banner, "8282")
|
assert.Equal(t, banner, "8282")
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
Loading…
Reference in New Issue
Block a user