File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -90,7 +90,9 @@ func (p *Proxy) onAgentConnected(newClient *ws.Client) {
9090 go func () {
9191 for msg := range newAgent .client .Recv {
9292 for r := range newAgent .remotes {
93- r .client .Send <- msg
93+ if ! r .client .Closed () {
94+ r .client .Send <- msg
95+ }
9496 }
9597 }
9698
@@ -132,7 +134,9 @@ func (p *Proxy) onRemoteConnected(newClient *ws.Client) {
132134 // Pipe received messages to the agent.
133135 go func () {
134136 for msg := range newRemote .client .Recv {
135- targetAgent .client .Send <- msg
137+ if ! targetAgent .client .Closed () {
138+ targetAgent .client .Send <- msg
139+ }
136140 }
137141
138142 log .Println ("Closed remote:" , target .Id )
Original file line number Diff line number Diff line change @@ -33,6 +33,10 @@ func (c *Client) Close() {
3333 }
3434}
3535
36+ func (c * Client ) Closed () bool {
37+ return c .closed
38+ }
39+
3640func (c * Client ) readPump () {
3741 defer c .Close ()
3842
@@ -52,6 +56,10 @@ func (c *Client) readPump() {
5256 break
5357 }
5458
59+ if c .closed {
60+ break
61+ }
62+
5563 c .Recv <- Message {
5664 MessageType : t ,
5765 Data : msg ,
Original file line number Diff line number Diff line change @@ -13,8 +13,8 @@ type Server struct {
1313}
1414
1515var upgrader = websocket.Upgrader {
16+ // Allow all origins.
1617 CheckOrigin : func (_ * http.Request ) bool {
17- // TODO: Actually check origin
1818 return true
1919 },
2020}
You can’t perform that action at this time.
0 commit comments