remoton

Check-in [4c8cfc4a9b]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:test concurrent connections to virtual socket
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256: 4c8cfc4a9bdda6b6fe1f5f02cc85caf00014c61256ca99818ae30542002ba6af
User & Date: bit4bit@riseup.net 2016-01-23 21:15:13
Context
2016-01-23
21:29
timeout on dial check-in: f7b7162711 user: bit4bit@riseup.net tags: master, trunk
21:15
test concurrent connections to virtual socket check-in: 4c8cfc4a9b user: bit4bit@riseup.net tags: master, trunk
2015-08-19
03:38
merge check-in: 8c7b3188c5 user: bit4bit@riseup.net tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to server_test.go.

1
2
3
4
5
6
7


8
9
10
11
12

13
14
15
16
17
18
19
..
32
33
34
35
36
37
38

39
40
41
42
43
44
45
46



47

48
49



50



51








52








53
54
55
56
57
58
59
package remoton

import (
	"bufio"
	"crypto/tls"
	"net/http"
	"net/http/httptest"


	"testing"
)

//TestDialAndListen test websocket tunnel
func TestDialAndListen(t *testing.T) {

	mux := http.NewServeMux()
	mux.Handle("/remoton/", http.StripPrefix("/remoton", NewServer(
		func(authToken string, r *http.Request) bool {
			return authToken == "testsrv"
		},
		func() string {
			return "testid"
................................................................................
		t.Fatal(err)
	}
	defer session.Destroy()

	go func() {
		listener := session.Listen("test")


		lconn, err := listener.Accept()
		if err != nil {
			t.Error(err)
		}
		data, _ := bufio.NewReader(lconn).ReadString('\n')

		if data != "transfer" {
			t.Errorf("want %v get %v", "transfer", data)



		}

	}()




	dconn, err := session.Dial("test")



	dconn.Write([]byte("transfer"))








	dconn.Close()








}

//TestDialAndListenTCP tcp tunnel
func TestDialAndListenTCP(t *testing.T) {

	ts := httptest.NewTLSServer(NewServer(
		func(authToken string, r *http.Request) bool {







>
>





>







 







>
|
|
|
|
|
<
|
|
>
>
>
|
>


>
>
>
|
>
>
>
|
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
35
36
37
38
39
40
41
42
43
44
45
46
47

48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package remoton

import (
	"bufio"
	"crypto/tls"
	"net/http"
	"net/http/httptest"
	"strings"
	"sync"
	"testing"
)

//TestDialAndListen test websocket tunnel
func TestDialAndListen(t *testing.T) {
	maxConns := 10
	mux := http.NewServeMux()
	mux.Handle("/remoton/", http.StripPrefix("/remoton", NewServer(
		func(authToken string, r *http.Request) bool {
			return authToken == "testsrv"
		},
		func() string {
			return "testid"
................................................................................
		t.Fatal(err)
	}
	defer session.Destroy()

	go func() {
		listener := session.Listen("test")

		for i := 0; i < maxConns; i++ {
			lconn, err := listener.Accept()
			if err != nil {
				t.Error(err)
			}
			data, _ := bufio.NewReader(lconn).ReadString('\n')

			if strings.TrimSpace(data) != "transfer" {
				t.Errorf("want %v get %v", "transfer", data)
			} else {
				lconn.Write([]byte("feedback"))
				lconn.Write([]byte{'\n'})
			}
		}
	}()

	wg := &sync.WaitGroup{}
	worker := func() {
		go func() {
			dconn, err := session.Dial("test")
			if err != nil {
				t.Fatal(err)
			}
			dconn.Write([]byte("transfer"))
			dconn.Write([]byte{'\n'})
			data, err := bufio.NewReader(dconn).ReadString('\n')
			if err != nil {
				t.Error(err)
			}
			if strings.TrimSpace(data) != "feedback" {
				t.Errorf("want %v get %v", "feedback", data)
			}
			dconn.Close()
			wg.Done()
		}()
	}
	for i := 0; i < maxConns; i++ {
		wg.Add(1)
		worker()
	}
	wg.Wait()
}

//TestDialAndListenTCP tcp tunnel
func TestDialAndListenTCP(t *testing.T) {

	ts := httptest.NewTLSServer(NewServer(
		func(authToken string, r *http.Request) bool {