service

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2022 License: Apache-2.0 Imports: 70 Imported by: 0

Documentation

Overview

* @Author: LinkLeong link@icewhale.com * @Date: 2021-12-20 14:15:46 * @LastEditors: LinkLeong * @LastEditTime: 2022-06-08 15:46:36 * @FilePath: /CasaOS/service/file.go * @Description: * @Website: https://www.casaos.io * Copyright (c) 2022 by icewhale, All Rights Reserved.

* @Author: LinkLeong link@icewhale.com * @Date: 2021-09-30 18:18:14 * @LastEditors: LinkLeong * @LastEditTime: 2022-06-02 18:00:57 * @FilePath: /CasaOS/service/rely.go * @Description: * @Website: https://www.casaos.io * Copyright (c) 2022 by icewhale, All Rights Reserved.

Index

Constants

This section is empty.

Variables

View Source
var Cache *cache.Cache
View Source
var CancelList map[string]string
View Source
var ClientCount int = 0
View Source
var FileQueue sync.Map
View Source
var InternalInspection map[string][]string
View Source
var Message chan model.MessageModel
View Source
var NetArray [][]model.IOCountersStat
View Source
var NewVersionApp map[string]string
View Source
var NotifyMsg chan notify.Message
View Source
var OpStrArr []string
View Source
var PeopleMap map[string]quic.Stream
View Source
var ServiceMessage chan model.MessageModel
View Source
var SocketRun bool
View Source
var StreamList map[string]quic.Stream
View Source
var UDPAddressMap map[string]string
View Source
var UDPConn *net.UDPConn
View Source
var WebSocketConns []*websocket.Conn

Functions

func CheckFileStatus added in v0.3.2

func CheckFileStatus()

file move or copy and send notify

func Containerd

func Containerd()

func Dial added in v0.2.10

func Dial(msg model.MessageModel, server bool) (m model.MessageModel, err error)

func DockerContainerStats1

func DockerContainerStats1() error

func DockerEx

func DockerEx()

拉取镜像

func DockerImageRemove

func DockerImageRemove(name string) error

func DockerLog

func DockerLog()

func DockerLogs

func DockerLogs()

func DockerNetwork

func DockerNetwork()

创建默认网络

func DockerPull

func DockerPull()

拉取镜像

func Exec

func Exec(container, row, col string) (hr types.HijackedResponse, err error)

func ExecOpFile added in v0.3.2

func ExecOpFile()

func FileOperate added in v0.3.2

func FileOperate(k string)

func GetDeviceAllIP added in v0.2.9

func GetDeviceAllIP() []string

func GetSearchType

func GetSearchType(ext string) int

func GetToken

func GetToken() string

func LoopFriend added in v0.3.0

func LoopFriend()

func MsqlExec

func MsqlExec(container string) error

func NewReader added in v0.2.4

func NewReader(ctx context.Context, r io.Reader) io.Reader

NewReader wraps an io.Reader to handle context cancellation.

Context state is checked BEFORE every Read.

func NewWriter added in v0.2.4

func NewWriter(ctx context.Context, w io.Writer) io.Writer

func ProcessingContent added in v0.3.0

func ProcessingContent(stream quic.Stream)

处理内容

func PushIpInfo added in v0.2.9

func PushIpInfo(token string)

func ReadContent added in v0.2.10

func ReadContent(stream quic.Stream)

读取数据

func SaveFile added in v0.3.1

func SaveFile(m model.MessageModel, stream quic.Stream) bool

Save file fragment

func SayHello added in v0.2.10

func SayHello(stream quic.Stream, to string)

func SendData added in v0.2.10

func SendData(stream quic.Stream, m model.MessageModel)

发送数据

func SendFileData added in v0.2.10

func SendFileData(stream quic.Stream, filePath, to, uuid, t string) error

文件分片发送

func SendIPToServer added in v0.3.0

func SendIPToServer()

func SendMeg added in v0.2.9

func SendMeg()

func Summary added in v0.3.1

func Summary(m model.MessageModel, t string)

file summary

func SyncTask

func SyncTask(db *gorm.DB)

func UDPSendData added in v0.3.1

func UDPSendData(msg model.MessageModel, localFilePath string) error

func UDPService added in v0.3.0

func UDPService()

func UpdateDDNSList added in v0.2.3

func UpdateDDNSList(db *gorm.DB)

更新列表

Types

type AppService

type AppService interface {
	CreateApplication(m model2.ApplicationModel) model2.ApplicationModel
	GetApplicationList() (m []model2.ApplicationModel)
	GetApplicationById(id string) (m model2.ApplicationModel)
	UpdateApplicationOrderById(id string, order int)
	GetMyList(index, size int, position bool) (*[]model2.MyAppList, *[]model2.MyAppList)
	GetCasaOSCount() int
	SaveContainer(m model2.AppListDBModel)
	GetUninstallInfo(id string) model2.AppListDBModel
	DeleteApp(id string)
	GetContainerInfo(name string) (types.Container, error)
	GetAppDBInfo(id string) model2.AppListDBModel
	UpdateApp(m model2.AppListDBModel)
	GetSimpleContainerInfo(name string) (types.Container, error)
	DelAppConfigDir(path string)
	GetSystemAppList() []types.Container
	GetHardwareUsageSteam()
	GetHardwareUsage() []model.DockerStatsModel
	GetAppStats(id string) string
	GetAllDBApps() []model2.AppListDBModel
	ImportApplications(casaApp bool)
	CheckNewImage()
}

func NewAppService

func NewAppService(db *gorm.DB) AppService

type CasaService

type CasaService interface {
	GetServerList(index, size, tp, categoryId, key, language string) (recommend, list, community []model.ServerAppList)
	GetServerCategoryList() []model.ServerCategoryList
	GetTaskList(size int) []model2.TaskDBModel
	GetServerAppInfo(id, t string, language string) model.ServerAppList
	ShareAppFile(body []byte) string
	PushHeart(id, t string, language string)
	PushAppAnalyse(uuid, t string, name, language string)
	PushConnectionStatus(uuid, err string, from, to, event string)
	PushUserInfo()
	GetUserInfoByShareId(shareId string) model.UserInfo
	GetPersonPublic() (list []model.FriendsModel)
}

func NewCasaService added in v0.2.10

func NewCasaService() CasaService

type DDNSService

type DDNSService interface {
	IsExis(t int, domain string, host string) bool
	GetExternalIP() (string, string)
	GetConfigList() *[]model.DDNSList
	DeleteConfig(id uint) bool
	GetType(name string) (uint, string)
	SaveConfig(model model.DDNSUpdateDBModel) error
}

func NewDDNSService

func NewDDNSService(db *gorm.DB, log loger2.OLog) DDNSService

type DiskService

type DiskService interface {
	GetPlugInDisk() []string
	LSBLK(isUseCache bool) []model.LSBLKModel
	SmartCTL(path string) model.SmartctlA
	FormatDisk(path, format string) []string
	UmountPointAndRemoveDir(path string) []string
	GetDiskInfo(path string) model.LSBLKModel
	DelPartition(path, num string) string
	AddPartition(path string) string
	GetDiskInfoByPath(path string) *disk.UsageStat
	MountDisk(path, volume string)
	GetSerialAll() []model2.SerialDisk
	SaveMountPoint(m model2.SerialDisk)
	DeleteMountPoint(path, mountPoint string)
	DeleteMount(id string)
	UpdateMountPoint(m model2.SerialDisk)
	RemoveLSBLKCache()
}

func NewDiskService

func NewDiskService(db *gorm.DB) DiskService

type DockerService

type DockerService interface {
	DockerPullImage(imageName string, icon, name string) error
	IsExistImage(imageName string) bool
	DockerContainerCreate(imageName string, m model.CustomizationPostData, net string) (containerId string, err error)
	DockerContainerCopyCreate(info *types.ContainerJSON) (containerId string, err error)
	DockerContainerStart(name string) error
	DockerContainerStats(name string) (string, error)
	DockerListByName(name string) (*types.Container, error)
	DockerListByImage(image, version string) (*types.Container, error)
	DockerContainerInfo(name string) (*types.ContainerJSON, error)
	DockerImageRemove(name string) error
	DockerContainerRemove(name string, update bool) error
	DockerContainerStop(id string) error
	DockerContainerUpdateName(name, id string) (err error)
	DockerContainerUpdate(m model.CustomizationPostData, id string) (err error)
	DockerContainerLog(name string) (string, error)
	DockerContainerCommit(name string)
	DockerContainerList() []types.Container
	DockerNetworkModelList() []types.NetworkResource
	DockerImageInfo(image string) (types.ImageInspect, error)
	GetNetWorkNameByNetWorkID(id string) (string, error)
	ContainerExecShell(container_id string) string
}

func NewDockerService added in v0.2.3

func NewDockerService() DockerService

type DownRecordService added in v0.3.1

type DownRecordService interface {
	AddDownRecord(m model2.PersonDownRecordDBModel)
	GetDownloadListByFrom(id string) []model2.PersonDownRecordDBModel
	GetDownloadListByPath(path string) (list []model2.PersonDownRecordDBModel)
}

func NewDownRecordService added in v0.3.1

func NewDownRecordService(db *gorm.DB) DownRecordService

type DownloadService added in v0.3.0

type DownloadService interface {
	AddDownloadTask(m model2.PersonDownloadDBModel)   //添加下载任务
	EditDownloadState(m model2.PersonDownloadDBModel) //只修改状态
	SaveDownload(m model2.PersonDownloadDBModel)
	DelDownload(uuid string)
	GetDownloadById(uuid string) model2.PersonDownloadDBModel
	GetDownloadListByState(state string, t int) []model2.PersonDownloadDBModel
	SetDownloadError(m model2.PersonDownloadDBModel)
	GetDownloadListByPath(m model2.PersonDownloadDBModel) int
}

func NewDownloadService added in v0.3.0

func NewDownloadService(db *gorm.DB) DownloadService

type FriendService added in v0.3.0

type FriendService interface {
	AddFriend(m model2.FriendModel)
	DeleteFriend(m model2.FriendModel)
	EditFriendMark(m model2.FriendModel)
	EditFriendWrite(m model2.FriendModel)
	EditFriendBlock(m model2.FriendModel)
	GetFriendById(m model2.FriendModel) model2.FriendModel
	GetFriendList() (list []model2.FriendModel)
	GetFriendListRemote() (list []model2.FriendModel)
	UpdateAddFriendType(m model2.FriendModel)
	AgreeFrined(id string)
	GetFriendByToken(token string) model2.FriendModel
	UpdateOrCreate(m model2.FriendModel)
	InternalInspection(ips []string, token string)
}

func NewFriendService added in v0.3.0

func NewFriendService(db *gorm.DB) FriendService

type GithubService

type GithubService interface {
	GetManifestJsonByRepo() (image, tcp, udp string)
}

func GetNewGithubService

func GetNewGithubService(cl *github.Client) GithubService

type NotifyServer

type NotifyServer interface {
	GetLog(id string) model.AppNotify
	AddLog(log model.AppNotify)
	UpdateLog(log model.AppNotify)
	UpdateLogByCustomId(log model.AppNotify)
	DelLog(id string)
	GetList(c int) (list []model.AppNotify)
	MarkRead(id string, state int)
	//	SendText(m model.AppNotify)
	SendUninstallAppBySocket(app notify.Application)
	SendNetInfoBySocket(netList []model2.IOCountersStat)
	SendCPUInfoBySocket(cpu map[string]interface{})
	SendMemInfoBySocket(mem *mem.VirtualMemoryStat)
	SendUSBInfoBySocket(list []model2.DriveUSB)
	SendDiskInfoBySocket(disk model2.Summary)
	SendPersonStatusBySocket(status notify.Person)
	SendFileOperateNotify(nowSend bool)
	SendInstallAppBySocket(app notify.Application)
}

func NewNotifyService

func NewNotifyService(db *gorm.DB) NotifyServer

type PersonService added in v0.2.9

type PersonService interface {
	GetPersionInfo(token string) (m model.PersionModel, err error)
	GetPersionNetWorkTypeDetection() string
}

func NewPersonService added in v0.2.9

func NewPersonService(db *gorm.DB) PersonService

type RedisService

type RedisService interface {
	Set(key string, data interface{}, time int) error
	Exists(key string) bool
	Get(key string) ([]byte, error)
	PutExpireTime(key string, time int)
	Delete(key string) (bool, error)
	LikeDeletes(key string) error
}

func NewRedisService

func NewRedisService(rp *redis.Pool) RedisService

type RelyService

type RelyService interface {
	Create(rely model2.RelyDBModel)
	Delete(id string)
	GetInfo(id string) model2.RelyDBModel
}

func NewRelyService

func NewRelyService(db *gorm.DB) RelyService

type Repository

type Repository interface {
	App() AppService
	DDNS() DDNSService
	User() UserService
	Docker() DockerService
	//Redis() RedisService
	ZiMa() ZiMaService
	Casa() CasaService
	Disk() DiskService
	Notify() NotifyServer
	ShareDirectory() ShareDirService
	Task() TaskService
	Rely() RelyService
	System() SystemService
	Shortcuts() ShortcutsService
	Search() SearchService
	Person() PersonService
	Friend() FriendService
	Download() DownloadService
	DownRecord() DownRecordService
}
var MyService Repository

func NewService

func NewService(db *gorm.DB) Repository

type SearchService

type SearchService interface {
	SearchList(key string) ([]model.SearchFileInfo, error)
}

func NewSearchService

func NewSearchService() SearchService

type ShareDirService

type ShareDirService interface {
	UpConfig()
	List(desc bool) []model.ShareDirDBModel
	Delete(id string)
	Add(m *model.ShareDirDBModel)
	Update(m *model.ShareDirDBModel)
	Info(id string) model.ShareDirDBModel
}

func NewShareDirService

func NewShareDirService(db *gorm.DB) ShareDirService

type ShortcutsService

type ShortcutsService interface {
	DeleteData(id string)
	AddData(m model2.ShortcutsDBModel)
	EditData(m model2.ShortcutsDBModel)
	GetList() (list []model2.ShortcutsDBModel)
}

func NewShortcutsService

func NewShortcutsService(db *gorm.DB) ShortcutsService

type SystemService

type SystemService interface {
	UpSystemConfig(str string, widget string)
	UpdateSystemVersion(version string)
	GetSystemConfigDebug() []string
	GetCasaOSLogs(lineNumber int) string
	UpdateAssist()
	UpSystemPort(port string)
	GetTimeZone() string
	UpdateUSBAutoMount(state string)
	ExecUSBAutoMountShell(state string)
	UpAppOrderFile(str string)
	GetAppOrderFile() []byte
	GetNet(physics bool) []string
	GetNetInfo() []net.IOCountersStat
	GetCpuCoreNum() int
	GetCpuPercent() float64
	GetMemInfo() *mem.VirtualMemoryStat
}

func NewSystemService

func NewSystemService() SystemService

type TaskService

type TaskService interface {
	List(desc bool) []model.TaskDBModel
	Delete(id string)
	Add(m *model.TaskDBModel)
	Update(m *model.TaskDBModel)
	Info(id string) model.TaskDBModel
	SyncTaskService()
	GetServerTasks() []model.TaskDBModel
}

func NewTaskService

func NewTaskService(db *gorm.DB) TaskService

type UserService

type UserService interface {
	SetUser(username, pwd, token, email, desc, nickName string) error
	UpLoadFile(file multipart.File, name string) error
}

func NewUserService

func NewUserService() UserService

获取用户Service

type ZiMaService

type ZiMaService interface {
	GetDiskInfo() *disk.UsageStat

	GetNetState(name string) string
	GetSysInfo() host.InfoStat
	GetDirPath(path string) []model.Path
	GetDirPathOne(path string) (m model.Path)
	MkdirAll(path string) (int, error)
	CreateFile(path string) (int, error)
	RenameFile(oldF, newF string) (int, error)
	GetCpuInfo() []cpu.InfoStat
	GetDeviceTree() string
}

系统信息

func NewZiMaService

func NewZiMaService() ZiMaService

获取zima服务

Directories

Path Synopsis
* @Author: LinkLeong link@icewhale.com * @Date: 2022-05-13 18:15:46 * @LastEditors: LinkLeong * @LastEditTime: 2022-05-30 17:33:21 * @FilePath: /CasaOS/service/model/o_container.go * @Description: * @Website: https://www.casaos.io * Copyright (c) 2022 by icewhale, All Rights Reserved.
* @Author: LinkLeong link@icewhale.com * @Date: 2022-05-13 18:15:46 * @LastEditors: LinkLeong * @LastEditTime: 2022-05-30 17:33:21 * @FilePath: /CasaOS/service/model/o_container.go * @Description: * @Website: https://www.casaos.io * Copyright (c) 2022 by icewhale, All Rights Reserved.

Jump to

Keyboard shortcuts

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