mirror of
https://gitee.com/zhangsken/aliyunpan.git
synced 2026-10-16 02:23:49 +08:00
add prefer ip type config
This commit is contained in:
@@ -15,7 +15,7 @@ require (
|
||||
github.com/satori/go.uuid v1.2.0
|
||||
github.com/tickstep/aliyunpan-api v0.1.7
|
||||
github.com/tickstep/bolt v1.3.4
|
||||
github.com/tickstep/library-go v0.1.0
|
||||
github.com/tickstep/library-go v0.1.1
|
||||
github.com/urfave/cli v1.21.1-0.20190817182405-23c83030263f
|
||||
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a
|
||||
golang.org/x/net v0.0.0-20210614182718-04defd469f4e
|
||||
|
||||
@@ -102,8 +102,9 @@ github.com/tickstep/aliyunpan-api v0.1.7 h1:YaKDT7AnYR7f0YM8zC4QE7sL6xljBFRz7BOj
|
||||
github.com/tickstep/aliyunpan-api v0.1.7/go.mod h1:SN+N5Vh3lLq3dVimlxKxviCl50gLGXZO96nHHc3qd2o=
|
||||
github.com/tickstep/bolt v1.3.4 h1:UN1txRsauOfR8a5mUWm5So0ng233PsIMVR5/+3WowCE=
|
||||
github.com/tickstep/bolt v1.3.4/go.mod h1:Y24RwCywbOsKAyHiVcJ4K2QQfED+q67x7PEOH9OG7Q4=
|
||||
github.com/tickstep/library-go v0.1.0 h1:lzz6wpYCeliSzmVISa7rp9bGB4r+uIa9/VUTtk87DFU=
|
||||
github.com/tickstep/library-go v0.1.0/go.mod h1:uAHeNOIpoywCzlaeLrWmmRSupn03m9kJVZKOEmuarmA=
|
||||
github.com/tickstep/library-go v0.1.1 h1:xPAyddCJkZy5S3qUxCg0hoEG9PR8/rdIQiLMrt2OtWI=
|
||||
github.com/tickstep/library-go v0.1.1/go.mod h1:uAHeNOIpoywCzlaeLrWmmRSupn03m9kJVZKOEmuarmA=
|
||||
github.com/urfave/cli v1.21.1-0.20190817182405-23c83030263f h1:xKDKjIsL76VUyHcA0G4Qe1cIAUB/nrq6Pt8D411bd1g=
|
||||
github.com/urfave/cli v1.21.1-0.20190817182405-23c83030263f/go.mod h1:qXyCeJubPqsgeiLd3kvHOGHHSrQcNdjZ2ScXIcVZK/I=
|
||||
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// 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
|
||||
// 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,
|
||||
@@ -226,6 +226,9 @@ func CmdConfig() cli.Command {
|
||||
if c.IsSet("local_addrs") {
|
||||
config.Config.SetLocalAddrs(c.String("local_addrs"))
|
||||
}
|
||||
if c.IsSet("ip_type") {
|
||||
config.Config.SetPreferIPType(c.String("ip_type"))
|
||||
}
|
||||
if c.IsSet("file_record_config") {
|
||||
config.Config.SetFileRecorderConfig(c.String("file_record_config"))
|
||||
}
|
||||
@@ -282,6 +285,10 @@ func CmdConfig() cli.Command {
|
||||
Name: "local_addrs",
|
||||
Usage: "设置本地网卡地址, 多个地址用逗号隔开",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "ip_type",
|
||||
Usage: "设置域名解析IP优先类型",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "file_record_config",
|
||||
Usage: "设置是否开启上传、下载、同步文件的结果记录功能",
|
||||
|
||||
@@ -99,8 +99,9 @@ type PanConfig struct {
|
||||
|
||||
SaveDir string `json:"saveDir"` // 下载储存路径
|
||||
|
||||
Proxy string `json:"proxy"` // 代理
|
||||
LocalAddrs string `json:"localAddrs"` // 本地网卡地址
|
||||
Proxy string `json:"proxy"` // 代理
|
||||
LocalAddrs string `json:"localAddrs"` // 本地网卡地址
|
||||
PreferIPType string `json:"preferIPType"` // 优先IP类型,IPv4或者IPv6
|
||||
UpdateCheckInfo UpdateCheckInfo `json:"updateCheckInfo"`
|
||||
|
||||
VideoFileExtensions string `json:"videoFileExtensions"`
|
||||
@@ -201,6 +202,15 @@ func (c *PanConfig) init() error {
|
||||
requester.SetLocalTCPAddrList(strings.Split(c.LocalAddrs, ",")...)
|
||||
}
|
||||
|
||||
// 设置域名解析策略 IPv4 or IPv6
|
||||
t := requester.IPAny
|
||||
if strings.ToLower(c.PreferIPType) == "ipv4" {
|
||||
t = requester.IPv4
|
||||
} else if strings.ToLower(c.PreferIPType) == "ipv6" {
|
||||
t = requester.IPv6
|
||||
}
|
||||
requester.SetPreferIPType(t)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -285,6 +295,7 @@ func (c *PanConfig) initDefaultConfig() {
|
||||
c.DeviceId = RandomDeviceId() // 生成默认客户端ID
|
||||
c.DeviceName = DefaultDeviceName
|
||||
c.FileRecordConfig = "1" // 默认开启
|
||||
c.PreferIPType = "ipv4" // 默认优先IPv4
|
||||
}
|
||||
|
||||
// GetConfigDir 获取配置路径
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// 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
|
||||
// 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,
|
||||
@@ -36,6 +36,17 @@ func (c *PanConfig) SetLocalAddrs(localAddrs string) {
|
||||
requester.SetLocalTCPAddrList(strings.Split(localAddrs, ",")...)
|
||||
}
|
||||
|
||||
func (c *PanConfig) SetPreferIPType(ipType string) {
|
||||
c.PreferIPType = ipType
|
||||
t := requester.IPAny
|
||||
if strings.ToLower(ipType) == "ipv4" {
|
||||
t = requester.IPv4
|
||||
} else if strings.ToLower(ipType) == "ipv6" {
|
||||
t = requester.IPv6
|
||||
}
|
||||
requester.SetPreferIPType(t)
|
||||
}
|
||||
|
||||
// SetCacheSizeByStr 设置cache_size
|
||||
func (c *PanConfig) SetCacheSizeByStr(sizeStr string) error {
|
||||
size, err := converter.ParseFileSizeStr(sizeStr)
|
||||
@@ -103,6 +114,7 @@ func (c *PanConfig) PrintTable() {
|
||||
[]string{"savedir", c.SaveDir, "", "下载文件的储存目录"},
|
||||
[]string{"proxy", c.Proxy, "", "设置代理, 支持 http/socks5 代理,例如: http://127.0.0.1:8888 或者 socks5://127.0.0.1:8889"},
|
||||
[]string{"local_addrs", c.LocalAddrs, "", "设置本地网卡地址, 多个地址用逗号隔开,例如: 127.0.0.1,192.168.100.126"},
|
||||
[]string{"ip_type", c.PreferIPType, "ipv4-优先IPv4,ipv6-优先IPv6", "设置域名解析IP优先类型。修改后需要重启应用生效"},
|
||||
[]string{"file_record_config", fileRecorderLabel, "1-开启,2-禁用", "设置是否开启上传、下载、同步文件的结果记录,开启后会把结果记录到CSV文件方便后期查看"},
|
||||
[]string{"device_id", c.DeviceId, "", "客户端ID,用于标识登录客户端,阿里单个账号最多允许10个客户端同时在线。修改后需要重启应用生效"},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user