mirror of
https://github.com/lwch/natpass
synced 2025-09-26 17:51:11 +08:00
实现普通http请求的转发逻辑
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -4,4 +4,5 @@
|
||||
/tmp
|
||||
/logs
|
||||
/run
|
||||
/*.yaml
|
||||
/*.yaml
|
||||
/test_conf
|
100
code/client/conn/send_code.go
Normal file
100
code/client/conn/send_code.go
Normal file
@@ -0,0 +1,100 @@
|
||||
package conn
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/lwch/natpass/code/network"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func makeCodeHeader(header http.Header) map[string]*network.CodeHeaderValues {
|
||||
ret := make(map[string]*network.CodeHeaderValues)
|
||||
for key, values := range header {
|
||||
data := make([]string, len(values))
|
||||
copy(data, values)
|
||||
ret[key] = &network.CodeHeaderValues{
|
||||
Values: data,
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
// SendCodeRequest send request
|
||||
func (conn *Conn) SendCodeRequest(to, linkID string, requestID uint64,
|
||||
method, uri string, body []byte, header http.Header) uint64 {
|
||||
var msg network.Msg
|
||||
msg.To = to
|
||||
msg.XType = network.Msg_code_request
|
||||
msg.LinkId = linkID
|
||||
msg.Payload = &network.Msg_Csreq{
|
||||
Csreq: &network.CodeRequest{
|
||||
RequestId: requestID,
|
||||
Method: method,
|
||||
Uri: uri,
|
||||
Body: body,
|
||||
Header: makeCodeHeader(header),
|
||||
},
|
||||
}
|
||||
select {
|
||||
case conn.write <- &msg:
|
||||
data, _ := proto.Marshal(&msg)
|
||||
return uint64(len(data))
|
||||
case <-time.After(conn.cfg.WriteTimeout):
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
// SendCodeResponseHeader send response header
|
||||
func (conn *Conn) SendCodeResponseHeader(to, linkID string, requestID uint64,
|
||||
code uint32, header http.Header) uint64 {
|
||||
var msg network.Msg
|
||||
msg.To = to
|
||||
msg.XType = network.Msg_code_response_hdr
|
||||
msg.LinkId = linkID
|
||||
msg.Payload = &network.Msg_CsrepHdr{
|
||||
CsrepHdr: &network.CodeResponseHeader{
|
||||
RequestId: requestID,
|
||||
Code: code,
|
||||
Header: makeCodeHeader(header),
|
||||
},
|
||||
}
|
||||
select {
|
||||
case conn.write <- &msg:
|
||||
data, _ := proto.Marshal(&msg)
|
||||
return uint64(len(data))
|
||||
case <-time.After(conn.cfg.WriteTimeout):
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
// SendCodeResponseBody send response body
|
||||
func (conn *Conn) SendCodeResponseBody(to, linkID string, requestID uint64,
|
||||
idx uint32, ok, done bool, data []byte) uint64 {
|
||||
var mask uint32
|
||||
if ok {
|
||||
mask |= 1
|
||||
}
|
||||
if done {
|
||||
mask |= 2
|
||||
}
|
||||
var msg network.Msg
|
||||
msg.To = to
|
||||
msg.XType = network.Msg_code_response_body
|
||||
msg.LinkId = linkID
|
||||
msg.Payload = &network.Msg_CsrepBody{
|
||||
CsrepBody: &network.CodeResponseBody{
|
||||
RequestId: requestID,
|
||||
Index: idx,
|
||||
Mask: mask,
|
||||
Body: data,
|
||||
},
|
||||
}
|
||||
select {
|
||||
case conn.write <- &msg:
|
||||
data, _ := proto.Marshal(&msg)
|
||||
return uint64(len(data))
|
||||
case <-time.After(conn.cfg.WriteTimeout):
|
||||
return 0
|
||||
}
|
||||
}
|
1
code/client/rule/code/.gitignore
vendored
Normal file
1
code/client/rule/code/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/assets.go
|
@@ -95,7 +95,8 @@ func (code *Code) Handle(c *conn.Conn) {
|
||||
}
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/new", pf(code.New))
|
||||
mux.HandleFunc("/", pf(code.Forward))
|
||||
mux.HandleFunc("/forward/", pf(code.Forward))
|
||||
mux.HandleFunc("/", pf(code.Render))
|
||||
svr := &http.Server{
|
||||
Addr: fmt.Sprintf("%s:%d", code.cfg.LocalAddr, code.cfg.LocalPort),
|
||||
Handler: mux,
|
||||
|
@@ -2,10 +2,38 @@ package code
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/lwch/natpass/code/client/conn"
|
||||
)
|
||||
|
||||
// Forward forward code-server requests
|
||||
func (code *Code) Forward(conn *conn.Conn, w http.ResponseWriter, r *http.Request) {
|
||||
id := strings.TrimPrefix(r.URL.Path, "/forward/")
|
||||
id = id[:strings.Index(id, "/")]
|
||||
|
||||
code.RLock()
|
||||
workspace := code.workspace[id]
|
||||
code.RUnlock()
|
||||
|
||||
if workspace == nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
r.URL.Path = strings.TrimPrefix(r.URL.Path, "/forward/"+id)
|
||||
if len(r.URL.Path) == 0 {
|
||||
r.URL.Path = "/"
|
||||
}
|
||||
|
||||
if code.isWebsocket(r) {
|
||||
code.handleWebsocket(workspace, w, r)
|
||||
} else {
|
||||
code.handleRequest(workspace, w, r)
|
||||
}
|
||||
}
|
||||
|
||||
func (code *Code) isWebsocket(r *http.Request) bool {
|
||||
upgrade := r.Header.Get("Connection")
|
||||
return upgrade == "Upgrade"
|
||||
}
|
||||
|
78
code/client/rule/code/h_forward_request.go
Normal file
78
code/client/rule/code/h_forward_request.go
Normal file
@@ -0,0 +1,78 @@
|
||||
package code
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/lwch/logging"
|
||||
"github.com/lwch/natpass/code/network"
|
||||
)
|
||||
|
||||
func (code *Code) handleRequest(workspace *Workspace, w http.ResponseWriter, r *http.Request) {
|
||||
reqID, err := workspace.SendRequest(r)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadGateway)
|
||||
return
|
||||
}
|
||||
defer workspace.closeMessage(reqID)
|
||||
resp := workspace.onResponse(reqID)
|
||||
if resp == nil {
|
||||
logging.Error("waiting for [%s] [%s] no response, request_id=%d",
|
||||
workspace.id, workspace.name, reqID)
|
||||
http.Error(w, "no response", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
if resp.GetXType() != network.Msg_code_response_hdr {
|
||||
logging.Error("got invalid message type [%s] [%s]: %s",
|
||||
workspace.id, workspace.name, resp.GetXType().String())
|
||||
http.Error(w, "invalid message type", http.StatusServiceUnavailable)
|
||||
return
|
||||
}
|
||||
|
||||
hdr := resp.GetCsrepHdr()
|
||||
for key, values := range hdr.GetHeader() {
|
||||
for _, v := range values.GetValues() {
|
||||
w.Header().Add(key, v)
|
||||
}
|
||||
}
|
||||
|
||||
logging.Info("header: %v", hdr.GetHeader())
|
||||
|
||||
w.WriteHeader(int(hdr.GetCode()))
|
||||
|
||||
var idx uint32
|
||||
for {
|
||||
msg := workspace.onResponse(reqID)
|
||||
if msg == nil {
|
||||
http.Error(w, "no response", http.StatusBadGateway)
|
||||
return
|
||||
}
|
||||
if msg.GetXType() != network.Msg_code_response_body {
|
||||
logging.Error("got invalid message type [%s] [%s]: %s",
|
||||
workspace.id, workspace.name, resp.GetXType().String())
|
||||
http.Error(w, "invalid message type", http.StatusServiceUnavailable)
|
||||
return
|
||||
}
|
||||
resp := msg.GetCsrepBody()
|
||||
if resp.GetIndex() != idx {
|
||||
logging.Error("loss data [%s] [%s]", workspace.id, workspace.name)
|
||||
http.Error(w, "loss data", http.StatusResetContent)
|
||||
return
|
||||
}
|
||||
if resp.GetMask()&1 == 0 {
|
||||
logging.Error("read data [%s] [%s]: %s", workspace.id, workspace.name, string(resp.GetBody()))
|
||||
http.Error(w, fmt.Sprintf("read error: %s", string(resp.GetBody())), http.StatusResetContent)
|
||||
return
|
||||
}
|
||||
_, err = w.Write(resp.GetBody())
|
||||
if err != nil {
|
||||
logging.Error("write body: %v", err)
|
||||
return
|
||||
}
|
||||
if resp.GetMask()&2 > 0 {
|
||||
return
|
||||
}
|
||||
idx++
|
||||
}
|
||||
}
|
8
code/client/rule/code/h_forward_websocket.go
Normal file
8
code/client/rule/code/h_forward_websocket.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package code
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func (code *Code) handleWebsocket(workspace *Workspace, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
@@ -23,13 +23,12 @@ func (code *Code) New(conn *conn.Conn, w http.ResponseWriter, r *http.Request) {
|
||||
link := code.NewLink(id, code.cfg.Target, nil, conn).(*Workspace)
|
||||
conn.SendConnectReq(id, code.cfg)
|
||||
ch := conn.ChanRead(id)
|
||||
timeout := time.After(code.readTimeout)
|
||||
var repMsg *network.Msg
|
||||
for {
|
||||
var msg *network.Msg
|
||||
select {
|
||||
case msg = <-ch:
|
||||
case <-timeout:
|
||||
case <-time.After(time.Minute):
|
||||
logging.Error("create code-server %s by rule %s failed, timtout", link.id, link.parent.Name)
|
||||
http.Error(w, "timeout", http.StatusBadGateway)
|
||||
return
|
||||
@@ -52,5 +51,6 @@ func (code *Code) New(conn *conn.Conn, w http.ResponseWriter, r *http.Request) {
|
||||
logging.Info("create link %s for code-server rule [%s] from %s to %s",
|
||||
link.GetID(), code.cfg.Name,
|
||||
repMsg.GetTo(), repMsg.GetFrom())
|
||||
go link.localRead()
|
||||
fmt.Fprint(w, id)
|
||||
}
|
||||
|
35
code/client/rule/code/h_render.go
Normal file
35
code/client/rule/code/h_render.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package code
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"mime"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
"github.com/lwch/natpass/code/client/conn"
|
||||
)
|
||||
|
||||
// Render render code-server
|
||||
func (code *Code) Render(conn *conn.Conn, w http.ResponseWriter, r *http.Request) {
|
||||
dir := strings.TrimPrefix(r.URL.Path, "/")
|
||||
data, err := Asset(dir)
|
||||
if err == nil {
|
||||
ctype := mime.TypeByExtension(filepath.Ext(dir))
|
||||
if ctype == "" {
|
||||
ctype = http.DetectContentType(data)
|
||||
}
|
||||
w.Header().Set("Content-Type", ctype)
|
||||
io.Copy(w, bytes.NewReader(data))
|
||||
return
|
||||
}
|
||||
data, _ = Asset("index.html")
|
||||
tpl, err := template.New("all").Parse(string(data))
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
tpl.Execute(w, code)
|
||||
}
|
@@ -2,41 +2,56 @@ package code
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/lwch/logging"
|
||||
"github.com/lwch/natpass/code/client/conn"
|
||||
"github.com/lwch/natpass/code/network"
|
||||
"github.com/lwch/natpass/code/utils"
|
||||
)
|
||||
|
||||
var errWaitingTimeout = errors.New("waiting for code-server startup more than 1 minute")
|
||||
|
||||
// Workspace workspace of code-server
|
||||
type Workspace struct {
|
||||
sync.RWMutex
|
||||
parent *Code
|
||||
id string
|
||||
target string
|
||||
name string
|
||||
exec *exec.Cmd
|
||||
cli *http.Client
|
||||
remote *conn.Conn
|
||||
// runtime
|
||||
sendBytes uint64
|
||||
recvBytes uint64
|
||||
sendPacket uint64
|
||||
recvPacket uint64
|
||||
requestID uint64
|
||||
onListen chan struct{}
|
||||
onMessage map[uint64]chan *network.Msg
|
||||
}
|
||||
|
||||
func newWorkspace(parent *Code, id, name, target string, remote *conn.Conn) *Workspace {
|
||||
name = strings.ReplaceAll(name, "/", "_")
|
||||
name = strings.ReplaceAll(name, "\\", "_")
|
||||
return &Workspace{
|
||||
parent: parent,
|
||||
id: id,
|
||||
target: target,
|
||||
name: name,
|
||||
remote: remote,
|
||||
parent: parent,
|
||||
id: id,
|
||||
target: target,
|
||||
name: name,
|
||||
remote: remote,
|
||||
onListen: make(chan struct{}),
|
||||
onMessage: make(map[uint64]chan *network.Msg),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,8 +98,28 @@ func (ws *Workspace) Exec(dir string) error {
|
||||
logging.Error("can not start code-server for link [%s] name [%s]", ws.id, ws.name)
|
||||
return err
|
||||
}
|
||||
go func() {
|
||||
err = ws.exec.Wait()
|
||||
if err != nil {
|
||||
logging.Error("code-server [%s] [%s] exited: %v", ws.id, ws.name, err)
|
||||
return
|
||||
}
|
||||
logging.Info("code-server for link [%s] name [%s] exited", ws.id, ws.name)
|
||||
}()
|
||||
ws.cli = &http.Client{
|
||||
Transport: &http.Transport{
|
||||
Dial: func(network, addr string) (net.Conn, error) {
|
||||
return net.Dial("unix", filepath.Join(workdir, ws.id+".sock"))
|
||||
},
|
||||
},
|
||||
}
|
||||
go ws.log(stdout, stderr)
|
||||
return nil
|
||||
select {
|
||||
case <-time.After(time.Minute):
|
||||
return errWaitingTimeout
|
||||
case <-ws.onListen:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// Close close workspace
|
||||
@@ -106,6 +141,10 @@ func (ws *Workspace) log(stdout, stderr io.ReadCloser) {
|
||||
defer wg.Done()
|
||||
s := bufio.NewScanner(target)
|
||||
for s.Scan() {
|
||||
if strings.Contains(s.Text(), "listening on") &&
|
||||
strings.Contains(s.Text(), ws.id+".sock") {
|
||||
ws.onListen <- struct{}{}
|
||||
}
|
||||
logging.Info("code-server [%s] [%s]: %s", ws.id, ws.name, s.Text())
|
||||
}
|
||||
}
|
||||
@@ -116,5 +155,76 @@ func (ws *Workspace) log(stdout, stderr io.ReadCloser) {
|
||||
}
|
||||
|
||||
func (ws *Workspace) Forward() {
|
||||
|
||||
go ws.remoteRead()
|
||||
}
|
||||
|
||||
func (ws *Workspace) remoteRead() {
|
||||
defer utils.Recover("remoteRead")
|
||||
defer ws.Close()
|
||||
ch := ws.remote.ChanRead(ws.id)
|
||||
for {
|
||||
msg := <-ch
|
||||
if msg == nil {
|
||||
return
|
||||
}
|
||||
switch msg.GetXType() {
|
||||
case network.Msg_code_request:
|
||||
go ws.handleRequest(msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (ws *Workspace) closeMessage(reqID uint64) {
|
||||
ws.Lock()
|
||||
if ch, ok := ws.onMessage[reqID]; ok {
|
||||
close(ch)
|
||||
delete(ws.onMessage, reqID)
|
||||
}
|
||||
ws.Unlock()
|
||||
}
|
||||
|
||||
func (ws *Workspace) localRead() {
|
||||
defer utils.Recover("localRead")
|
||||
defer ws.Close()
|
||||
ch := ws.remote.ChanRead(ws.id)
|
||||
for {
|
||||
msg := <-ch
|
||||
if msg == nil {
|
||||
return
|
||||
}
|
||||
switch msg.GetXType() {
|
||||
case network.Msg_code_response_hdr:
|
||||
ws.writeMessage(msg.GetCsrepHdr().GetRequestId(), msg)
|
||||
case network.Msg_code_response_body:
|
||||
ws.writeMessage(msg.GetCsrepBody().GetRequestId(), msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (ws *Workspace) writeMessage(reqID uint64, msg *network.Msg) {
|
||||
defer utils.Recover("writeMessage")
|
||||
ws.RLock()
|
||||
ch := ws.onMessage[reqID]
|
||||
ws.RUnlock()
|
||||
if ch != nil {
|
||||
select {
|
||||
case ch <- msg:
|
||||
case <-time.After(ws.parent.writeTimeout):
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (ws *Workspace) onResponse(reqID uint64) *network.Msg {
|
||||
ws.RLock()
|
||||
ch := ws.onMessage[reqID]
|
||||
ws.RUnlock()
|
||||
if ch != nil {
|
||||
select {
|
||||
case msg := <-ch:
|
||||
return msg
|
||||
case <-time.After(ws.parent.readTimeout):
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
27
code/client/rule/code/workspace_local_request.go
Normal file
27
code/client/rule/code/workspace_local_request.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package code
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/lwch/logging"
|
||||
"github.com/lwch/natpass/code/network"
|
||||
)
|
||||
|
||||
func (ws *Workspace) SendRequest(r *http.Request) (uint64, error) {
|
||||
reqID := atomic.AddUint64(&ws.requestID, 1)
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
logging.Error("send request for workspace [%s] [%s]: %v", ws.id, ws.name, err)
|
||||
return 0, err
|
||||
}
|
||||
ws.Lock()
|
||||
ws.onMessage[reqID] = make(chan *network.Msg)
|
||||
ws.Unlock()
|
||||
send := ws.remote.SendCodeRequest(ws.target, ws.id, reqID,
|
||||
r.Method, r.URL.RequestURI(), body, r.Header)
|
||||
ws.sendBytes += send
|
||||
ws.sendPacket++
|
||||
return reqID, nil
|
||||
}
|
60
code/client/rule/code/workspace_remote_response.go
Normal file
60
code/client/rule/code/workspace_remote_response.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package code
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/lwch/logging"
|
||||
"github.com/lwch/natpass/code/network"
|
||||
"github.com/lwch/natpass/code/utils"
|
||||
)
|
||||
|
||||
func (ws *Workspace) handleRequest(msg *network.Msg) {
|
||||
defer utils.Recover("handleRequest")
|
||||
req := msg.GetCsreq()
|
||||
request, err := http.NewRequest(req.GetMethod(), "http://unix"+req.GetUri(), bytes.NewReader(req.GetBody()))
|
||||
if err != nil {
|
||||
logging.Error("build request [%s] [%s]: %v", ws.id, ws.name, err)
|
||||
return
|
||||
}
|
||||
for key, values := range req.GetHeader() {
|
||||
for _, v := range values.GetValues() {
|
||||
request.Header.Add(key, v)
|
||||
}
|
||||
}
|
||||
response, err := ws.cli.Do(request)
|
||||
if err != nil {
|
||||
// TODO: response error
|
||||
logging.Error("call request [%s] [%s] [%s]: %v", ws.id, ws.name, req.GetUri(), err)
|
||||
return
|
||||
}
|
||||
defer response.Body.Close()
|
||||
send := ws.remote.SendCodeResponseHeader(ws.target, ws.id, req.GetRequestId(), uint32(response.StatusCode), response.Header)
|
||||
ws.sendBytes += send
|
||||
ws.sendPacket++
|
||||
buf := make([]byte, 32*1024) // 32k block read
|
||||
var idx uint32
|
||||
for {
|
||||
n, err := response.Body.Read(buf)
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
send := ws.remote.SendCodeResponseBody(ws.target, ws.id, req.GetRequestId(), idx, true, true, nil)
|
||||
ws.sendBytes += send
|
||||
ws.sendPacket++
|
||||
idx++
|
||||
return
|
||||
}
|
||||
send := ws.remote.SendCodeResponseBody(ws.target, ws.id, req.GetRequestId(), idx, false, true, []byte(err.Error()))
|
||||
ws.sendBytes += send
|
||||
ws.sendPacket++
|
||||
idx++
|
||||
logging.Error("call request [%s] [%s] [%s] read response data: %v", ws.id, ws.name, req.GetUri(), err)
|
||||
return
|
||||
}
|
||||
send := ws.remote.SendCodeResponseBody(ws.target, ws.id, req.GetRequestId(), idx, true, false, buf[:n])
|
||||
ws.sendBytes += send
|
||||
ws.sendPacket++
|
||||
idx++
|
||||
}
|
||||
}
|
@@ -73,7 +73,7 @@ type CodeRequest struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
|
||||
RequestId uint64 `protobuf:"varint,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
|
||||
Method string `protobuf:"bytes,2,opt,name=method,proto3" json:"method,omitempty"`
|
||||
Uri string `protobuf:"bytes,3,opt,name=uri,proto3" json:"uri,omitempty"`
|
||||
Body []byte `protobuf:"bytes,4,opt,name=body,proto3" json:"body,omitempty"`
|
||||
@@ -112,11 +112,11 @@ func (*CodeRequest) Descriptor() ([]byte, []int) {
|
||||
return file_code_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *CodeRequest) GetRequestId() string {
|
||||
func (x *CodeRequest) GetRequestId() uint64 {
|
||||
if x != nil {
|
||||
return x.RequestId
|
||||
}
|
||||
return ""
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *CodeRequest) GetMethod() string {
|
||||
@@ -147,19 +147,18 @@ func (x *CodeRequest) GetHeader() map[string]*CodeHeaderValues {
|
||||
return nil
|
||||
}
|
||||
|
||||
type CodeResponse struct {
|
||||
type CodeResponseHeader struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
|
||||
RequestId uint64 `protobuf:"varint,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
|
||||
Code uint32 `protobuf:"varint,2,opt,name=code,proto3" json:"code,omitempty"`
|
||||
Body []byte `protobuf:"bytes,3,opt,name=body,proto3" json:"body,omitempty"`
|
||||
Header map[string]*CodeHeaderValues `protobuf:"bytes,4,rep,name=header,proto3" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
Header map[string]*CodeHeaderValues `protobuf:"bytes,3,rep,name=header,proto3" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
}
|
||||
|
||||
func (x *CodeResponse) Reset() {
|
||||
*x = CodeResponse{}
|
||||
func (x *CodeResponseHeader) Reset() {
|
||||
*x = CodeResponseHeader{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_code_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
@@ -167,13 +166,13 @@ func (x *CodeResponse) Reset() {
|
||||
}
|
||||
}
|
||||
|
||||
func (x *CodeResponse) String() string {
|
||||
func (x *CodeResponseHeader) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*CodeResponse) ProtoMessage() {}
|
||||
func (*CodeResponseHeader) ProtoMessage() {}
|
||||
|
||||
func (x *CodeResponse) ProtoReflect() protoreflect.Message {
|
||||
func (x *CodeResponseHeader) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_code_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
@@ -185,35 +184,99 @@ func (x *CodeResponse) ProtoReflect() protoreflect.Message {
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use CodeResponse.ProtoReflect.Descriptor instead.
|
||||
func (*CodeResponse) Descriptor() ([]byte, []int) {
|
||||
// Deprecated: Use CodeResponseHeader.ProtoReflect.Descriptor instead.
|
||||
func (*CodeResponseHeader) Descriptor() ([]byte, []int) {
|
||||
return file_code_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *CodeResponse) GetRequestId() string {
|
||||
func (x *CodeResponseHeader) GetRequestId() uint64 {
|
||||
if x != nil {
|
||||
return x.RequestId
|
||||
}
|
||||
return ""
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *CodeResponse) GetCode() uint32 {
|
||||
func (x *CodeResponseHeader) GetCode() uint32 {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *CodeResponse) GetBody() []byte {
|
||||
func (x *CodeResponseHeader) GetHeader() map[string]*CodeHeaderValues {
|
||||
if x != nil {
|
||||
return x.Body
|
||||
return x.Header
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *CodeResponse) GetHeader() map[string]*CodeHeaderValues {
|
||||
type CodeResponseBody struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
RequestId uint64 `protobuf:"varint,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
|
||||
Index uint32 `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"`
|
||||
Mask uint32 `protobuf:"varint,3,opt,name=mask,proto3" json:"mask,omitempty"`
|
||||
Body []byte `protobuf:"bytes,4,opt,name=body,proto3" json:"body,omitempty"`
|
||||
}
|
||||
|
||||
func (x *CodeResponseBody) Reset() {
|
||||
*x = CodeResponseBody{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_code_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *CodeResponseBody) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*CodeResponseBody) ProtoMessage() {}
|
||||
|
||||
func (x *CodeResponseBody) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_code_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use CodeResponseBody.ProtoReflect.Descriptor instead.
|
||||
func (*CodeResponseBody) Descriptor() ([]byte, []int) {
|
||||
return file_code_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *CodeResponseBody) GetRequestId() uint64 {
|
||||
if x != nil {
|
||||
return x.Header
|
||||
return x.RequestId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *CodeResponseBody) GetIndex() uint32 {
|
||||
if x != nil {
|
||||
return x.Index
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *CodeResponseBody) GetMask() uint32 {
|
||||
if x != nil {
|
||||
return x.Mask
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *CodeResponseBody) GetBody() []byte {
|
||||
if x != nil {
|
||||
return x.Body
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -224,7 +287,7 @@ type CodeConnect struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
|
||||
RequestId uint64 `protobuf:"varint,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
|
||||
Uri string `protobuf:"bytes,2,opt,name=uri,proto3" json:"uri,omitempty"`
|
||||
Header map[string]*CodeHeaderValues `protobuf:"bytes,3,rep,name=header,proto3" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
}
|
||||
@@ -232,7 +295,7 @@ type CodeConnect struct {
|
||||
func (x *CodeConnect) Reset() {
|
||||
*x = CodeConnect{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_code_proto_msgTypes[3]
|
||||
mi := &file_code_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -245,7 +308,7 @@ func (x *CodeConnect) String() string {
|
||||
func (*CodeConnect) ProtoMessage() {}
|
||||
|
||||
func (x *CodeConnect) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_code_proto_msgTypes[3]
|
||||
mi := &file_code_proto_msgTypes[4]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -258,14 +321,14 @@ func (x *CodeConnect) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use CodeConnect.ProtoReflect.Descriptor instead.
|
||||
func (*CodeConnect) Descriptor() ([]byte, []int) {
|
||||
return file_code_proto_rawDescGZIP(), []int{3}
|
||||
return file_code_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *CodeConnect) GetRequestId() string {
|
||||
func (x *CodeConnect) GetRequestId() uint64 {
|
||||
if x != nil {
|
||||
return x.RequestId
|
||||
}
|
||||
return ""
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *CodeConnect) GetUri() string {
|
||||
@@ -287,14 +350,14 @@ type CodeData struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
|
||||
RequestId uint64 `protobuf:"varint,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
|
||||
Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
|
||||
}
|
||||
|
||||
func (x *CodeData) Reset() {
|
||||
*x = CodeData{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_code_proto_msgTypes[4]
|
||||
mi := &file_code_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -307,7 +370,7 @@ func (x *CodeData) String() string {
|
||||
func (*CodeData) ProtoMessage() {}
|
||||
|
||||
func (x *CodeData) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_code_proto_msgTypes[4]
|
||||
mi := &file_code_proto_msgTypes[5]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -320,14 +383,14 @@ func (x *CodeData) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use CodeData.ProtoReflect.Descriptor instead.
|
||||
func (*CodeData) Descriptor() ([]byte, []int) {
|
||||
return file_code_proto_rawDescGZIP(), []int{4}
|
||||
return file_code_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *CodeData) GetRequestId() string {
|
||||
func (x *CodeData) GetRequestId() uint64 {
|
||||
if x != nil {
|
||||
return x.RequestId
|
||||
}
|
||||
return ""
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *CodeData) GetData() []byte {
|
||||
@@ -346,7 +409,7 @@ var file_code_proto_rawDesc = []byte{
|
||||
0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x76, 0x61, 0x6c,
|
||||
0x75, 0x65, 0x73, 0x22, 0xfe, 0x01, 0x0a, 0x0c, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x72, 0x65, 0x71,
|
||||
0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f,
|
||||
0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73,
|
||||
0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73,
|
||||
0x74, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75,
|
||||
0x72, 0x69, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x69, 0x12, 0x12, 0x0a,
|
||||
@@ -360,40 +423,47 @@ var file_code_proto_rawDesc = []byte{
|
||||
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6e,
|
||||
0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x68, 0x65, 0x61, 0x64,
|
||||
0x65, 0x72, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65,
|
||||
0x3a, 0x02, 0x38, 0x01, 0x22, 0xea, 0x01, 0x0a, 0x0d, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x72, 0x65,
|
||||
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73,
|
||||
0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75,
|
||||
0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x0d, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64,
|
||||
0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x12, 0x3a, 0x0a,
|
||||
0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e,
|
||||
0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x72, 0x65, 0x73,
|
||||
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72,
|
||||
0x79, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x1a, 0x56, 0x0a, 0x0b, 0x48, 0x65, 0x61,
|
||||
0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x31, 0x0a, 0x05, 0x76, 0x61,
|
||||
0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6e, 0x65, 0x74, 0x77,
|
||||
0x6f, 0x72, 0x6b, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f,
|
||||
0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38,
|
||||
0x01, 0x22, 0xd2, 0x01, 0x0a, 0x0c, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65,
|
||||
0x63, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49,
|
||||
0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x69, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03,
|
||||
0x75, 0x72, 0x69, 0x12, 0x39, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20,
|
||||
0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x63, 0x6f,
|
||||
0x64, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65,
|
||||
0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x1a, 0x56,
|
||||
0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a,
|
||||
0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12,
|
||||
0x31, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b,
|
||||
0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x68, 0x65,
|
||||
0x61, 0x64, 0x65, 0x72, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x52, 0x05, 0x76, 0x61, 0x6c,
|
||||
0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x3e, 0x0a, 0x09, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x64,
|
||||
0x61, 0x74, 0x61, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69,
|
||||
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
||||
0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c,
|
||||
0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x0c, 0x5a, 0x0a, 0x2e, 0x2f, 0x3b, 0x6e, 0x65, 0x74,
|
||||
0x77, 0x6f, 0x72, 0x6b, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x3a, 0x02, 0x38, 0x01, 0x22, 0xe4, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x72, 0x65,
|
||||
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x1d, 0x0a,
|
||||
0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x04, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04,
|
||||
0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65,
|
||||
0x12, 0x41, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b,
|
||||
0x32, 0x29, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x5f,
|
||||
0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e,
|
||||
0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x68, 0x65, 0x61,
|
||||
0x64, 0x65, 0x72, 0x1a, 0x56, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74,
|
||||
0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x03, 0x6b, 0x65, 0x79, 0x12, 0x31, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x63, 0x6f,
|
||||
0x64, 0x65, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73,
|
||||
0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x71, 0x0a, 0x12, 0x63,
|
||||
0x6f, 0x64, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x62, 0x6f, 0x64,
|
||||
0x79, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64,
|
||||
0x12, 0x14, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52,
|
||||
0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x61, 0x73, 0x6b, 0x18, 0x03,
|
||||
0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x6d, 0x61, 0x73, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f,
|
||||
0x64, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0xd2,
|
||||
0x01, 0x0a, 0x0c, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x12,
|
||||
0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x04, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x10,
|
||||
0x0a, 0x03, 0x75, 0x72, 0x69, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x69,
|
||||
0x12, 0x39, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b,
|
||||
0x32, 0x21, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x5f,
|
||||
0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e,
|
||||
0x74, 0x72, 0x79, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x1a, 0x56, 0x0a, 0x0b, 0x48,
|
||||
0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65,
|
||||
0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x31, 0x0a, 0x05,
|
||||
0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6e, 0x65,
|
||||
0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65,
|
||||
0x72, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a,
|
||||
0x02, 0x38, 0x01, 0x22, 0x3e, 0x0a, 0x09, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x64, 0x61, 0x74, 0x61,
|
||||
0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12,
|
||||
0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64,
|
||||
0x61, 0x74, 0x61, 0x42, 0x0c, 0x5a, 0x0a, 0x2e, 0x2f, 0x3b, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72,
|
||||
0x6b, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -408,23 +478,24 @@ func file_code_proto_rawDescGZIP() []byte {
|
||||
return file_code_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_code_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
|
||||
var file_code_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
|
||||
var file_code_proto_goTypes = []interface{}{
|
||||
(*CodeHeaderValues)(nil), // 0: network.code_header_values
|
||||
(*CodeRequest)(nil), // 1: network.code_request
|
||||
(*CodeResponse)(nil), // 2: network.code_response
|
||||
(*CodeConnect)(nil), // 3: network.code_connect
|
||||
(*CodeData)(nil), // 4: network.code_data
|
||||
nil, // 5: network.code_request.HeaderEntry
|
||||
nil, // 6: network.code_response.HeaderEntry
|
||||
nil, // 7: network.code_connect.HeaderEntry
|
||||
(*CodeHeaderValues)(nil), // 0: network.code_header_values
|
||||
(*CodeRequest)(nil), // 1: network.code_request
|
||||
(*CodeResponseHeader)(nil), // 2: network.code_response_header
|
||||
(*CodeResponseBody)(nil), // 3: network.code_response_body
|
||||
(*CodeConnect)(nil), // 4: network.code_connect
|
||||
(*CodeData)(nil), // 5: network.code_data
|
||||
nil, // 6: network.code_request.HeaderEntry
|
||||
nil, // 7: network.code_response_header.HeaderEntry
|
||||
nil, // 8: network.code_connect.HeaderEntry
|
||||
}
|
||||
var file_code_proto_depIdxs = []int32{
|
||||
5, // 0: network.code_request.header:type_name -> network.code_request.HeaderEntry
|
||||
6, // 1: network.code_response.header:type_name -> network.code_response.HeaderEntry
|
||||
7, // 2: network.code_connect.header:type_name -> network.code_connect.HeaderEntry
|
||||
6, // 0: network.code_request.header:type_name -> network.code_request.HeaderEntry
|
||||
7, // 1: network.code_response_header.header:type_name -> network.code_response_header.HeaderEntry
|
||||
8, // 2: network.code_connect.header:type_name -> network.code_connect.HeaderEntry
|
||||
0, // 3: network.code_request.HeaderEntry.value:type_name -> network.code_header_values
|
||||
0, // 4: network.code_response.HeaderEntry.value:type_name -> network.code_header_values
|
||||
0, // 4: network.code_response_header.HeaderEntry.value:type_name -> network.code_header_values
|
||||
0, // 5: network.code_connect.HeaderEntry.value:type_name -> network.code_header_values
|
||||
6, // [6:6] is the sub-list for method output_type
|
||||
6, // [6:6] is the sub-list for method input_type
|
||||
@@ -464,7 +535,7 @@ func file_code_proto_init() {
|
||||
}
|
||||
}
|
||||
file_code_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*CodeResponse); i {
|
||||
switch v := v.(*CodeResponseHeader); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
@@ -476,7 +547,7 @@ func file_code_proto_init() {
|
||||
}
|
||||
}
|
||||
file_code_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*CodeConnect); i {
|
||||
switch v := v.(*CodeResponseBody); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
@@ -488,6 +559,18 @@ func file_code_proto_init() {
|
||||
}
|
||||
}
|
||||
file_code_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*CodeConnect); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_code_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*CodeData); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -506,7 +589,7 @@ func file_code_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_code_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 8,
|
||||
NumMessages: 9,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
@@ -9,28 +9,34 @@ message code_header_values {
|
||||
|
||||
// normal request
|
||||
message code_request {
|
||||
string request_id = 1;
|
||||
uint64 request_id = 1;
|
||||
string method = 2;
|
||||
string uri = 3;
|
||||
bytes body = 4;
|
||||
map<string, code_header_values> header = 5;
|
||||
}
|
||||
|
||||
message code_response {
|
||||
string request_id = 1;
|
||||
message code_response_header {
|
||||
uint64 request_id = 1;
|
||||
uint32 code = 2;
|
||||
bytes body = 3;
|
||||
map<string, code_header_values> header = 4;
|
||||
map<string, code_header_values> header = 3;
|
||||
}
|
||||
|
||||
message code_response_body {
|
||||
uint64 request_id = 1;
|
||||
uint32 index = 2;
|
||||
uint32 mask = 3;
|
||||
bytes body = 4;
|
||||
}
|
||||
|
||||
// websocket
|
||||
message code_connect {
|
||||
string request_id = 1;
|
||||
uint64 request_id = 1;
|
||||
string uri = 2;
|
||||
map<string, code_header_values> header = 3;
|
||||
}
|
||||
|
||||
message code_data {
|
||||
string request_id = 1;
|
||||
uint64 request_id = 1;
|
||||
bytes data = 2;
|
||||
}
|
@@ -42,8 +42,11 @@ const (
|
||||
Msg_vnc_scroll MsgType = 25
|
||||
Msg_vnc_clipboard MsgType = 26
|
||||
// code-server
|
||||
Msg_code_request MsgType = 30
|
||||
Msg_code_response MsgType = 31
|
||||
Msg_code_request MsgType = 30
|
||||
Msg_code_response_hdr MsgType = 31
|
||||
Msg_code_response_body MsgType = 32
|
||||
Msg_code_connect MsgType = 33
|
||||
Msg_code_data MsgType = 34
|
||||
)
|
||||
|
||||
// Enum value maps for MsgType.
|
||||
@@ -66,27 +69,33 @@ var (
|
||||
25: "vnc_scroll",
|
||||
26: "vnc_clipboard",
|
||||
30: "code_request",
|
||||
31: "code_response",
|
||||
31: "code_response_hdr",
|
||||
32: "code_response_body",
|
||||
33: "code_connect",
|
||||
34: "code_data",
|
||||
}
|
||||
MsgType_value = map[string]int32{
|
||||
"unknown": 0,
|
||||
"handshake": 1,
|
||||
"keepalive": 2,
|
||||
"connect_req": 3,
|
||||
"connect_rep": 4,
|
||||
"disconnect": 5,
|
||||
"forward": 6,
|
||||
"shell_resize": 10,
|
||||
"shell_data": 11,
|
||||
"vnc_ctrl": 20,
|
||||
"vnc_image": 21,
|
||||
"vnc_mouse": 22,
|
||||
"vnc_keyboard": 23,
|
||||
"vnc_cad": 24,
|
||||
"vnc_scroll": 25,
|
||||
"vnc_clipboard": 26,
|
||||
"code_request": 30,
|
||||
"code_response": 31,
|
||||
"unknown": 0,
|
||||
"handshake": 1,
|
||||
"keepalive": 2,
|
||||
"connect_req": 3,
|
||||
"connect_rep": 4,
|
||||
"disconnect": 5,
|
||||
"forward": 6,
|
||||
"shell_resize": 10,
|
||||
"shell_data": 11,
|
||||
"vnc_ctrl": 20,
|
||||
"vnc_image": 21,
|
||||
"vnc_mouse": 22,
|
||||
"vnc_keyboard": 23,
|
||||
"vnc_cad": 24,
|
||||
"vnc_scroll": 25,
|
||||
"vnc_clipboard": 26,
|
||||
"code_request": 30,
|
||||
"code_response_hdr": 31,
|
||||
"code_response_body": 32,
|
||||
"code_connect": 33,
|
||||
"code_data": 34,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -187,7 +196,8 @@ type Msg struct {
|
||||
// *Msg_Vscroll
|
||||
// *Msg_Vclipboard
|
||||
// *Msg_Csreq
|
||||
// *Msg_Csrep
|
||||
// *Msg_CsrepHdr
|
||||
// *Msg_CsrepBody
|
||||
// *Msg_Csconn
|
||||
// *Msg_Csdata
|
||||
Payload isMsg_Payload `protobuf_oneof:"payload"`
|
||||
@@ -351,9 +361,16 @@ func (x *Msg) GetCsreq() *CodeRequest {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Msg) GetCsrep() *CodeResponse {
|
||||
if x, ok := x.GetPayload().(*Msg_Csrep); ok {
|
||||
return x.Csrep
|
||||
func (x *Msg) GetCsrepHdr() *CodeResponseHeader {
|
||||
if x, ok := x.GetPayload().(*Msg_CsrepHdr); ok {
|
||||
return x.CsrepHdr
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Msg) GetCsrepBody() *CodeResponseBody {
|
||||
if x, ok := x.GetPayload().(*Msg_CsrepBody); ok {
|
||||
return x.CsrepBody
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -431,16 +448,20 @@ type Msg_Csreq struct {
|
||||
Csreq *CodeRequest `protobuf:"bytes,40,opt,name=csreq,proto3,oneof"`
|
||||
}
|
||||
|
||||
type Msg_Csrep struct {
|
||||
Csrep *CodeResponse `protobuf:"bytes,41,opt,name=csrep,proto3,oneof"`
|
||||
type Msg_CsrepHdr struct {
|
||||
CsrepHdr *CodeResponseHeader `protobuf:"bytes,41,opt,name=csrep_hdr,json=csrepHdr,proto3,oneof"`
|
||||
}
|
||||
|
||||
type Msg_CsrepBody struct {
|
||||
CsrepBody *CodeResponseBody `protobuf:"bytes,42,opt,name=csrep_body,json=csrepBody,proto3,oneof"`
|
||||
}
|
||||
|
||||
type Msg_Csconn struct {
|
||||
Csconn *CodeConnect `protobuf:"bytes,42,opt,name=csconn,proto3,oneof"`
|
||||
Csconn *CodeConnect `protobuf:"bytes,43,opt,name=csconn,proto3,oneof"`
|
||||
}
|
||||
|
||||
type Msg_Csdata struct {
|
||||
Csdata *CodeData `protobuf:"bytes,43,opt,name=csdata,proto3,oneof"`
|
||||
Csdata *CodeData `protobuf:"bytes,44,opt,name=csdata,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*Msg_Hsp) isMsg_Payload() {}
|
||||
@@ -469,7 +490,9 @@ func (*Msg_Vclipboard) isMsg_Payload() {}
|
||||
|
||||
func (*Msg_Csreq) isMsg_Payload() {}
|
||||
|
||||
func (*Msg_Csrep) isMsg_Payload() {}
|
||||
func (*Msg_CsrepHdr) isMsg_Payload() {}
|
||||
|
||||
func (*Msg_CsrepBody) isMsg_Payload() {}
|
||||
|
||||
func (*Msg_Csconn) isMsg_Payload() {}
|
||||
|
||||
@@ -485,7 +508,7 @@ var file_msg_proto_rawDesc = []byte{
|
||||
0x09, 0x76, 0x6e, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0a, 0x63, 0x6f, 0x64, 0x65,
|
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x25, 0x0a, 0x11, 0x68, 0x61, 0x6e, 0x64, 0x73, 0x68,
|
||||
0x61, 0x6b, 0x65, 0x5f, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x65,
|
||||
0x6e, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x65, 0x6e, 0x63, 0x22, 0x90, 0x09,
|
||||
0x6e, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x65, 0x6e, 0x63, 0x22, 0x99, 0x0a,
|
||||
0x0a, 0x03, 0x6d, 0x73, 0x67, 0x12, 0x26, 0x0a, 0x05, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x0e, 0x32, 0x11, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x6d,
|
||||
0x73, 0x67, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x52, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a,
|
||||
@@ -530,37 +553,45 @@ var file_msg_proto_rawDesc = []byte{
|
||||
0x64, 0x48, 0x00, 0x52, 0x0a, 0x76, 0x63, 0x6c, 0x69, 0x70, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x12,
|
||||
0x2d, 0x0a, 0x05, 0x63, 0x73, 0x72, 0x65, 0x71, 0x18, 0x28, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15,
|
||||
0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x72, 0x65,
|
||||
0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x05, 0x63, 0x73, 0x72, 0x65, 0x71, 0x12, 0x2e,
|
||||
0x0a, 0x05, 0x63, 0x73, 0x72, 0x65, 0x70, 0x18, 0x29, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e,
|
||||
0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x72, 0x65, 0x73,
|
||||
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x05, 0x63, 0x73, 0x72, 0x65, 0x70, 0x12, 0x2f,
|
||||
0x0a, 0x06, 0x63, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x18, 0x2a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15,
|
||||
0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x63, 0x6f,
|
||||
0x6e, 0x6e, 0x65, 0x63, 0x74, 0x48, 0x00, 0x52, 0x06, 0x63, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x12,
|
||||
0x2c, 0x0a, 0x06, 0x63, 0x73, 0x64, 0x61, 0x74, 0x61, 0x18, 0x2b, 0x20, 0x01, 0x28, 0x0b, 0x32,
|
||||
0x12, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x64,
|
||||
0x61, 0x74, 0x61, 0x48, 0x00, 0x52, 0x06, 0x63, 0x73, 0x64, 0x61, 0x74, 0x61, 0x22, 0xa5, 0x02,
|
||||
0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x75, 0x6e, 0x6b, 0x6e, 0x6f, 0x77,
|
||||
0x6e, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x68, 0x61, 0x6e, 0x64, 0x73, 0x68, 0x61, 0x6b, 0x65,
|
||||
0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x6b, 0x65, 0x65, 0x70, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x10,
|
||||
0x02, 0x12, 0x0f, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x5f, 0x72, 0x65, 0x71,
|
||||
0x10, 0x03, 0x12, 0x0f, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x5f, 0x72, 0x65,
|
||||
0x70, 0x10, 0x04, 0x12, 0x0e, 0x0a, 0x0a, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63,
|
||||
0x74, 0x10, 0x05, 0x12, 0x0b, 0x0a, 0x07, 0x66, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x10, 0x06,
|
||||
0x12, 0x10, 0x0a, 0x0c, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x5f, 0x72, 0x65, 0x73, 0x69, 0x7a, 0x65,
|
||||
0x10, 0x0a, 0x12, 0x0e, 0x0a, 0x0a, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x5f, 0x64, 0x61, 0x74, 0x61,
|
||||
0x10, 0x0b, 0x12, 0x0c, 0x0a, 0x08, 0x76, 0x6e, 0x63, 0x5f, 0x63, 0x74, 0x72, 0x6c, 0x10, 0x14,
|
||||
0x12, 0x0d, 0x0a, 0x09, 0x76, 0x6e, 0x63, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x10, 0x15, 0x12,
|
||||
0x0d, 0x0a, 0x09, 0x76, 0x6e, 0x63, 0x5f, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x10, 0x16, 0x12, 0x10,
|
||||
0x0a, 0x0c, 0x76, 0x6e, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x10, 0x17,
|
||||
0x12, 0x0b, 0x0a, 0x07, 0x76, 0x6e, 0x63, 0x5f, 0x63, 0x61, 0x64, 0x10, 0x18, 0x12, 0x0e, 0x0a,
|
||||
0x0a, 0x76, 0x6e, 0x63, 0x5f, 0x73, 0x63, 0x72, 0x6f, 0x6c, 0x6c, 0x10, 0x19, 0x12, 0x11, 0x0a,
|
||||
0x0d, 0x76, 0x6e, 0x63, 0x5f, 0x63, 0x6c, 0x69, 0x70, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x10, 0x1a,
|
||||
0x12, 0x10, 0x0a, 0x0c, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
||||
0x10, 0x1e, 0x12, 0x11, 0x0a, 0x0d, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f,
|
||||
0x6e, 0x73, 0x65, 0x10, 0x1f, 0x42, 0x09, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64,
|
||||
0x42, 0x0c, 0x5a, 0x0a, 0x2e, 0x2f, 0x3b, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x62, 0x06,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x05, 0x63, 0x73, 0x72, 0x65, 0x71, 0x12, 0x3c,
|
||||
0x0a, 0x09, 0x63, 0x73, 0x72, 0x65, 0x70, 0x5f, 0x68, 0x64, 0x72, 0x18, 0x29, 0x20, 0x01, 0x28,
|
||||
0x0b, 0x32, 0x1d, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x63, 0x6f, 0x64, 0x65,
|
||||
0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72,
|
||||
0x48, 0x00, 0x52, 0x08, 0x63, 0x73, 0x72, 0x65, 0x70, 0x48, 0x64, 0x72, 0x12, 0x3c, 0x0a, 0x0a,
|
||||
0x63, 0x73, 0x72, 0x65, 0x70, 0x5f, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x2a, 0x20, 0x01, 0x28, 0x0b,
|
||||
0x32, 0x1b, 0x2e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x5f,
|
||||
0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x62, 0x6f, 0x64, 0x79, 0x48, 0x00, 0x52,
|
||||
0x09, 0x63, 0x73, 0x72, 0x65, 0x70, 0x42, 0x6f, 0x64, 0x79, 0x12, 0x2f, 0x0a, 0x06, 0x63, 0x73,
|
||||
0x63, 0x6f, 0x6e, 0x6e, 0x18, 0x2b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6e, 0x65, 0x74,
|
||||
0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63,
|
||||
0x74, 0x48, 0x00, 0x52, 0x06, 0x63, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x12, 0x2c, 0x0a, 0x06, 0x63,
|
||||
0x73, 0x64, 0x61, 0x74, 0x61, 0x18, 0x2c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6e, 0x65,
|
||||
0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x48,
|
||||
0x00, 0x52, 0x06, 0x63, 0x73, 0x64, 0x61, 0x74, 0x61, 0x22, 0xe2, 0x02, 0x0a, 0x04, 0x74, 0x79,
|
||||
0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x75, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12,
|
||||
0x0d, 0x0a, 0x09, 0x68, 0x61, 0x6e, 0x64, 0x73, 0x68, 0x61, 0x6b, 0x65, 0x10, 0x01, 0x12, 0x0d,
|
||||
0x0a, 0x09, 0x6b, 0x65, 0x65, 0x70, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x10, 0x02, 0x12, 0x0f, 0x0a,
|
||||
0x0b, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x10, 0x03, 0x12, 0x0f,
|
||||
0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x5f, 0x72, 0x65, 0x70, 0x10, 0x04, 0x12,
|
||||
0x0e, 0x0a, 0x0a, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x10, 0x05, 0x12,
|
||||
0x0b, 0x0a, 0x07, 0x66, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x10, 0x06, 0x12, 0x10, 0x0a, 0x0c,
|
||||
0x73, 0x68, 0x65, 0x6c, 0x6c, 0x5f, 0x72, 0x65, 0x73, 0x69, 0x7a, 0x65, 0x10, 0x0a, 0x12, 0x0e,
|
||||
0x0a, 0x0a, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x10, 0x0b, 0x12, 0x0c,
|
||||
0x0a, 0x08, 0x76, 0x6e, 0x63, 0x5f, 0x63, 0x74, 0x72, 0x6c, 0x10, 0x14, 0x12, 0x0d, 0x0a, 0x09,
|
||||
0x76, 0x6e, 0x63, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x10, 0x15, 0x12, 0x0d, 0x0a, 0x09, 0x76,
|
||||
0x6e, 0x63, 0x5f, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x10, 0x16, 0x12, 0x10, 0x0a, 0x0c, 0x76, 0x6e,
|
||||
0x63, 0x5f, 0x6b, 0x65, 0x79, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x10, 0x17, 0x12, 0x0b, 0x0a, 0x07,
|
||||
0x76, 0x6e, 0x63, 0x5f, 0x63, 0x61, 0x64, 0x10, 0x18, 0x12, 0x0e, 0x0a, 0x0a, 0x76, 0x6e, 0x63,
|
||||
0x5f, 0x73, 0x63, 0x72, 0x6f, 0x6c, 0x6c, 0x10, 0x19, 0x12, 0x11, 0x0a, 0x0d, 0x76, 0x6e, 0x63,
|
||||
0x5f, 0x63, 0x6c, 0x69, 0x70, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x10, 0x1a, 0x12, 0x10, 0x0a, 0x0c,
|
||||
0x63, 0x6f, 0x64, 0x65, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x10, 0x1e, 0x12, 0x15,
|
||||
0x0a, 0x11, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f,
|
||||
0x68, 0x64, 0x72, 0x10, 0x1f, 0x12, 0x16, 0x0a, 0x12, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x72, 0x65,
|
||||
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x62, 0x6f, 0x64, 0x79, 0x10, 0x20, 0x12, 0x10, 0x0a,
|
||||
0x0c, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x10, 0x21, 0x12,
|
||||
0x0d, 0x0a, 0x09, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x10, 0x22, 0x42, 0x09,
|
||||
0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x0c, 0x5a, 0x0a, 0x2e, 0x2f, 0x3b,
|
||||
0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -578,24 +609,25 @@ func file_msg_proto_rawDescGZIP() []byte {
|
||||
var file_msg_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_msg_proto_goTypes = []interface{}{
|
||||
(MsgType)(0), // 0: network.msg.type
|
||||
(*HandshakePayload)(nil), // 1: network.handshake_payload
|
||||
(*Msg)(nil), // 2: network.msg
|
||||
(*ConnectRequest)(nil), // 3: network.connect_request
|
||||
(*ConnectResponse)(nil), // 4: network.connect_response
|
||||
(*Data)(nil), // 5: network.data
|
||||
(*ShellResize)(nil), // 6: network.shell_resize
|
||||
(*ShellData)(nil), // 7: network.shell_data
|
||||
(*VncControl)(nil), // 8: network.vnc_control
|
||||
(*VncImage)(nil), // 9: network.vnc_image
|
||||
(*VncMouse)(nil), // 10: network.vnc_mouse
|
||||
(*VncKeyboard)(nil), // 11: network.vnc_keyboard
|
||||
(*VncScroll)(nil), // 12: network.vnc_scroll
|
||||
(*VncClipboard)(nil), // 13: network.vnc_clipboard
|
||||
(*CodeRequest)(nil), // 14: network.code_request
|
||||
(*CodeResponse)(nil), // 15: network.code_response
|
||||
(*CodeConnect)(nil), // 16: network.code_connect
|
||||
(*CodeData)(nil), // 17: network.code_data
|
||||
(MsgType)(0), // 0: network.msg.type
|
||||
(*HandshakePayload)(nil), // 1: network.handshake_payload
|
||||
(*Msg)(nil), // 2: network.msg
|
||||
(*ConnectRequest)(nil), // 3: network.connect_request
|
||||
(*ConnectResponse)(nil), // 4: network.connect_response
|
||||
(*Data)(nil), // 5: network.data
|
||||
(*ShellResize)(nil), // 6: network.shell_resize
|
||||
(*ShellData)(nil), // 7: network.shell_data
|
||||
(*VncControl)(nil), // 8: network.vnc_control
|
||||
(*VncImage)(nil), // 9: network.vnc_image
|
||||
(*VncMouse)(nil), // 10: network.vnc_mouse
|
||||
(*VncKeyboard)(nil), // 11: network.vnc_keyboard
|
||||
(*VncScroll)(nil), // 12: network.vnc_scroll
|
||||
(*VncClipboard)(nil), // 13: network.vnc_clipboard
|
||||
(*CodeRequest)(nil), // 14: network.code_request
|
||||
(*CodeResponseHeader)(nil), // 15: network.code_response_header
|
||||
(*CodeResponseBody)(nil), // 16: network.code_response_body
|
||||
(*CodeConnect)(nil), // 17: network.code_connect
|
||||
(*CodeData)(nil), // 18: network.code_data
|
||||
}
|
||||
var file_msg_proto_depIdxs = []int32{
|
||||
0, // 0: network.msg._type:type_name -> network.msg.type
|
||||
@@ -612,14 +644,15 @@ var file_msg_proto_depIdxs = []int32{
|
||||
12, // 11: network.msg.vscroll:type_name -> network.vnc_scroll
|
||||
13, // 12: network.msg.vclipboard:type_name -> network.vnc_clipboard
|
||||
14, // 13: network.msg.csreq:type_name -> network.code_request
|
||||
15, // 14: network.msg.csrep:type_name -> network.code_response
|
||||
16, // 15: network.msg.csconn:type_name -> network.code_connect
|
||||
17, // 16: network.msg.csdata:type_name -> network.code_data
|
||||
17, // [17:17] is the sub-list for method output_type
|
||||
17, // [17:17] is the sub-list for method input_type
|
||||
17, // [17:17] is the sub-list for extension type_name
|
||||
17, // [17:17] is the sub-list for extension extendee
|
||||
0, // [0:17] is the sub-list for field type_name
|
||||
15, // 14: network.msg.csrep_hdr:type_name -> network.code_response_header
|
||||
16, // 15: network.msg.csrep_body:type_name -> network.code_response_body
|
||||
17, // 16: network.msg.csconn:type_name -> network.code_connect
|
||||
18, // 17: network.msg.csdata:type_name -> network.code_data
|
||||
18, // [18:18] is the sub-list for method output_type
|
||||
18, // [18:18] is the sub-list for method input_type
|
||||
18, // [18:18] is the sub-list for extension type_name
|
||||
18, // [18:18] is the sub-list for extension extendee
|
||||
0, // [0:18] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_msg_proto_init() }
|
||||
@@ -672,7 +705,8 @@ func file_msg_proto_init() {
|
||||
(*Msg_Vscroll)(nil),
|
||||
(*Msg_Vclipboard)(nil),
|
||||
(*Msg_Csreq)(nil),
|
||||
(*Msg_Csrep)(nil),
|
||||
(*Msg_CsrepHdr)(nil),
|
||||
(*Msg_CsrepBody)(nil),
|
||||
(*Msg_Csconn)(nil),
|
||||
(*Msg_Csdata)(nil),
|
||||
}
|
||||
|
@@ -34,8 +34,11 @@ message msg {
|
||||
vnc_scroll = 25;
|
||||
vnc_clipboard = 26;
|
||||
// code-server
|
||||
code_request = 30;
|
||||
code_response = 31;
|
||||
code_request = 30;
|
||||
code_response_hdr = 31;
|
||||
code_response_body = 32;
|
||||
code_connect = 33;
|
||||
code_data = 34;
|
||||
}
|
||||
type _type = 1;
|
||||
string from = 2;
|
||||
@@ -57,9 +60,10 @@ message msg {
|
||||
vnc_scroll vscroll = 34;
|
||||
vnc_clipboard vclipboard = 35;
|
||||
// code-server
|
||||
code_request csreq = 40;
|
||||
code_response csrep = 41;
|
||||
code_connect csconn = 42;
|
||||
code_data csdata = 43;
|
||||
code_request csreq = 40;
|
||||
code_response_header csrep_hdr = 41;
|
||||
code_response_body csrep_body = 42;
|
||||
code_connect csconn = 43;
|
||||
code_data csdata = 44;
|
||||
}
|
||||
}
|
@@ -21,10 +21,10 @@ go run contrib/bindata/main.go -pkg shell -o code/client/rule/shell/assets.go \
|
||||
-prefix html/shell "$@" html/shell/...
|
||||
go run contrib/bindata/main.go -pkg vnc -o code/client/rule/vnc/assets.go \
|
||||
-prefix html/vnc "$@" html/vnc/...
|
||||
go run contrib/bindata/main.go -pkg code -o code/client/rule/code/assets.go \
|
||||
-prefix html/code "$@" html/code/...
|
||||
go run contrib/bindata/main.go -pkg dashboard -o code/client/dashboard/assets.go \
|
||||
-prefix html/dashboard "$@" html/dashboard/...
|
||||
|
||||
go build -ldflags "$LDFLAGS" -o bin/np-svr code/server/*.go
|
||||
# CC=x86_64-w64-mingw32-gcc \
|
||||
# CXX=x86_64-w64-mingw32-g++ \
|
||||
go build -ldflags "$LDFLAGS" -tags "$TAGS" -o bin/np-cli code/client/*.go
|
@@ -136,6 +136,15 @@ func bindata() {
|
||||
cmd.Stderr = os.Stderr
|
||||
runtime.Assert(cmd.Run())
|
||||
|
||||
cmd = exec.Command("go", "run", "contrib/bindata/main.go",
|
||||
"-pkg", "code",
|
||||
"-o", "code/client/rule/code/assets.go",
|
||||
"-prefix", "html/code",
|
||||
"html/code/...")
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
runtime.Assert(cmd.Run())
|
||||
|
||||
cmd = exec.Command("go", "run", "contrib/bindata/main.go",
|
||||
"-pkg", "dashboard",
|
||||
"-o", "code/client/dashboard/assets.go",
|
||||
|
0
html/code/index.css
Normal file
0
html/code/index.css
Normal file
22
html/code/index.html
Normal file
22
html/code/index.html
Normal file
@@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>code - [{{.Name}}]</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<script src="/jquery/jquery-3.6.0.min.js"></script>
|
||||
<link rel="stylesheet" href="/index.css" />
|
||||
<script src="/index.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div>
|
||||
<i id="fullscreen" class="fas fa-expand"></i>
|
||||
<span id="closed" style="display: none;">连接已断开</span>
|
||||
</div>
|
||||
<!-- header -->
|
||||
<iframe id="code"></iframe>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
13
html/code/index.js
Normal file
13
html/code/index.js
Normal file
@@ -0,0 +1,13 @@
|
||||
var page = {
|
||||
init: function() {
|
||||
page.connect();
|
||||
},
|
||||
connect: function() {
|
||||
$.get('/new', function(ret) {
|
||||
page.id = ret;
|
||||
$('#code').attr('src', `/forward/${page.id}/`);
|
||||
});
|
||||
},
|
||||
id: ''
|
||||
};
|
||||
$(document).ready(page.init);
|
1
html/code/jquery
Symbolic link
1
html/code/jquery
Symbolic link
@@ -0,0 +1 @@
|
||||
../jquery
|
@@ -3,19 +3,51 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/lwch/runtime"
|
||||
)
|
||||
|
||||
var cli = &http.Client{}
|
||||
var cli = &http.Client{
|
||||
Transport: &http.Transport{
|
||||
Dial: func(network, addr string) (net.Conn, error) {
|
||||
return net.Dial("unix", "./code-server/code-server.sock")
|
||||
},
|
||||
},
|
||||
}
|
||||
var upgrader = websocket.Upgrader{}
|
||||
var dialer = websocket.Dialer{}
|
||||
var dialer = websocket.Dialer{
|
||||
NetDial: func(network, addr string) (net.Conn, error) {
|
||||
return net.Dial("unix", "./code-server/code-server.sock")
|
||||
},
|
||||
}
|
||||
|
||||
func main() {
|
||||
dir := "/home/lwch/src/natpass/code-server"
|
||||
exec := exec.Command("code-server", "--disable-update-check",
|
||||
"--auth", "none",
|
||||
"--socket", filepath.Join(dir, "code-server.sock"),
|
||||
"--user-data-dir", filepath.Join(dir, "data"),
|
||||
"--extensions-dir", filepath.Join(dir, "extensions"), ".")
|
||||
exec.Stdout = os.Stdout
|
||||
exec.Stderr = os.Stderr
|
||||
runtime.Assert(exec.Start())
|
||||
time.Sleep(time.Second)
|
||||
|
||||
go exec.Wait()
|
||||
|
||||
conn, err := net.Dial("unix", "./code-server/code-server.sock")
|
||||
runtime.Assert(err)
|
||||
conn.Close()
|
||||
|
||||
http.HandleFunc("/", next)
|
||||
http.ListenAndServe(":8001", nil)
|
||||
}
|
||||
@@ -23,7 +55,7 @@ func main() {
|
||||
func normal(w http.ResponseWriter, r *http.Request) {
|
||||
u := r.URL
|
||||
u.Scheme = "http"
|
||||
u.Host = "127.0.0.1:8000"
|
||||
u.Host = "unix"
|
||||
req, err := http.NewRequest(r.Method, u.String(), r.Body)
|
||||
runtime.Assert(err)
|
||||
|
||||
@@ -52,7 +84,7 @@ func normal(w http.ResponseWriter, r *http.Request) {
|
||||
func ws(w http.ResponseWriter, r *http.Request) {
|
||||
u := r.URL
|
||||
u.Scheme = "ws"
|
||||
u.Host = "127.0.0.1:8000"
|
||||
u.Host = "unix"
|
||||
|
||||
hdr := make(http.Header)
|
||||
for key, values := range r.Header {
|
||||
|
Reference in New Issue
Block a user