This commit is contained in:
lwch
2022-07-28 15:51:15 +08:00
parent c1a5d73bcf
commit 7f5a2cf89e
5 changed files with 13 additions and 8 deletions
+8 -8
View File
@@ -39,16 +39,16 @@ func (code *Code) Forward(conn *conn.Conn, w http.ResponseWriter, r *http.Reques
srcQuery.Set(argName, id)
http.Redirect(w, r, srcPath+"?"+srcQuery.Encode(), http.StatusTemporaryRedirect)
return
} else {
cookie, err := r.Cookie("__NATPASS_CONNECTION_ID__")
if err != nil {
logging.Error("get connection id: %v", err)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
id = cookie.Value
}
cookie, err := r.Cookie("__NATPASS_CONNECTION_ID__")
if err != nil {
logging.Error("get connection id: %v", err)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
id = cookie.Value
code.RLock()
workspace := code.workspace[id]
code.RUnlock()
+1
View File
@@ -170,6 +170,7 @@ func (ws *Workspace) log(stdout, stderr io.ReadCloser) {
wg.Wait()
}
// Forward forward data from remote node
func (ws *Workspace) Forward() {
go ws.remoteRead()
}
@@ -10,6 +10,7 @@ import (
"github.com/lwch/natpass/code/network"
)
// SendRequest send request from local node
func (ws *Workspace) SendRequest(r *http.Request) (uint64, error) {
reqID := atomic.AddUint64(&ws.requestID, 1)
body, err := ioutil.ReadAll(r.Body)
@@ -27,6 +28,7 @@ func (ws *Workspace) SendRequest(r *http.Request) (uint64, error) {
return reqID, nil
}
// SendConnect send websocket connect action from local node
func (ws *Workspace) SendConnect(r *http.Request) (uint64, error) {
reqID := atomic.AddUint64(&ws.requestID, 1)
ws.Lock()
@@ -118,6 +118,7 @@ func (ws *Workspace) ws2remote(wg *sync.WaitGroup, reqID uint64, conn *websocket
}
}
// SendData send websocket data
func (ws *Workspace) SendData(reqID uint64, ok bool, t int, body []byte) {
for i := 0; i < len(body); i += 32 * 1024 {
end := i + 32*1024
+1
View File
@@ -149,6 +149,7 @@ func (link *Link) localRead() {
}
}
// Close close link
func (link *Link) Close(send bool) {
if link.ps != nil {
link.ps.Close()