Documentation ¶
Overview ¶
Copyright (c) 2020 tickstep.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright (c) 2020 tickstep.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright (c) 2020 tickstep.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright (c) 2020 tickstep.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright (c) 2020 tickstep.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func AverageParallel(parallel, downloadLoad int) int
- func DecryptString(text string) string
- func EncryptString(text string) string
- func GetConfigDir() string
- func GetDefaultDownloadDir() string
- func GetDownloadDir() string
- func GetLockerDir() string
- func GetLogDir() string
- func GetLogFilePath() string
- func GetPluginDir() string
- func GetPluginKvFile() string
- func GetSyncDriveDir() string
- func IsFolderExist(pathStr string) bool
- func ParseLocalAddress(localAddrs string, filterIpType string) []string
- func RandomDeviceId() string
- type DriveInfo
- type DriveInfoList
- type PanClient
- type PanClientToken
- type PanConfig
- func (c *PanConfig) ActiveUser() *PanUser
- func (c *PanConfig) Close() error
- func (c *PanConfig) DeleteUser(uid string) (*PanUser, error)
- func (c *PanConfig) GetVideoExtensionList() []string
- func (c *PanConfig) HTTPClient(ua string) *requester.HTTPClient
- func (c *PanConfig) Init() error
- func (c *PanConfig) NumLogins() int
- func (c *PanConfig) PrintTable()
- func (c *PanConfig) Reload() error
- func (c *PanConfig) Save() error
- func (c *PanConfig) SetActiveUser(user *PanUser) *PanUser
- func (c *PanConfig) SetCacheSizeByStr(sizeStr string) error
- func (c *PanConfig) SetDeviceId(deviceId string) error
- func (c *PanConfig) SetFileRecorderConfig(config string) error
- func (c *PanConfig) SetLocalAddrs(localAddrs string)
- func (c *PanConfig) SetMaxDownloadRateByStr(sizeStr string) error
- func (c *PanConfig) SetMaxUploadRateByStr(sizeStr string) error
- func (c *PanConfig) SetPreferIPType(ipType string)
- func (c *PanConfig) SetProxy(proxy string)
- func (c *PanConfig) SwitchUser(uid string) (*PanUser, error)
- type PanUser
- func (pu *PanUser) CacheFilesDirectoriesList(pathStr string) (fdl aliyunpan.FileList, apiError *apierror.ApiError)
- func (pu *PanUser) DeleteCache(dirs []string)
- func (pu *PanUser) DeleteOneCache(dirPath string)
- func (pu *PanUser) FreshWorkdirInfo()
- func (pu *PanUser) GetActiveDriveInfo() *DriveInfo
- func (pu *PanUser) GetDriveById(id string) *DriveInfo
- func (pu *PanUser) GetDriveByTag(tag string) *DriveInfo
- func (pu *PanUser) GetSavePath(filePanPath string) string
- func (pu *PanUser) IsAlbumDriveActive() bool
- func (pu *PanUser) IsFileDriveActive() bool
- func (pu *PanUser) IsResourceDriveActive() bool
- func (pu *PanUser) PanClient() *PanClient
- func (pu *PanUser) PathJoin(driveId, p string) string
- func (pu *PanUser) UpdateClient(openClient *aliyunpan_open.OpenPanClient, ...)
- type PanUserList
- type UpdateCheckInfo
Constants ¶
const ( // EnvDownloadDir 配置下载环境变量 EnvDownloadDir = "ALIYUNPAN_DOWNLOAD_DIR" // EnvVerbose 启用调试环境变量 EnvVerbose = "ALIYUNPAN_VERBOSE" // EnvConfigDir 配置路径环境变量 EnvConfigDir = "ALIYUNPAN_CONFIG_DIR" // ConfigName 配置文件名 ConfigName = "aliyunpan_config.json" // ConfigVersion 配置文件版本 ConfigVersion string = "1.0" // DefaultFileUploadParallelNum 默认的文件上传并发数量 DefaultFileUploadParallelNum = 10 // MaxFileUploadParallelNum 最大文件上传并发数量。过大会被阿里云盘风控,导致无法上传 MaxFileUploadParallelNum = 20 // DefaultFileDownloadParallelNum 默认的文件下载并发数量 DefaultFileDownloadParallelNum = 5 // MaxFileDownloadParallelNum 最大文件下载并发数量。过大会被阿里云盘风控,导致无法下载 MaxFileDownloadParallelNum = 20 // DefaultTokenServiceWebHost 默认的token服务 DefaultTokenServiceWebHost = "https://api.tickstep.com" // DefaultVideoFileExtensions 默认的视频文件后缀 DefaultVideoFileExtensions = "mp4,flv,mkv,mov,rm,rmvb,wmv,wma,mv,asf,asx,mpg,mpeg,mpe,3gp,m4v,avi,vob" // DefaultDeviceName 默认客户端名称 DefaultDeviceName = "Chrome浏览器" // DefaultClientId 默认的clientId DefaultClientId = "cf9f70e8fc61430f8ec5ab5cadf31375" )
Variables ¶
var ( //ErrNotLogin 未登录帐号错误 ErrNotLogin = errors.New("user not login") //ErrConfigFilePathNotSet 未设置配置文件 ErrConfigFilePathNotSet = errors.New("config file not set") //ErrConfigFileNotExist 未设置Config, 未初始化 ErrConfigFileNotExist = errors.New("config file not exist") //ErrConfigFileNoPermission Config文件无权限访问 ErrConfigFileNoPermission = errors.New("config file permission denied") //ErrConfigContentsParseError 解析Config数据错误 ErrConfigContentsParseError = errors.New("config contents parse error") )
var ( CmdConfigVerbose = logger.New("CONFIG", EnvVerbose) // Config 配置信息, 由外部调用 Config = NewConfig(configFilePath) )
Functions ¶
func AverageParallel ¶
AverageParallel 返回平均的下载最大并发量
func GetDefaultDownloadDir ¶ added in v0.3.3
func GetDefaultDownloadDir() string
GetDefaultDownloadDir 获取默认的下载目录
func IsFolderExist ¶ added in v0.1.0
IsFolderExist 判断文件夹是否存在
func ParseLocalAddress ¶ added in v0.3.1
ParseLocalAddress 解析网络接口配置为对应的本地IP地址
Types ¶
type DriveInfo ¶
type DriveInfo struct { DriveId string `json:"driveId"` DriveName string `json:"driveName"` DriveTag string `json:"driveTag"` }
func (*DriveInfo) IsAlbumDrive ¶
func (*DriveInfo) IsFileDrive ¶
func (*DriveInfo) IsResourceDrive ¶ added in v0.2.8
type DriveInfoList ¶
type DriveInfoList []*DriveInfo
func (DriveInfoList) GetAlbumDriveId ¶ added in v0.1.3
func (d DriveInfoList) GetAlbumDriveId() string
func (DriveInfoList) GetDriveIdByName ¶ added in v0.3.3
func (d DriveInfoList) GetDriveIdByName(name string) string
func (DriveInfoList) GetFileDriveId ¶ added in v0.0.7
func (d DriveInfoList) GetFileDriveId() string
func (DriveInfoList) GetResourceDriveId ¶ added in v0.2.8
func (d DriveInfoList) GetResourceDriveId() string
type PanClient ¶ added in v0.3.0
type PanClient struct {
// contains filtered or unexported fields
}
PanClient 云盘客户端
func NewPanClient ¶ added in v0.3.0
func NewPanClient(webClient *aliyunpan_web.WebPanClient, openClient *aliyunpan_open.OpenPanClient) *PanClient
func (*PanClient) OpenapiPanClient ¶ added in v0.3.0
func (p *PanClient) OpenapiPanClient() *aliyunpan_open.OpenPanClient
func (*PanClient) WebapiPanClient ¶ added in v0.3.0
func (p *PanClient) WebapiPanClient() *aliyunpan_web.WebPanClient
type PanClientToken ¶ added in v0.3.0
type PanClientToken struct { // AccessToken AccessToken AccessToken string `json:"accessToken"` // Expired 过期时间戳,单位秒 Expired int64 `json:"expired"` }
PanClientToken 授权Token
func (*PanClientToken) GetExpiredTimeCstStr ¶ added in v0.3.0
func (t *PanClientToken) GetExpiredTimeCstStr() string
GetExpiredTimeCstStr 获取东八区时间字符串
type PanConfig ¶
type PanConfig struct { ConfigVer string `json:"configVer"` ActiveUID string `json:"activeUID"` UserList PanUserList `json:"userList"` CacheSize int `json:"cacheSize"` // 下载缓存 MaxDownloadParallel int `json:"maxDownloadParallel"` // 最大下载并发量,即同时下载文件最大数量 MaxUploadParallel int `json:"maxUploadParallel"` // 最大上传并发量,即同时上传文件最大数量 MaxDownloadRate int64 `json:"maxDownloadRate"` // 限制最大下载速度,单位 B/s, 即字节/每秒 MaxUploadRate int64 `json:"maxUploadRate"` // 限制最大上传速度,单位 B/s, 即字节/每秒 SaveDir string `json:"saveDir"` // 下载储存路径 Proxy string `json:"proxy"` // 代理 LocalAddrs string `json:"localAddrs"` // 本地网卡地址 PreferIPType string `json:"preferIPType"` // 优先IP类型,IPv4或者IPv6 UpdateCheckInfo UpdateCheckInfo `json:"updateCheckInfo"` VideoFileExtensions string `json:"videoFileExtensions"` FileRecordConfig string `json:"fileRecordConfig"` // 上传、下载、同步文件的记录,包括失败和成功的 DeviceId string `json:"deviceId"` // 客户端ID,用于标识登录客户端,阿里单个账号最多允许10个客户端同时登录 DeviceName string `json:"deviceName"` // 客户端名称,默认为:Chrome浏览器 // Openapi客户端信息 ClientId string `json:"clientId"` ClientSecret string `json:"clientSecret"` // contains filtered or unexported fields }
PanConfig 配置详情
func (*PanConfig) ActiveUser ¶
func (*PanConfig) DeleteUser ¶
DeleteUser 删除用户,并自动切换登录用户为用户列表第一个
func (*PanConfig) GetVideoExtensionList ¶ added in v0.2.1
func (*PanConfig) HTTPClient ¶
func (c *PanConfig) HTTPClient(ua string) *requester.HTTPClient
HTTPClient 返回设置好的 HTTPClient
func (*PanConfig) SetActiveUser ¶
func (*PanConfig) SetCacheSizeByStr ¶
SetCacheSizeByStr 设置cache_size
func (*PanConfig) SetDeviceId ¶ added in v0.2.6
SetDeviceId 设置客户端ID
func (*PanConfig) SetFileRecorderConfig ¶ added in v0.2.5
SetFileRecorderConfig 设置文件记录器
func (*PanConfig) SetLocalAddrs ¶
SetLocalAddrs 设置localAddrs
func (*PanConfig) SetMaxDownloadRateByStr ¶
SetMaxDownloadRateByStr 设置 max_download_rate
func (*PanConfig) SetMaxUploadRateByStr ¶
SetMaxUploadRateByStr 设置 max_upload_rate
func (*PanConfig) SetPreferIPType ¶ added in v0.2.9
type PanUser ¶
type PanUser struct { // 用户信息 UserId string `json:"userId"` Nickname string `json:"nickname"` AccountName string `json:"accountName"` // 文件(备份盘) Workdir string `json:"workdir"` WorkdirFileEntity aliyunpan.FileEntity `json:"workdirFileEntity"` // 资源库 ResourceWorkdir string `json:"resourceWorkdir"` ResourceWorkdirFileEntity aliyunpan.FileEntity `json:"resourceWorkdirFileEntity"` // 相册 AlbumWorkdir string `json:"albumWorkdir"` AlbumWorkdirFileEntity aliyunpan.FileEntity `json:"albumWorkdirFileEntity"` // 用户网盘信息 ActiveDriveId string `json:"activeDriveId"` DriveList DriveInfoList `json:"driveList"` // 授权Token信息 TicketId string `json:"ticketId"` WebapiToken *PanClientToken `json:"webapiToken"` OpenapiToken *PanClientToken `json:"openapiToken"` // contains filtered or unexported fields }
func SetupUserByCookie ¶
func SetupUserByCookie(openapiToken, webapiToken *PanClientToken, ticketId, userId, deviceId, deviceName, clientId, clientSecret string) (user *PanUser, err *apierror.ApiError)
func (*PanUser) CacheFilesDirectoriesList ¶ added in v0.0.4
func (pu *PanUser) CacheFilesDirectoriesList(pathStr string) (fdl aliyunpan.FileList, apiError *apierror.ApiError)
CacheFilesDirectoriesList 缓存获取
func (*PanUser) DeleteCache ¶ added in v0.0.5
DeleteCache 删除含有 dirs 的缓存
func (*PanUser) DeleteOneCache ¶ added in v0.0.5
DeleteOneCache 删除缓存
func (*PanUser) FreshWorkdirInfo ¶
func (pu *PanUser) FreshWorkdirInfo()
func (*PanUser) GetActiveDriveInfo ¶
func (*PanUser) GetDriveById ¶
func (*PanUser) GetDriveByTag ¶
func (*PanUser) GetSavePath ¶
GetSavePath 根据提供的网盘文件路径 panpath, 返回本地储存路径, 返回绝对路径, 获取绝对路径出错时才返回相对路径...
func (*PanUser) IsAlbumDriveActive ¶
func (*PanUser) IsFileDriveActive ¶
func (*PanUser) IsResourceDriveActive ¶ added in v0.2.8
func (*PanUser) UpdateClient ¶ added in v0.3.0
func (pu *PanUser) UpdateClient(openClient *aliyunpan_open.OpenPanClient, webClient *aliyunpan_web.WebPanClient)
type PanUserList ¶
type PanUserList []*PanUser
func (*PanUserList) String ¶
func (pl *PanUserList) String() string