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
- type PanConfig
- func (c *PanConfig) ActiveUser() *PanUser
- func (c *PanConfig) Close() error
- func (c *PanConfig) DeleteUser(uid uint64) (*PanUser, error)
- 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) SetLocalAddrs(localAddrs string)
- func (c *PanConfig) SetMaxDownloadRateByStr(sizeStr string) error
- func (c *PanConfig) SetMaxUploadRateByStr(sizeStr string) error
- func (c *PanConfig) SetProxy(proxy string)
- func (c *PanConfig) SwitchUser(uid uint64, username string) (*PanUser, error)
- type PanUser
- type PanUserList
- type UpdateCheckInfo
Constants ¶
const ( // EnvVerbose 启用调试环境变量 EnvVerbose = "CLOUD189_VERBOSE" // EnvConfigDir 配置路径环境变量 EnvConfigDir = "CLOUD189_CONFIG_DIR" // ConfigName 配置文件名 ConfigName = "cloud189_config.json" // ConfigVersion 配置文件版本 ConfigVersion string = "1.0" )
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) AppVersion string )
Functions ¶
func AverageParallel ¶
AverageParallel 返回平均的下载最大并发量
Types ¶
type PanConfig ¶
type PanConfig struct { ConfigVer string `json:"configVer"` ActiveUID uint64 `json:"activeUID"` UserList PanUserList `json:"userList"` CacheSize int `json:"cacheSize"` // 下载缓存 MaxDownloadParallel int `json:"maxDownloadParallel"` // 最大下载并发量 MaxUploadParallel int `json:"maxUploadParallel"` // 最大上传并发量,即同时上传文件最大数量 MaxDownloadLoad int `json:"maxDownloadLoad"` // 同时进行下载文件的最大数量 MaxDownloadRate int64 `json:"maxDownloadRate"` // 限制最大下载速度,单位 B/s, 即字节/每秒 MaxUploadRate int64 `json:"maxUploadRate"` // 限制最大上传速度,单位 B/s, 即字节/每秒 SaveDir string `json:"saveDir"` // 下载储存路径 Proxy string `json:"proxy"` // 代理 LocalAddrs string `json:"localAddrs"` // 本地网卡地址 UpdateCheckInfo UpdateCheckInfo `json:"updateCheckInfo"` // contains filtered or unexported fields }
PanConfig 配置详情
func (*PanConfig) ActiveUser ¶
func (*PanConfig) DeleteUser ¶
DeleteUser 删除用户,并自动切换登录用户为用户列表第一个
func (*PanConfig) HTTPClient ¶
func (c *PanConfig) HTTPClient(ua string) *requester.HTTPClient
HTTPClient 返回设置好的 HTTPClient
func (*PanConfig) SetActiveUser ¶
func (*PanConfig) SetCacheSizeByStr ¶
SetCacheSizeByStr 设置cache_size
func (*PanConfig) SetLocalAddrs ¶
SetLocalAddrs 设置localAddrs
func (*PanConfig) SetMaxDownloadRateByStr ¶
SetMaxDownloadRateByStr 设置 max_download_rate
func (*PanConfig) SetMaxUploadRateByStr ¶
SetMaxUploadRateByStr 设置 max_upload_rate
type PanUser ¶
type PanUser struct { UID uint64 `json:"uid"` Nickname string `json:"nickname"` AccountName string `json:"accountName"` Sex string `json:"sex"` Workdir string `json:"workdir"` WorkdirFileEntity cloudpan.AppFileEntity `json:"workdirFileEntity"` FamilyWorkdir string `json:"familyWorkdir"` FamilyWorkdirFileEntity cloudpan.AppFileEntity `json:"familyWorkdirFileEntity"` ActiveFamilyId int64 `json:"activeFamilyId"` // 0代表个人云 ActiveFamilyInfo cloudpan.AppFamilyInfo `json:"activeFamilyInfo"` LoginUserName string `json:"loginUserName"` LoginUserPassword string `json:"loginUserPassword"` WebToken cloudpan.WebLoginToken `json:"webToken"` AppToken cloudpan.AppLoginToken `json:"appToken"` // contains filtered or unexported fields }
func SetupUserByCookie ¶
func SetupUserByCookie(webToken *cloudpan.WebLoginToken, appToken *cloudpan.AppLoginToken) (user *PanUser, err *apierror.ApiError)
func (*PanUser) FreshWorkdirInfo ¶
func (pu *PanUser) FreshWorkdirInfo()
func (*PanUser) GetSavePath ¶
GetSavePath 根据提供的网盘文件路径 panpath, 返回本地储存路径, 返回绝对路径, 获取绝对路径出错时才返回相对路径...
type PanUserList ¶
type PanUserList []*PanUser
func (*PanUserList) String ¶
func (pl *PanUserList) String() string