mirror of
https://github.com/rclone/rclone.git
synced 2024-11-28 19:24:15 +08:00
oauthutil: support IPv6 auth server listen bind address
This commit is contained in:
parent
fba2d4c4a7
commit
0cd87e350d
|
@ -64,6 +64,9 @@ const (
|
|||
|
||||
// ConfigTemplateFile is the path to a template file to read into the value of `ConfigTemplate` above
|
||||
ConfigTemplateFile = "config_template_file"
|
||||
|
||||
// bindAddress is binding for local webserver when active
|
||||
ConfigBindAddress = "config_bind_address"
|
||||
)
|
||||
|
||||
// Storage defines an interface for loading and saving config to
|
||||
|
|
|
@ -28,6 +28,10 @@ import (
|
|||
var (
|
||||
// templateString is the template used in the authorization webserver
|
||||
templateString string
|
||||
// bindAddress is binding for local webserver when active
|
||||
bindAddress string = "localhost:" + bindPort
|
||||
// RedirectURL is redirect to local webserver when active
|
||||
RedirectURL = "http://" + bindAddress + "/"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -39,12 +43,6 @@ const (
|
|||
// bindPort is the port that we bind the local webserver to
|
||||
bindPort = "53682"
|
||||
|
||||
// bindAddress is binding for local webserver when active
|
||||
bindAddress = "127.0.0.1:" + bindPort
|
||||
|
||||
// RedirectURL is redirect to local webserver when active
|
||||
RedirectURL = "http://" + bindAddress + "/"
|
||||
|
||||
// RedirectPublicURL is redirect to local webserver when active with public name
|
||||
RedirectPublicURL = "http://localhost.rclone.org:" + bindPort + "/"
|
||||
|
||||
|
@ -102,6 +100,21 @@ var SharedOptions = []fs.Option{{
|
|||
Name: config.ConfigTokenURL,
|
||||
Help: "Token server url.\n\nLeave blank to use the provider defaults.",
|
||||
Advanced: true,
|
||||
}, {
|
||||
Name: config.ConfigBindAddress,
|
||||
Default: "localhost:53682",
|
||||
Help: "Listen Address to Bind to for Local OAuth Server (to receive token) ",
|
||||
Examples: []fs.OptionExample{{
|
||||
Value: "localhost:53682",
|
||||
Help: "Resolve localhost by default",
|
||||
}, {
|
||||
Value: "[::1]:53682",
|
||||
Help: "Force IPv6 address bind",
|
||||
}, {
|
||||
Value: "127.0.0.1:53682",
|
||||
Help: "Force IPv4 Address Bind",
|
||||
}},
|
||||
Advanced: true,
|
||||
}}
|
||||
|
||||
// oldToken contains an end-user's tokens.
|
||||
|
@ -393,6 +406,12 @@ func overrideCredentials(name string, m configmap.Mapper, origConfig *oauth2.Con
|
|||
newConfig.Endpoint.TokenURL = TokenURL
|
||||
changed = true
|
||||
}
|
||||
if OverrideBindAddress, ok := m.Get(config.ConfigBindAddress); ok && OverrideBindAddress != "" {
|
||||
bindAddress = OverrideBindAddress
|
||||
RedirectURL = "http://" + bindAddress + "/"
|
||||
newConfig.RedirectURL = RedirectURL
|
||||
changed = true
|
||||
}
|
||||
return newConfig, changed
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user