mirror of
https://github.com/lwch/natpass.git
synced 2024-04-21 12:41:54 +00:00
golint
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -149,6 +149,7 @@ func (link *Link) localRead() {
|
||||
}
|
||||
}
|
||||
|
||||
// Close close link
|
||||
func (link *Link) Close(send bool) {
|
||||
if link.ps != nil {
|
||||
link.ps.Close()
|
||||
|
||||
Reference in New Issue
Block a user