remoton

Check-in [f7b7162711]

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

Overview
Comment:timeout on dial
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256: f7b71627118d34a891f212d082fb68e2df7a6875fa38123720c65cc8ec953926
User & Date: bit4bit@riseup.net 2016-01-23 21:29:15
Context
2016-08-04
14:10
cmd/remoton-support-desktop: add flag -insecure for skip validation tls check-in: fe316eab8c user: bit4bit@riseup.net tags: master, trunk
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
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to server.go.

7
8
9
10
11
12
13

14
15
16
17
18
19
20
..
99
100
101
102
103
104
105

106


107
108
109




110
111
112
113
114
115
116
...
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
	"time"

	"github.com/julienschmidt/httprouter"
)

const (
	timeoutDefaultListen = time.Minute * 20

)

type requestTunnel struct {
	SessionID string
	Service   string
}

................................................................................
	if session == nil {
		w.WriteHeader(http.StatusNotFound)
		return
	}

	kservice := params.ByName("service")
	if trans, ok := tunnelTypes[params.ByName("tunnel")]; ok {

		tunnel := session.DialService(kservice)


		defer tunnel.Close()
		trans(tunnel).ServeHTTP(w, r)
		return




	}

	w.WriteHeader(http.StatusInternalServerError)
}

func (c *Server) hSessionListen(w http.ResponseWriter, r *http.Request, params httprouter.Params) {
	session := c.sessions.Get(params.ByName("id"))
................................................................................
		w.WriteHeader(http.StatusNotFound)
		return
	}

	kservice := params.ByName("service")

	if trans, ok := tunnelTypes[params.ByName("tunnel")]; ok {
		chtunnel := session.ListenService(kservice)
		select {
		case tunnel := <-chtunnel:
			defer tunnel.Close()
			trans(tunnel).ServeHTTP(w, r)
			return
		case <-time.After(timeoutDefaultListen):
			w.WriteHeader(http.StatusGatewayTimeout)







>







 







>
|
>
>
|
|
|
>
>
>
>







 







|







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
...
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
	"time"

	"github.com/julienschmidt/httprouter"
)

const (
	timeoutDefaultListen = time.Minute * 20
	timeoutDefaultDial   = time.Minute * 3
)

type requestTunnel struct {
	SessionID string
	Service   string
}

................................................................................
	if session == nil {
		w.WriteHeader(http.StatusNotFound)
		return
	}

	kservice := params.ByName("service")
	if trans, ok := tunnelTypes[params.ByName("tunnel")]; ok {
		listen, tunnel := net.Pipe()
		service := session.Service(kservice)
		select {
		case service <- listen:
			defer tunnel.Close()
			trans(tunnel).ServeHTTP(w, r)
			return
		case <-time.After(timeoutDefaultDial):
			w.WriteHeader(http.StatusGatewayTimeout)
			return
		}
	}

	w.WriteHeader(http.StatusInternalServerError)
}

func (c *Server) hSessionListen(w http.ResponseWriter, r *http.Request, params httprouter.Params) {
	session := c.sessions.Get(params.ByName("id"))
................................................................................
		w.WriteHeader(http.StatusNotFound)
		return
	}

	kservice := params.ByName("service")

	if trans, ok := tunnelTypes[params.ByName("tunnel")]; ok {
		chtunnel := session.Service(kservice)
		select {
		case tunnel := <-chtunnel:
			defer tunnel.Close()
			trans(tunnel).ServeHTTP(w, r)
			return
		case <-time.After(timeoutDefaultListen):
			w.WriteHeader(http.StatusGatewayTimeout)

Changes to session.go.

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
	c.mutex.Lock()
	defer c.mutex.Unlock()
	if _, ok := c.service[id]; !ok {
		c.service[id] = make(chan net.Conn)
	}
}

func (c *srvSession) ListenService(id string) <-chan net.Conn {
	c.initService(id)
	return c.service[id]
}

func (c *srvSession) DialService(id string) net.Conn {
	c.initService(id)

	listen, dial := net.Pipe()
	c.service[id] <- listen
	return dial
}

//SessionManager handle sessions
type sessionManager struct {
	sync.Mutex
	sessions map[string]*srvSession

	Stat struct {
		Sessions int64







|




<
<
<
<
<
<
<
<







26
27
28
29
30
31
32
33
34
35
36
37








38
39
40
41
42
43
44
	c.mutex.Lock()
	defer c.mutex.Unlock()
	if _, ok := c.service[id]; !ok {
		c.service[id] = make(chan net.Conn)
	}
}

func (c *srvSession) Service(id string) chan net.Conn {
	c.initService(id)
	return c.service[id]
}









//SessionManager handle sessions
type sessionManager struct {
	sync.Mutex
	sessions map[string]*srvSession

	Stat struct {
		Sessions int64