Documentation ¶
Index ¶
- Constants
- Variables
- func ConnetctServer(cid, port uint32) (*vsock.Conn, error)
- func Exists(path string) bool
- func InitViper()
- func IntToBytes(n uint32) []byte
- func SendMsg(msg string, conn net.Conn)
- func StartServer(port uint32)
- func UnPackageData(data []MessagePackage) ([]byte, error)
- type MessagePackage
- type MessagePackageSlice
- type MyMessage
- type PackageHeader
Constants ¶
View Source
const BODY_MAX_SIZE = 256 // 包的body的最大size;
View Source
const BODY_SIZE_LEN = 4 // body实际长度占用的字节数
View Source
const CONNECTED_OK = "CONNECT_OK"
View Source
const FILE_HASH_LEN = 32 // file的hash的长度
View Source
const FILE_SIZE_LEN = 4 // file长度占用字节数
View Source
const MAX_BYTE_LENGTH_OF_DATA = 4294967295
View Source
const PACKAGE_HASH_LEN = 32 // 包的hash的长度
View Source
const PACKAGE_ID_LEN = 4 // 包id占用的字节数
View Source
const PACKAGE_MAX_SIZE = FILE_HASH_LEN + FILE_SIZE_LEN + PACKAGE_HASH_LEN + PACKAGE_ID_LEN + BODY_SIZE_LEN + BODY_MAX_SIZE // 包的长度
View Source
const VMADDR_CID_ANY uint32 = 4294967295
View Source
const VMADDR_CID_HOST uint32 = 2
View Source
const VMADDR_CID_HYPERVISOR uint32 = 0
View Source
const VMADDR_CID_RESERVED = 1
View Source
const VMADDR_PORT_ANY uint32 = 4294967295
View Source
const VSOCK_EOF = "EOF"
Variables ¶
View Source
var Config *viper.Viper
View Source
var MSG_FROM_SERVER_CHAN chan MyMessage = make(chan MyMessage)
View Source
var RECV_MSG_CHAN chan MyMessage = make(chan MyMessage)
Functions ¶
func IntToBytes ¶
func StartServer ¶
func StartServer(port uint32)
func UnPackageData ¶
func UnPackageData(data []MessagePackage) ([]byte, error)
Types ¶
type MessagePackage ¶
type MessagePackage struct { *PackageHeader Body [BODY_MAX_SIZE]byte }
func BytesToMessagePackage ¶
func BytesToMessagePackage(data [PACKAGE_MAX_SIZE]byte) MessagePackage
func PackageData ¶
func PackageData(data []byte) ([]MessagePackage, error)
type MessagePackageSlice ¶
type MessagePackageSlice []MessagePackage
func (MessagePackageSlice) Len ¶
func (m MessagePackageSlice) Len() int
func (MessagePackageSlice) Less ¶
func (m MessagePackageSlice) Less(i, j int) bool
func (MessagePackageSlice) Swap ¶
func (m MessagePackageSlice) Swap(i, j int)
Click to show internal directories.
Click to hide internal directories.