my_vsock

package
v0.0.0-...-fbeb6a2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2022 License: MIT Imports: 13 Imported by: 3

Documentation

Index

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 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 ConnetctServer

func ConnetctServer(cid, port uint32) (*vsock.Conn, error)

func Exists

func Exists(path string) bool

func InitViper

func InitViper()

func IntToBytes

func IntToBytes(n uint32) []byte

func SendMsg

func SendMsg(msg string, conn net.Conn)

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)

type MyMessage

type MyMessage struct {
	Data []byte
	Conn net.Conn
}

type PackageHeader

type PackageHeader struct {
	FileHash    [32]byte
	PackageHash [32]byte
	Length      []byte // 4 bytes
	PackageId   []byte // 4 bytes
	BodyLen     []byte // 4 bytes
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL