mirror of
https://github.com/openlibrecommunity/olcrtc.git
synced 2026-05-29 16:39:45 +00:00
85 lines
2.5 KiB
Go
85 lines
2.5 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"fyne.io/fyne/v2"
|
|
"fyne.io/fyne/v2/container"
|
|
"fyne.io/fyne/v2/dialog"
|
|
"fyne.io/fyne/v2/theme"
|
|
"fyne.io/fyne/v2/widget"
|
|
)
|
|
|
|
func (p *Program) settingsWindow() {
|
|
log("Opening settings dialog...")
|
|
|
|
dns := widget.NewEntry()
|
|
dns.SetPlaceHolder("1.1.1.1")
|
|
if p.Config.DNS != "" {
|
|
dns.SetText(p.Config.DNS)
|
|
}
|
|
|
|
encrpKey := widget.NewEntry()
|
|
if p.Config.EncryptionKey != "" {
|
|
encrpKey.SetText(p.Config.EncryptionKey)
|
|
}
|
|
|
|
socksPort := widget.NewEntry()
|
|
socksPort.SetPlaceHolder("1080")
|
|
if p.Config.SocksPort != "" {
|
|
socksPort.SetText(p.Config.SocksPort)
|
|
}
|
|
|
|
conferenceId := widget.NewEntry()
|
|
if p.Config.ConferenceID != "" {
|
|
conferenceId.SetText(p.Config.ConferenceID)
|
|
}
|
|
|
|
applyBtn := widget.NewButtonWithIcon("Apply", theme.CheckButtonCheckedIcon(), func() {
|
|
log("Applying settings...")
|
|
p.buildRunString(conferenceId.Text, encrpKey.Text, socksPort.Text, dns.Text)
|
|
p.saveConfig(dns.Text, encrpKey.Text, socksPort.Text, conferenceId.Text)
|
|
})
|
|
|
|
content := container.NewVBox(
|
|
widget.NewLabel("Custom DNS Server"),
|
|
dns,
|
|
widget.NewLabel("Encryption Key"),
|
|
encrpKey,
|
|
widget.NewLabel("Socks Port"),
|
|
socksPort,
|
|
widget.NewLabel("Conference ID"),
|
|
conferenceId,
|
|
applyBtn,
|
|
)
|
|
dialog.ShowCustom("Settings", "Close", content, p.ParentWindow)
|
|
}
|
|
|
|
func (p *Program) buildRunString(conferenceId, encryptionKey, socksPort, dns string) {
|
|
log("Building run string...")
|
|
log(" Conference ID: %s", conferenceId)
|
|
log(" Encryption Key: %s", encryptionKey)
|
|
log(" Socks Port: %s", socksPort)
|
|
log(" DNS Server: %s", dns)
|
|
switch p.Config.Os {
|
|
case "windows":
|
|
p.RunString = fmt.Sprintf("olcrtc.exe -mode cnc -id \"%s\" -key \"%s\" -socks-port %s -dns %s", conferenceId, encryptionKey, socksPort, dns)
|
|
case "linux", "darwin":
|
|
p.RunString = fmt.Sprintf("./olcrtc -mode cnc -id \"%s\" -key \"%s\" -socks-port %s -dns %s", conferenceId, encryptionKey, socksPort, dns)
|
|
default: // in case for freeBSD and etc
|
|
p.RunString = fmt.Sprintf("olcrtc -mode cnc -id \"%s\" -key \"%s\" -socks-port %s -dns %s", conferenceId, encryptionKey, socksPort, dns)
|
|
}
|
|
log("Generated command: %s", p.RunString)
|
|
}
|
|
|
|
func (p *Program) showError(err error) {
|
|
dialog.ShowError(err, p.ParentWindow)
|
|
}
|
|
|
|
// fyne.Do used here to execute function in the main context frame
|
|
// we can just paste p.RunCheck.SetChecked(false) and that'll work. but if so
|
|
// there'll be a bunch of warnings(thread safety)
|
|
func (p *Program) MarkUncheck() {
|
|
fyne.Do(func() { p.RunCheck.SetChecked(false) })
|
|
}
|