1.不追踪二进制文件

2.重构。完成了基本的功能。

Signed-off-by: dmy@lab <dmy@lab.com>
This commit is contained in:
dmy@lab
2015-10-08 23:11:07 +08:00
parent fc533656a0
commit 9c4dafc07d
10 changed files with 142 additions and 114 deletions

20
tscipher/chacha.go Normal file
View File

@@ -0,0 +1,20 @@
package tscipher
type ChaCha struct {
}
func (*ChaCha) Decrypt(data []byte) (decrypted []byte, err error) {
decrypted = data
err = nil
return
}
func (*ChaCha) Encrypt(data []byte) (encryped []byte, err error) {
encryped = data
err = nil
return
}
func NewChaCha() (cipher Cipher) {
return &ChaCha{}
}

33
tscipher/cipher.go Normal file
View File

@@ -0,0 +1,33 @@
package tscipher
import (
"net"
)
type Cipher interface {
Decrypt(data []byte) (decrypted []byte, err error)
Encrypt(data []byte) (encryped []byte, err error)
}
type Carrier struct {
Conn net.Conn
Cipher Cipher
Cache []byte
}
func NewCipher(cipherName string) (cipher Cipher) {
if cipherName == "default" {
return NewChaCha()
}
return nil //TODO:临时这样处理
}
func SendData(carrier *Carrier, nByte int) (n int, err error) {
n, err = carrier.Conn.Write(carrier.Cache[:nByte])
return
}
func ReceiveData(carrier *Carrier) (n int, err error) {
n, err = carrier.Conn.Read(carrier.Cache)
return
}

View File

@@ -0,0 +1,5 @@
package tscipher
import (
// "github.com/TransX/cipher"
)