controller

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2022 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NO_TALKER       = 0x000
	TALKER_REQ      = 0x001
	TALKER_I_HAVE   = 0x010
	TALKER_YOU_HAVE = 0x100

	TALKER_CONNECTED = 0x111
	TALKER_ERR       = -1
)
View Source
const (
	MSG_TP_NORMAL = iota
	MSG_TP_GROUP
)
View Source
const FILE_CIPHER_HEADER_LEN = 188
View Source
const TIME_TMP = "2006-1-2 15:04:05 -0700 MST"

Variables

View Source
var (
	// HOME, _  = os.UserHomeDir()
	KeysHome      = filepath.Join(HOME, ".sshchat", "keys")
	GroupKeysHome = filepath.Join(HOME, ".sshchat", "gkeys")
)
View Source
var (
	MSG_HISTORY     = "message.history.txt"
	MSG_FILE        = "message.txt"
	MSG_HEART       = "heart"
	MSG_PRIVATE_KEY = "keys"
	MSG_FILE_ROOT   = "files"
	MSG_HELLO       = "info"
	MSG_ICON        = "icon.png"
	MSG_TMP_FILE    = "tmp_file"
	ROOT            = "/tmp/SecureRoom"
	GROUP_TAIL      = "_GroUP"
	TMP             = "/tmp"
	MSG_KICK        = "kick"
	MSG_CLIP_PREFIX = "[clipbroad]:"
	MsgIsNULL       = fmt.Errorf("msg is null!!")
)
View Source
var (
	HOME, _ = os.UserHomeDir()
)

Functions

func ClearLocalCache added in v1.1.0

func ClearLocalCache()

func GetGroupKey

func GetGroupKey(name string) string

func GetKey

func GetKey(name string) string

func Join

func Join(root string, files ...string) string

func L added in v1.1.4

func L(tmp string, args ...interface{})

func LocalGroupKeys

func LocalGroupKeys() (kmac []string)

func LocalKeys

func LocalKeys() (kmac []string)

func NewKey

func NewKey() string

func Ok added in v1.1.4

func Ok(tmp string, args ...interface{})

func SecurityCheckName

func SecurityCheckName(name string)

func SetGroupKey

func SetGroupKey(name, key string)

func SetHome

func SetHome(h string)

func SetKey

func SetKey(name, key string)

func ToMd5

func ToMd5(key string) string

func VerifyKey

func VerifyKey(name, mac string) (exists, group bool)

Types

type ChatRoom

type ChatRoom struct {
	IP string

	MyName string
	// contains filtered or unexported fields
}

func NewChatRoom

func NewChatRoom(sshstr string, HomePath ...string) (chat *ChatRoom, err error)

NewChatRoom HOME default is '~'

func (*ChatRoom) ClearLocalCache added in v1.1.0

func (chat *ChatRoom) ClearLocalCache()

func (*ChatRoom) CloseWithClear

func (chat *ChatRoom) CloseWithClear(t int)

func (*ChatRoom) CloudFiles

func (chat *ChatRoom) CloudFiles(groupName ...string) (fs []string)

func (*ChatRoom) Contact

func (chat *ChatRoom) Contact() (users []*User)

func (*ChatRoom) CreateGroup

func (chat *ChatRoom) CreateGroup(name string)

func (*ChatRoom) ExistsUser added in v1.1.1

func (chat *ChatRoom) ExistsUser(name string) bool

func (*ChatRoom) GetFile

func (chat *ChatRoom) GetFile(name string, groupName ...string) (err error)

func (*ChatRoom) GetMyIcon added in v1.1.0

func (chat *ChatRoom) GetMyIcon() (buf []byte, err error)

func (*ChatRoom) GetMyIconWithPath added in v1.1.0

func (chat *ChatRoom) GetMyIconWithPath() string

func (*ChatRoom) GetMyLocalHome added in v1.1.0

func (chat *ChatRoom) GetMyLocalHome() string

func (*ChatRoom) GetTalker

func (chat *ChatRoom) GetTalker() string

func (*ChatRoom) GetTalkerSIcon added in v1.1.0

func (chat *ChatRoom) GetTalkerSIcon(name ...string) (buf []byte, err error)

func (*ChatRoom) GetTalkerSIconPath added in v1.1.0

func (chat *ChatRoom) GetTalkerSIconPath(name ...string) (string, error)

func (*ChatRoom) GroupVerify

func (chat *ChatRoom) GroupVerify(name string) bool

func (*ChatRoom) History

func (chat *ChatRoom) History()

func (*ChatRoom) Init

func (chat *ChatRoom) Init(sshstr string) (err error)

func (*ChatRoom) IsGroupName

func (chat *ChatRoom) IsGroupName(name string) (string, bool)

func (*ChatRoom) JoinGroup

func (chat *ChatRoom) JoinGroup(name string)

func (*ChatRoom) Login

func (chat *ChatRoom) Login(restoresKey ...string) (logined bool)

func (*ChatRoom) Permitt

func (chat *ChatRoom) Permitt(gname, uname string)

func (*ChatRoom) Read

func (chat *ChatRoom) Read() *Message

func (*ChatRoom) ReadEncryptedMessage

func (chat *ChatRoom) ReadEncryptedMessage(msg, from, to, group string, date time.Time, tp int, crypted bool) (m *Message, err error)

func (*ChatRoom) RemoveGroup

func (chat *ChatRoom) RemoveGroup(name string)

func (*ChatRoom) RestoreKeyFromServer

func (chat *ChatRoom) RestoreKeyFromServer(key string) bool

func (*ChatRoom) SaveKeyToServer

func (chat *ChatRoom) SaveKeyToServer(key string) bool

func (*ChatRoom) SendFile

func (chat *ChatRoom) SendFile(path string, groupName ...string) (err error)

func (*ChatRoom) SetMyIcon added in v1.1.0

func (chat *ChatRoom) SetMyIcon(path string) (err error)

func (*ChatRoom) SetWacher

func (chat *ChatRoom) SetWacher(call func(msg *Message))

func (*ChatRoom) TalkTo

func (chat *ChatRoom) TalkTo(name string) (icon string)

func (*ChatRoom) UpdateMyIconWithPath added in v1.1.0

func (chat *ChatRoom) UpdateMyIconWithPath() string

func (*ChatRoom) UpdateTalkerIconWithPath added in v1.1.0

func (chat *ChatRoom) UpdateTalkerIconWithPath(name ...string) string

func (*ChatRoom) Write

func (chat *ChatRoom) Write(msg string)

func (*ChatRoom) WriteGroup

func (chat *ChatRoom) WriteGroup(gname, msg string)

type CipherFileHeader

type CipherFileHeader struct {
	From [100]byte `json:"from"`
	Len  int64     `json:"size"`
}

type EnHeader

type EnHeader struct {
	NO int `json:"no"`
	L  int `json:"size"`
}

type Group

type Group struct {
	Members []string
}

type Message

type Message struct {
	Date    string `json:"date"`
	Data    string `json:"data"`
	From    string `json:"from"`
	Group   string `json:"group"`
	Tp      int    `json:"tp"`
	To      string `json:"to"`
	Crypted bool   `json:"crypt"`
	Readed  string `json:"readed"`
}

type Stream

type Stream struct {
	Key    string `json:"key"`
	Author string `json:"author"`
	// contains filtered or unexported fields
}

func NewStreamWithAuthor

func NewStreamWithAuthor(author string, loadGroupKey bool) (stream *Stream, err error)

func NewStreamWithAuthorNoSave added in v1.1.4

func NewStreamWithAuthorNoSave(author string, loadGroupKey bool) (stream *Stream, err error)

func NewStreamWithBase64Key

func NewStreamWithBase64Key(keyb64 string) (stream *Stream, err error)

func NewStreamWithRandomeKey

func NewStreamWithRandomeKey() (stream *Stream, err error)

func (*Stream) De

func (stream *Stream) De(cipher []byte) (plain []byte)

func (*Stream) DecryptFile

func (stream *Stream) DecryptFile(cipherFile, plainFile string, bar ...func(int64)) (err error)

func (*Stream) En

func (stream *Stream) En(plain []byte) (cipher []byte)

func (*Stream) EncryptFile

func (stream *Stream) EncryptFile(plainFile, cipherFile string, bar ...func(int64)) (err error)

func (*Stream) Flow

func (steam *Stream) Flow(raw []byte) (out []byte)

func (*Stream) FlowDe

func (stream *Stream) FlowDe(raw64 string) (out string)

func (*Stream) FlowEn

func (stream *Stream) FlowEn(raw string) (out string)

func (*Stream) LoadCipherByAuthor

func (stream *Stream) LoadCipherByAuthor(author string) (err error)

func (*Stream) ReBildCipherByKey

func (stream *Stream) ReBildCipherByKey(keyb64 string)

func (*Stream) SaveKey

func (stream *Stream) SaveKey(author string, grouped bool)

func (*Stream) StreamDecrypt

func (stream *Stream) StreamDecrypt(dst io.Writer, src io.Reader, bar ...func(uploaded int64)) (copied int64, err error)

func (*Stream) StreamEncrypt

func (stream *Stream) StreamEncrypt(dst io.Writer, src io.Reader, bar ...func(updated int64)) (copied int64, err error)

type User

type User struct {
	Name       string `json:"name"`
	State      bool   `json:"login"`
	LastActive string `json:"last"`
}

func (*User) Acivte

func (u *User) Acivte() string

func (*User) IfAlive

func (u *User) IfAlive() bool

func (*User) Last

func (u *User) Last() (t time.Time)

type Vps

type Vps struct {
	IP     string
	USER   string
	PWD    string
	TAG    string
	Region string
	Proxy  string
	// contains filtered or unexported fields
}

func Parse

func Parse(sshStr string) *Vps

func (*Vps) AllowJoinGroup

func (vps *Vps) AllowJoinGroup(gname, uname string)

func (*Vps) CacheMsg

func (vps *Vps) CacheMsg(msg *Message) (err error)

func (*Vps) Close

func (vps *Vps) Close()

func (*Vps) CloseWithClear

func (vps *Vps) CloseWithClear(t int)

func (*Vps) CloudFiles

func (vps *Vps) CloudFiles(groupName ...string) (files []string)

func (*Vps) Connect

func (vps *Vps) Connect() (client *ssh.Client, sess *ssh.Session, err error)

func (*Vps) Contact

func (vps *Vps) Contact() (users []*User, err error)

func (*Vps) ContactTo

func (vps *Vps) ContactTo(name string) (ip string, err error)

func (*Vps) CreateGroup

func (vps *Vps) CreateGroup(name string)

func (*Vps) CreateMe

func (vps *Vps) CreateMe() (canlogin bool)

func (*Vps) D

func (vps *Vps) D(en string) string

func (*Vps) DownloadCloud

func (vps *Vps) DownloadCloud(name string, dealStream func(reader io.Reader) error, groupName ...string) (err error)

func (*Vps) E

func (vps *Vps) E(raw string) string

func (*Vps) ExchangeKeyCheck

func (vps *Vps) ExchangeKeyCheck() (my, you bool)

func (*Vps) Exists added in v1.1.0

func (vps *Vps) Exists(name string) (exists bool, dir bool)

func (*Vps) GenerateIcon added in v1.1.0

func (vps *Vps) GenerateIcon() (buf []byte, err error)

func (*Vps) GetGroupName

func (vps *Vps) GetGroupName(name string) string

func (*Vps) GetGroupVpsName

func (vps *Vps) GetGroupVpsName(name string) string

func (*Vps) GetRawMsgTo

func (vps *Vps) GetRawMsgTo() string

func (*Vps) GetRemoteKeyPath added in v1.1.0

func (vps *Vps) GetRemoteKeyPath(key string) string

func (*Vps) GetVpsName

func (vps *Vps) GetVpsName() string

func (*Vps) GroupCheck

func (vps *Vps) GroupCheck(name string) (exists, verified bool)

func (*Vps) GroupList

func (vps *Vps) GroupList() (groups []string)

func (*Vps) HeartBeat

func (vps *Vps) HeartBeat()

func (*Vps) History

func (vps *Vps) History() (msgs []*Message, err error)

func (*Vps) IfAlive

func (vps *Vps) IfAlive() (out bool)

func (*Vps) IfLogined added in v1.1.0

func (vps *Vps) IfLogined() (logined bool)

func (*Vps) Init

func (vps *Vps) Init() (err error)

func (*Vps) JoinGroup

func (vps *Vps) JoinGroup(name string)

func (*Vps) KickOld added in v1.1.0

func (vps *Vps) KickOld()

func (*Vps) OnMessage

func (vps *Vps) OnMessage(call func(group, from, to, msg string, crypted bool, tp int, date time.Time))

func (*Vps) RecvGroupMsg

func (vps *Vps) RecvGroupMsg() (msgs []*Message)

func (*Vps) RecvMsg

func (vps *Vps) RecvMsg() (msgs []*Message, err error)

func (*Vps) RemoveGroup

func (vps *Vps) RemoveGroup(name string)

func (Vps) Rm

func (vps Vps) Rm(file string) bool

func (*Vps) SaveKeyToServer

func (vps *Vps) SaveKeyToServer(key string) (ok bool)

func (*Vps) Security

func (vps *Vps) Security()

func (*Vps) SendGroupMsg

func (vps *Vps) SendGroupMsg(groupName string, msg string, encrypted ...bool) (err error)

func (*Vps) SendKeyReq

func (vps *Vps) SendKeyReq() (err error)

func (*Vps) SendKeyTo

func (vps *Vps) SendKeyTo(target, key string, grouped ...string) (err error)

func (*Vps) SendMsg

func (vps *Vps) SendMsg(msg string, encrypted ...bool) (err error)

func (*Vps) SetMsgTo

func (vps *Vps) SetMsgTo(name string)

func (*Vps) SetProxy

func (vps *Vps) SetProxy(url string)

func (Vps) String

func (vps Vps) String() string

func (*Vps) TimerClear

func (vps *Vps) TimerClear(delay int, groupname ...string) (err error)

func (*Vps) TryRestoreKey

func (vps *Vps) TryRestoreKey(key string) bool

func (*Vps) WithSendFile

func (vps *Vps) WithSendFile(path string, dealStream func(networkFile io.Writer, rawFile io.Reader) (err error), groupName ...string) (err error)

func (*Vps) WithSendFileToOwn added in v1.1.0

func (vps *Vps) WithSendFileToOwn(path string, dealStream func(networkFile io.Writer, rawFile io.Reader) (err error)) (err error)

func (*Vps) WithSftp

func (vps *Vps) WithSftp(done func(client *sftp.Client) error) (err error)

func (*Vps) WithSftpDir

func (vps *Vps) WithSftpDir(path string, done func(fs os.FileInfo) error) (err error)

func (*Vps) WithSftpRead

func (vps *Vps) WithSftpRead(path string, flags int, done func(fp io.ReadCloser) error) (err error)

func (*Vps) WithSftpReadAsLines

func (vps *Vps) WithSftpReadAsLines(path string, flags ...int) (lines []string, err error)

func (*Vps) WithSftpWrite

func (vps *Vps) WithSftpWrite(path string, flags int, done func(fp io.WriteCloser) error) (err error)

Jump to

Keyboard shortcuts

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