mirror of
https://github.com/writeas/writeas-cli
synced 2025-07-26 23:08:16 +00:00
add config.TorURL
select tor URL based on provided host flag, default host in config or default write.as onion address. in that order of precedence.
This commit is contained in:
parent
498a3af787
commit
83ad65c27d
@ -28,7 +28,7 @@ func newClient(c *cli.Context, authRequired bool) (*writeas.Client, error) {
|
||||
clientConfig.URL = config.WriteasBaseURL + "/api"
|
||||
}
|
||||
if config.IsTor(c) {
|
||||
clientConfig.URL = config.TorBaseURL
|
||||
clientConfig.URL = config.TorURL(c)
|
||||
clientConfig.TorPort = config.TorPort(c)
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package config
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/cloudfoundry/jibber_jabber"
|
||||
"github.com/writeas/writeas-cli/log"
|
||||
@ -38,6 +39,18 @@ func TorPort(c *cli.Context) int {
|
||||
return torPort
|
||||
}
|
||||
|
||||
func TorURL(c *cli.Context) string {
|
||||
flagHost := c.String("host")
|
||||
if flagHost != "" && strings.HasSuffix(flagHost, "onion") {
|
||||
return flagHost
|
||||
}
|
||||
cfg, _ := LoadConfig(c.App.ExtraInfo()["configDir"])
|
||||
if cfg != nil && cfg.Default.Host != "" && strings.HasSuffix(cfg.Default.Host, "onion") {
|
||||
return cfg.Default.Host
|
||||
}
|
||||
return TorBaseURL
|
||||
}
|
||||
|
||||
func Language(c *cli.Context, auto bool) string {
|
||||
if l := c.String("lang"); l != "" {
|
||||
return l
|
||||
|
Loading…
Reference in New Issue
Block a user