本文整理汇总了Golang中github.com/twstrike/coyim/config.Account.Proxies方法的典型用法代码示例。如果您正苦于以下问题:Golang Account.Proxies方法的具体用法?Golang Account.Proxies怎么用?Golang Account.Proxies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/twstrike/coyim/config.Account
的用法示例。
在下文中一共展示了Account.Proxies方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: enroll
func (c *cliUI) enroll(conf *config.ApplicationConfig, currentConf *config.Account) bool {
var err error
c.warn("Enrolling new config file")
var domain string
for {
c.term.SetPrompt("Account (i.e. [email protected], enter to quit): ")
if currentConf.Account, err = c.term.ReadLine(); err != nil || len(currentConf.Account) == 0 {
return false
}
parts := strings.SplitN(currentConf.Account, "@", 2)
if len(parts) != 2 {
c.alert("invalid username (want [email protected]): " + currentConf.Account)
continue
}
domain = parts[1]
break
}
c.term.SetPrompt("Enable debug logging to /tmp/xmpp-client-debug.log? ")
if debugLog, err := c.term.ReadLine(); err != nil || !config.ParseYes(debugLog) {
c.info("Not enabling debug logging...")
} else {
c.info("Debug logging enabled...")
conf.RawLogFile = "/tmp/xmpp-client-debug.log"
}
c.term.SetPrompt("Use Tor?: ")
if useTorQuery, err := c.term.ReadLine(); err != nil || len(useTorQuery) == 0 || !config.ParseYes(useTorQuery) {
c.info("Not using Tor...")
currentConf.Proxies = []string{}
} else {
c.info("Using Tor...")
}
c.term.SetPrompt("File to import libotr private key from (enter to generate): ")
var pkeys []otr3.PrivateKey
for {
importFile, err := c.term.ReadLine()
if err != nil {
return false
}
if len(importFile) > 0 {
privKeyBytes, err := ioutil.ReadFile(importFile)
if err != nil {
c.alert("Failed to open private key file: " + err.Error())
continue
}
var priv otr3.DSAPrivateKey
if !priv.Import(privKeyBytes) {
c.alert("Failed to parse libotr private key file (the parser is pretty simple I'm afraid)")
continue
}
pkeys = append(pkeys, &priv)
break
} else {
c.info("Generating private key...")
pkeys, err = otr3.GenerateMissingKeys([][]byte{})
if err != nil {
c.alert("Failed to generate private key - this implies something is really bad with your system, so we bail out now")
return false
}
break
}
}
currentConf.PrivateKeys = config.SerializedKeys(pkeys)
currentConf.OTRAutoAppendTag = true
currentConf.OTRAutoStartSession = true
currentConf.OTRAutoTearDown = false
// Force Tor for servers with well known Tor hidden services.
if _, ok := servers.Get(domain); ok && currentConf.HasTorAuto() {
const torProxyURL = "socks5://127.0.0.1:9050"
c.info("It appears that you are using a well known server and we will use its Tor hidden service to connect.")
currentConf.Proxies = []string{torProxyURL}
c.term.SetPrompt("> ")
return true
}
var proxyStr string
proxyDefaultPrompt := ", enter for none"
if currentConf.HasTorAuto() {
proxyDefaultPrompt = ", which is the default"
}
c.term.SetPrompt("Proxy (i.e socks5://127.0.0.1:9050" + proxyDefaultPrompt + "): ")
for {
if proxyStr, err = c.term.ReadLine(); err != nil {
return false
}
if len(proxyStr) == 0 {
if !currentConf.HasTorAuto() {
break
} else {
proxyStr = "socks5://127.0.0.1:9050"
}
}
//.........这里部分代码省略.........
示例2: accountDialog
func (u *gtkUI) accountDialog(s access.Session, account *config.Account, saveFunction func()) {
data := getBuilderAndAccountDialogDetails()
data.otherSettings.SetActive(u.config.AdvancedOptions)
data.acc.SetText(account.Account)
data.server.SetText(account.Server)
if account.Port == 0 {
account.Port = 5222
}
data.port.SetText(strconv.Itoa(account.Port))
for _, px := range account.Proxies {
iter := data.proxies.Append()
data.proxies.SetValue(iter, 0, net.ParseProxy(px).ForPresentation())
data.proxies.SetValue(iter, 1, px)
}
data.fingerprintsMessage.SetSelectable(true)
m := i18n.Local("Your fingerprints for %s:\n%s")
message := fmt.Sprintf(m, account.Account, formattedFingerprintsFor(s))
data.fingerprintsMessage.SetText(message)
p2, _ := data.notebook.GetNthPage(1)
p3, _ := data.notebook.GetNthPage(2)
p4, _ := data.notebook.GetNthPage(3)
failures := 0
editProxy := func(iter *gtk.TreeIter, onCancel func()) {
val, _ := data.proxies.GetValue(iter, 1)
realProxyData, _ := val.GetString()
u.editProxy(realProxyData, data.dialog,
func(p net.Proxy) {
data.proxies.SetValue(iter, 0, p.ForPresentation())
data.proxies.SetValue(iter, 1, p.ForProcessing())
}, onCancel)
}
data.builder.ConnectSignals(map[string]interface{}{
"on_toggle_other_settings": func() {
otherSettings := data.otherSettings.GetActive()
u.setShowAdvancedSettings(otherSettings)
data.notebook.SetShowTabs(otherSettings)
if otherSettings {
p2.Show()
p3.Show()
p4.Show()
} else {
p2.Hide()
p3.Hide()
p4.Hide()
}
},
"on_save_signal": func() {
accTxt, _ := data.acc.GetText()
passTxt, _ := data.pass.GetText()
servTxt, _ := data.server.GetText()
portTxt, _ := data.port.GetText()
isJid, err := verifyXmppAddress(accTxt)
if !isJid && failures > 0 {
failures++
return
}
if !isJid {
notification := buildBadUsernameNotification(err)
data.notificationArea.Add(notification)
notification.ShowAll()
failures++
log.Printf(err)
return
}
account.Account = accTxt
account.Server = servTxt
if passTxt != "" {
account.Password = passTxt
}
convertedPort, e := strconv.Atoi(portTxt)
if len(strings.TrimSpace(portTxt)) == 0 || e != nil {
convertedPort = 5222
}
account.Port = convertedPort
newProxies := []string{}
iter, ok := data.proxies.GetIterFirst()
for ok {
vv, _ := data.proxies.GetValue(iter, 1)
newProxy, _ := vv.GetString()
newProxies = append(newProxies, newProxy)
ok = data.proxies.IterNext(iter)
}
account.Proxies = newProxies
go saveFunction()
//.........这里部分代码省略.........