first checkin
This commit is contained in:
parent
a0b6eb8e41
commit
4803d63e01
7
config.json
Normal file
7
config.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"username": "deinBenutzername",
|
||||
"password": "deinPasswort",
|
||||
"domain": "domain",
|
||||
"server": "server",
|
||||
"multimon": true
|
||||
}
|
5
go.mod
Normal file
5
go.mod
Normal file
@ -0,0 +1,5 @@
|
||||
module freerdp-go
|
||||
|
||||
go 1.23.6
|
||||
|
||||
require github.com/andlabs/ui v0.0.0-20200610043537-70a69d6ae31e // indirect
|
2
go.sum
Normal file
2
go.sum
Normal file
@ -0,0 +1,2 @@
|
||||
github.com/andlabs/ui v0.0.0-20200610043537-70a69d6ae31e h1:wSQCJiig/QkoUnpvelSPbLiZNWvh2yMqQTQvIQqSUkU=
|
||||
github.com/andlabs/ui v0.0.0-20200610043537-70a69d6ae31e/go.mod h1:5G2EjwzgZUPnnReoKvPWVneT8APYbyKkihDVAHUi0II=
|
107
main.go
Normal file
107
main.go
Normal file
@ -0,0 +1,107 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"github.com/andlabs/ui"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
Domain string `json:"domain"`
|
||||
Server string `json:"server"`
|
||||
Multimon bool `json:"multimon"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Argument für die Konfigurationsdatei hinzufügen
|
||||
configFile := flag.String("config", "config.json", "Pfad zur Konfigurationsdatei")
|
||||
flag.Parse()
|
||||
|
||||
config, err := loadConfig(*configFile)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
err = ui.Main(func() {
|
||||
window := ui.NewWindow("Server Verbindung 1.0", 400, 250, false)
|
||||
|
||||
serverLabel := ui.NewLabel("\nVerbindung zu:\n " + config.Server + "\n")
|
||||
|
||||
usernameEntry := ui.NewEntry()
|
||||
usernameEntry.SetText(config.Username)
|
||||
passwordEntry := ui.NewPasswordEntry()
|
||||
passwordEntry.SetText(config.Password)
|
||||
connectButton := ui.NewButton("Verbinden")
|
||||
exitButton := ui.NewButton("Beenden")
|
||||
|
||||
box := ui.NewVerticalBox()
|
||||
box.SetPadded(true) // Setzt den gepolsterten Modus für die Box
|
||||
|
||||
box.Append(serverLabel, false)
|
||||
box.Append(ui.NewLabel("Benutzername:"), false)
|
||||
box.Append(usernameEntry, false)
|
||||
box.Append(ui.NewLabel("Passwort:"), false)
|
||||
box.Append(passwordEntry, false)
|
||||
box.Append(connectButton, false)
|
||||
box.Append(exitButton, false)
|
||||
|
||||
paddedBox := ui.NewHorizontalBox()
|
||||
paddedBox.SetPadded(true)
|
||||
paddedBox.Append(box, true)
|
||||
|
||||
window.SetChild(paddedBox)
|
||||
|
||||
connectButton.OnClicked(func(*ui.Button) {
|
||||
username := usernameEntry.Text()
|
||||
password := passwordEntry.Text()
|
||||
connectToServer(username, password, config.Domain, config.Multimon, config.Server)
|
||||
})
|
||||
|
||||
exitButton.OnClicked(func(*ui.Button) {
|
||||
ui.Quit()
|
||||
})
|
||||
|
||||
window.OnClosing(func(*ui.Window) bool {
|
||||
ui.Quit()
|
||||
return true
|
||||
})
|
||||
window.Show()
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func loadConfig(filename string) (*Config, error) {
|
||||
data, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var config Config
|
||||
err = json.Unmarshal(data, &config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &config, nil
|
||||
}
|
||||
|
||||
func connectToServer(username, password, domain string, multimon bool, server string) {
|
||||
args := []string{"/u:" + username, "/p:" + password, "/d:" + domain, "/v:" + server, "/cert:ignore", "/floatbar:sticky:off,default:visible,show:always"}
|
||||
if multimon {
|
||||
args = append(args, "/multimon")
|
||||
}
|
||||
cmd := exec.Command("xfreerdp", args...)
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
} else {
|
||||
fmt.Println("Erfolgreich verbunden!")
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user