-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add new msg type handlers * Fixes * more fixes
- Loading branch information
Showing
12 changed files
with
256 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
|
||
build: | ||
mkdir -p devbin | ||
go build -o devbin/yproxy ./cmd/yproxy | ||
go build -o devbin/client ./cmd/client | ||
go build -o devbin/client ./cmd/client | ||
|
||
####################### TESTS ####################### | ||
|
||
unittest: | ||
go test -race ./pkg/proc/... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module github.com/yezzey-gp/yproxy | ||
|
||
go 1.21.1 | ||
go 1.21 | ||
|
||
require ( | ||
github.com/BurntSushi/toml v1.3.2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package proc | ||
|
||
import ( | ||
"encoding/binary" | ||
) | ||
|
||
type CopyDataMessage struct { | ||
ProtoMessage | ||
Sz uint64 | ||
Data []byte | ||
} | ||
|
||
func NewCopyDataMessage() *CopyDataMessage { | ||
return &CopyDataMessage{} | ||
} | ||
|
||
func (cc *CopyDataMessage) Encode() []byte { | ||
bt := make([]byte, 4+cc.Sz) | ||
|
||
bt[0] = byte(MessageTypeCopyData) | ||
|
||
// sizeof(sz) + data | ||
ln := len(bt) + 8 + 8 + int(cc.Sz) | ||
|
||
bs := make([]byte, 8) | ||
binary.BigEndian.PutUint64(bs, uint64(ln)) | ||
|
||
binary.BigEndian.PutUint64(bt[4:], uint64(cc.Sz)) | ||
|
||
// check data len more than cc.sz? | ||
copy(bt[4+8:], cc.Data[:cc.Sz]) | ||
|
||
return append(bs, bt...) | ||
} | ||
|
||
func (cc *CopyDataMessage) Decode(data []byte) { | ||
msgLenBuf := data[4:12] | ||
cc.Sz = binary.BigEndian.Uint64(msgLenBuf) | ||
cc.Data = make([]byte, cc.Sz) | ||
copy(cc.Data, data[12:12+cc.Sz]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters