protocol

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2019 License: MIT Imports: 2 Imported by: 12

Documentation

Index

Constants

View Source
const (
	// 初始化,在node对象建立之前
	INIT = iota
	// 控制协议
	SYNC
	LISTEN
	CONNECT
	SHELL
	UPLOAD
	DOWNLOAD
	SOCKS
	LFORWARD
	RFORWARD
	SSHCONNECT
	// 数据传输协议
	SOCKSDATA
	LFORWARDDATA
	RFORWARDDATA
)

协议类型

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectPacketCmd

type ConnectPacketCmd struct {
	IP   uint32
	Port uint16
}

type ConnectPacketRet

type ConnectPacketRet struct {
	Success uint16 // 操作是否成功, 1 or 0
	MsgLen  uint32 // 返回的信息长度
	Msg     []byte // 如果成功则为空, 否则为错误信息
}

type DownloadPacketCmd

type DownloadPacketCmd struct {
	PathLen       uint32 // 目标路径长度
	Path          []byte // 目标路径名
	StillDownload uint32 // 如果文件过大是否还有继续下载
}

DownloadPacketCmd 文件下载命令

type DownloadPacketRet

type DownloadPacketRet struct {
	Success uint16 // 操作是否成功, 1 or 0
	MsgLen  uint32 // 返回的信息长度
	Msg     []byte // 如果成功则为空, 否则为错误信息
	FileLen uint64 // 文件大小

}

DownloadPacketRet 文件下载返回包

type FileDataPacket

type FileDataPacket struct {
	DataLen uint32 // 返回的信息长度
	Data    []byte // 如果成功则为空, 否则为错误信息
}

type InitPacketCmd

type InitPacketCmd struct {
	OsType  uint32 // 系统类型
	IsAdmin uint16 // 是否为管理员节点
	HashID  [32]byte
}

InitPacketCmd 初始化数据包,命令数据

type InitPacketRet

type InitPacketRet struct {
	OsType  uint32 // 系统类型
	IsAdmin uint16 // 是否为管理员节点
	HashID  [32]byte
}

InitPacketRet 初始化数据包,命令数据

type ListenPacketCmd

type ListenPacketCmd struct {
	Port uint16
}

type ListenPacketRet

type ListenPacketRet struct {
	Success uint16 // 操作是否成功, 1 or 0
	MsgLen  uint32 // 返回的信息长度
	Msg     []byte // 如果成功则为空, 否则为错误信息
}

type NetDataPacket

type NetDataPacket struct {
	SessionID uint16 // session id用于标识该数据包属于哪一个TCP连接,因为可能存在并发访问的问题
	// 在对数据包按命令类型分流之后,还需要对其中的socks5数据包做tcp会话分流
	DataLen uint32 // 返回的信息长度
	Data    []byte // 如果成功则为空, 否则为错误信息
	Close   uint16 // 1表示连接关闭
}

type NetLForwardPacketCmd

type NetLForwardPacketCmd struct {
	Start   uint16
	DstPort uint16
	SrcPort uint16
	LHost   uint32
}

type NetLForwardPacketRet

type NetLForwardPacketRet struct {
	Success   uint16
	SessionID uint16
	SrcPort   uint16
	LHost     uint32
}

type NetRForwardPacketCmd

type NetRForwardPacketCmd struct {
	Start     uint16
	SessionID uint16
	RHost     uint32
	SrcPort   uint16
}

type NetRForwardPacketRet

type NetRForwardPacketRet struct {
	Success uint16
}

type Packet

type Packet struct {
	Separator string
	CmdType   uint16
	SrcHashID [32]byte // 源节点ID
	DstHashID [32]byte // 目的节点ID
	DataLen   uint64
	Data      []byte
}

Packet 是较为低层的数据包格式 比Packet高层的网络数据存放在Data中 如果Packet不属于本节点,则直接转发即可,无需解析Data格式

func (*Packet) ResolveData

func (packet *Packet) ResolveData(cmdPacket interface{})

ResolveData 解析Packet Data字段的数据为特定格式的数据包

func (*Packet) ResolveHeader

func (packet *Packet) ResolveHeader(header *PacketHeader)

ResolveHeader 解析Packet数据包中PacketHeader字段

type PacketHeader

type PacketHeader struct {
	Separator string
	CmdType   uint16
	SrcHashID [32]byte // 源节点ID
	DstHashID [32]byte // 目的节点ID
	DataLen   uint64
}

type ShellPacketCmd

type ShellPacketCmd struct {
	Start  uint16 // 启动shell
	CmdLen uint32 // 要执行的命令
	Cmd    []byte // 执行命令的长度
}

type ShellPacketRet

type ShellPacketRet struct {
	Success uint16 // 操作是否成功, 1 or 0
	DataLen uint32 // 返回的信息长度
	Data    []byte // 如果成功则为空, 否则为错误信息
}

type Socks5ControlPacketCmd

type Socks5ControlPacketCmd struct {
	Start     uint16 // 启动一个socks5连接/关闭这个socks5连接,针对一个TCP连接而言
	SessionID uint16
}

type Socks5ControlPacketRet

type Socks5ControlPacketRet struct {
	Success uint16 // 启动一个socks5连接/关闭这个socks5连接,针对一个TCP连接而言
}

type SshConnectPacketCmd

type SshConnectPacketCmd struct {
	SshServer      uint32 // 服务端IP地址
	SshPort        uint16 // ssh服务端口
	DstPort        uint16 // 要连接的target node监听的端口
	SshUserLen     uint32
	SshUser        []byte // ssh用户名
	SshAuthMethod  uint16 // password(1) / ssh key(2)
	SshAuthDataLen uint32
	SshAuthData    []byte // ssh key or password
}

type SshConnectPacketRet

type SshConnectPacketRet struct {
	Success uint16 // 操作是否成功, 1 or 0
	MsgLen  uint32 // 返回的信息长度
	Msg     []byte // 如果成功则为空, 否则为错误信息
}

type SyncPacket

type SyncPacket struct {
	NetworkMapLen uint64
	NetworkMap    []byte
}

type UploadPacketCmd

type UploadPacketCmd struct {
	PathLen uint32 // 目标路径长度
	Path    []byte
	FileLen uint64 // 文件大小

}

UploadPacketCmd

type UploadPacketRet

type UploadPacketRet struct {
	Success uint16 // 操作是否成功, 1 or 0
	MsgLen  uint32 // 返回的信息长度
	Msg     []byte // 如果成功则为空, 否则为错误信息
}

UploadPacketRet 文件上传返回包

Jump to

Keyboard shortcuts

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