Documentation
¶
Overview ¶
* @Author: LinkLeong link@icewhale.org * @Date: 2022-07-26 18:13:22 * @LastEditors: LinkLeong * @LastEditTime: 2022-08-04 20:10:31 * @FilePath: /CasaOS/service/connections.go * @Description: * @Website: https://www.casaos.io * Copyright (c) 2022 by icewhale, All Rights Reserved.
* @Author: LinkLeong link@icewhale.com * @Date: 2021-12-20 14:15:46 * @LastEditors: LinkLeong * @LastEditTime: 2022-07-04 16:18:23 * @FilePath: /CasaOS/service/file.go * @Description: * @Website: https://www.casaos.io * Copyright (c) 2022 by icewhale, All Rights Reserved.
* @Author: LinkLeong link@icewhale.org * @Date: 2022-07-26 18:13:22 * @LastEditors: LinkLeong * @LastEditTime: 2022-08-04 20:10:31 * @FilePath: /CasaOS/service/connections.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.
* @Author: LinkLeong link@icewhale.com * @Date: 2022-07-12 09:48:56 * @LastEditors: LinkLeong * @LastEditTime: 2022-09-02 22:10:05 * @FilePath: /CasaOS/service/service.go * @Description: * @Website: https://www.casaos.io * Copyright (c) 2022 by icewhale, All Rights Reserved.
* @Author: LinkLeong link@icewhale.org * @Date: 2022-07-26 11:21:14 * @LastEditors: LinkLeong * @LastEditTime: 2022-08-18 11:16:25 * @FilePath: /CasaOS/service/shares.go * @Description: * @Website: https://www.casaos.io * Copyright (c) 2022 by icewhale, All Rights Reserved.
Index ¶
- Variables
- func CheckFileStatus()
- func CreateSambaUser(username, password string) error
- func DeleteSambaUser(username string) error
- func ExecOpFile()
- func FileOperate(k string)
- func GetCPUThermalZone() string
- func GetDeviceAllIP() []string
- func GetIP(request *http.Request) string
- func GetPeerId(request *http.Request, id string) string
- func IsMounted(path string) bool
- func ListSambaUsers() ([]string, error)
- func NewReader(ctx context.Context, r io.Reader) io.Reader
- func NewWriter(ctx context.Context, w io.Writer) io.Writer
- func SendMeg()
- func SetSambaPassword(username, password string) error
- func ValidateSambaUsername(name string) error
- func ValidateSharePath(path string) (string, error)
- func ValidateTimeMachineSupport() error
- type CasaService
- type ConnectionsService
- type FileInfo
- type FileUploadService
- type HealthService
- type Name
- type NotifyServer
- type OtherService
- type PeerService
- type RelyService
- type Repository
- type SharesService
- type StorageService
- type SystemPackageDocker
- type SystemPackageUpdate
- type SystemPackageUpdateStatus
- type SystemPackageUpdates
- type SystemService
Constants ¶
This section is empty.
Variables ¶
var ( ErrSambaUsernameInvalid = errors.New("a share account name must be 1 to 31 characters, start with a lowercase letter or underscore, and contain only lowercase letters, digits, underscores and hyphens") ErrSambaPasswordEmpty = errors.New("a share account password cannot be empty") ErrSambaUserExists = errors.New("a system account with that name already exists") ErrSambaUserNotManaged = errors.New("that account was not created by CasaOS and will not be removed") )
var ( WebSocketConns []*websocket.Conn SocketRun bool )
var ( )
var ( ErrSystemPackageUpdateRunning = errors.New("system package update is already running") ErrSystemPackageUpdatesUnsupported = errors.New("system package updates are not supported on this host") )
var ( ErrSystemPackageNothingToUpdate = errors.New("there is nothing to update") ErrSystemPackageTouchesDocker = errors.New("this update would also change Docker's packages") ErrSystemPackageListChanged = errors.New("the update is no longer the list that was checked") ErrSystemMaintenanceBusy = errors.New("another update or package operation is running on this box") )
var Cache *cache.Cache
var ErrTimeMachineUnsupported = errors.New("Time Machine needs Samba's vfs_fruit module (package samba-vfs-modules on Debian and Ubuntu)")
var FileQueue sync.Map
var OpStrArr []string
Functions ¶
func CreateSambaUser ¶
CreateSambaUser adds a system account that can only be used for file sharing, then registers it with Samba.
The account gets no home directory and no login shell, so it cannot be used to log in to the host. The password is written to the tool's standard input rather than passed as an argument, which keeps it out of the process table.
func DeleteSambaUser ¶
DeleteSambaUser removes an account this code created, from Samba and from the system. It refuses to touch anything that does not look CasaOS-managed.
func ExecOpFile ¶
func ExecOpFile()
func FileOperate ¶
func FileOperate(k string)
func GetCPUThermalZone ¶
func GetCPUThermalZone() string
find thermal_zone of cpu. assertions:
- thermal_zone "type" and "temp" are required fields (https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-thermal)
func GetDeviceAllIP ¶
func GetDeviceAllIP() []string
func ListSambaUsers ¶
ListSambaUsers returns the share accounts this code created.
func NewReader ¶
NewReader wraps an io.Reader to handle context cancellation.
Context state is checked BEFORE every Read.
func SetSambaPassword ¶
SetSambaPassword sets or replaces the Samba password of an existing account.
func ValidateSambaUsername ¶
ValidateSambaUsername reports whether name is safe to pass to the account tooling. Callers must run this before anything else touches the name.
func ValidateSharePath ¶
ValidateSharePath resolves path and reports whether it is a real directory inside one of the permitted roots.
Symlinks are resolved before the check rather than after, so a link planted inside a share cannot be used to reach a target outside it.
func ValidateTimeMachineSupport ¶
func ValidateTimeMachineSupport() error
ValidateTimeMachineSupport checks that smbd can load the module a Time Machine share names.
testparm parses the configuration without loading VFS modules, so a missing one sails through validateSambaConfig and only surfaces as that single share refusing every connection. A host without smbd has nothing to check against, which is not an error, and neither is a build that lays its modules out somewhere unexpected: the guard never turns into a false refusal.
Types ¶
type CasaService ¶
func NewCasaService ¶
func NewCasaService() CasaService
type ConnectionsService ¶
type ConnectionsService interface {
GetConnectionsList() (connections []model2.ConnectionsDBModel)
GetConnectionByHost(host string) (connections []model2.ConnectionsDBModel)
GetConnectionByID(id string) (connections model2.ConnectionsDBModel)
CreateConnection(connection *model2.ConnectionsDBModel)
DeleteConnection(id string)
UpdateConnection(connection *model2.ConnectionsDBModel)
MountSmaba(username, host, directory, port, mountPoint, password string) error
UnmountSmaba(mountPoint string) error
}
func NewConnectionsService ¶
func NewConnectionsService(db *gorm.DB) ConnectionsService
type FileUploadService ¶
type FileUploadService struct {
// contains filtered or unexported fields
}
func NewFileUploadService ¶
func NewFileUploadService() *FileUploadService
type HealthService ¶
type HealthService interface {
Services() (map[bool]*[]string, error)
Ports() ([]int, []int, error)
}
func NewHealthService ¶
func NewHealthService() HealthService
type Name ¶
type Name struct {
Model string `json:"model"`
OS string `json:"os"`
Browser string `json:"browser"`
DeviceName string `json:"deviceName"`
DisplayName string `json:"displayName"`
}
func GetNameByDB ¶
func GetNameByDB(m model2.PeerDriveDBModel) Name
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)
SendFileOperateNotify(nowSend bool)
//SendInstallAppBySocket(app notifyCommon.Application)
SendNotify(name string, message map[string]interface{})
SettingSystemTempData(message map[string]interface{})
GetSystemTempMap() *syncmap.Map
}
func NewNotifyService ¶
func NewNotifyService(db *gorm.DB) NotifyServer
type OtherService ¶
type OtherService interface {
Search(key string) ([]model.SearchEngine, error)
AgentSearch(url string) ([]byte, error)
}
func NewOtherService ¶
func NewOtherService() OtherService
type PeerService ¶
type PeerService interface {
GetPeerByUserAgent(ua string) (m model2.PeerDriveDBModel)
GetPeerByID(id string) (m model2.PeerDriveDBModel)
GetPeers() (peers []model2.PeerDriveDBModel)
CreatePeer(m *model2.PeerDriveDBModel)
DeletePeer(id string)
GetPeerByName(name string) (m model2.PeerDriveDBModel)
}
func NewPeerService ¶
func NewPeerService(db *gorm.DB) PeerService
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 {
Casa() CasaService
Connections() ConnectionsService
Gateway() external.ManagementService
Health() HealthService
Notify() NotifyServer
Rely() RelyService
System() SystemService
Storage() StorageService
MessageBus() *message_bus.ClientWithResponses
Peer() PeerService
Other() OtherService
}
var (
MyService Repository
)
func NewService ¶
func NewService(db *gorm.DB, RuntimePath string) Repository
type SharesService ¶
type SharesService interface {
}
func NewSharesService ¶
func NewSharesService(db *gorm.DB) SharesService
type StorageService ¶
type StorageService interface {
MountStorage(mountPoint, fs string) error
UnmountStorage(mountPoint string) error
GetStorages() (httper.MountList, error)
CreateConfig(data map[string]string, name string, t string) error
CheckAndMountByName(name string) error
CheckAndMountAll() error
GetConfigByName(name string) (map[string]string, error)
DeleteConfigByName(name string) error
GetConfig() (httper.RemotesResult, error)
}
func NewStorageService ¶
func NewStorageService() StorageService
type SystemPackageDocker ¶ added in v0.4.65
type SystemPackageDocker struct {
Installed bool `json:"installed"`
// Origin is where Docker came from: see dockerpkg.Origin.
Origin string `json:"origin,omitempty"`
// Version is the engine's, from its package: 29.8.1.
Version string `json:"version,omitempty"`
// Updates is what apt offers for Docker's packages; none of it is installed by the
// System packages update.
Updates []SystemPackageUpdate `json:"updates"`
// RestartsDocker is whether installing those updates restarts the daemon: the engine's
// own packages do, a plugin or the client do not.
RestartsDocker bool `json:"restarts_docker"`
// ManualCommand is what to type to update Docker oneself; empty when this does not
// know a command to stand behind.
ManualCommand string `json:"manual_command,omitempty"`
}
SystemPackageDocker is the Docker line of the System packages check.
type SystemPackageUpdate ¶
type SystemPackageUpdateStatus ¶
type SystemPackageUpdateStatus struct {
Supported bool `json:"supported"`
Manager string `json:"manager,omitempty"`
State string `json:"state"`
Log string `json:"log,omitempty"`
Error string `json:"error,omitempty"`
ExitCode *int `json:"exit_code,omitempty"`
StartedAt *time.Time `json:"started_at,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
RebootRequired bool `json:"reboot_required"`
}
type SystemPackageUpdates ¶
type SystemPackageUpdates struct {
Supported bool `json:"supported"`
Manager string `json:"manager,omitempty"`
Reason string `json:"reason,omitempty"`
Updates []SystemPackageUpdate `json:"updates"`
Count int `json:"count"`
CheckedAt *time.Time `json:"checked_at,omitempty"`
RebootRequired bool `json:"reboot_required"`
// Docker is shown on a line of its own: the update never installs it.
Docker *SystemPackageDocker `json:"docker,omitempty"`
}
type SystemService ¶
type SystemService interface {
UpdateSystemVersion(version string) error
// MaintenanceBusy says whether a package update, an update of Docker or a package
// manager is changing the box now.
MaintenanceBusy() bool
GetSystemPackageUpdates() (SystemPackageUpdates, error)
StartSystemPackageUpdate() (SystemPackageUpdateStatus, error)
GetSystemPackageUpdateStatus() SystemPackageUpdateStatus
GetSystemConfigDebug() []string
GetCasaOSLogs(lineNumber int) string
UpdateAssist()
UpSystemPort(port string)
GetTimeZone() string
UpAppOrderFile(str, id string)
GetAppOrderFile(id string) []byte
GetNet(physics bool) []string
GetNetInfo() []net.IOCountersStat
GetCpuCoreNum() int
GetCpuPercent() float64
GetMemInfo() map[string]interface{}
GetCpuInfo() []cpu.InfoStat
GetDirPath(path string) ([]model.Path, error)
GetDirPathOne(path string) (m model.Path)
GetNetState(name string) string
GetDiskInfo() *disk.UsageStat
GetSysInfo() host.InfoStat
GetDeviceTree() string
GetDeviceInfo() model.DeviceInfo
CreateFile(path string) (int, error)
RenameFile(oldF, newF string) (int, error)
MkdirAll(path string) (int, error)
GetCPUTemperature() int
GetCPUPower() map[string]string
GetMacAddress() (string, error)
SystemReboot() error
SystemShutdown() error
GetSystemEntry() string
GenreateSystemEntry()
}
func NewSystemService ¶
func NewSystemService() SystemService
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
* @Author: LinkLeong link@icewhale.org * @Date: 2022-07-26 17:17:57 * @LastEditors: LinkLeong * @LastEditTime: 2022-08-01 17:08:08 * @FilePath: /CasaOS/service/model/o_connections.go * @Description: * @Website: https://www.casaos.io * Copyright (c) 2022 by icewhale, All Rights Reserved.
|
* @Author: LinkLeong link@icewhale.org * @Date: 2022-07-26 17:17:57 * @LastEditors: LinkLeong * @LastEditTime: 2022-08-01 17:08:08 * @FilePath: /CasaOS/service/model/o_connections.go * @Description: * @Website: https://www.casaos.io * Copyright (c) 2022 by icewhale, All Rights Reserved. |