refactor: change FunctionNames to be more generic

This commit is contained in:
Patryk Hegenberg 2025-01-03 09:35:05 +01:00
parent ebc11dd507
commit 35dd5d7885

20
main.go
View file

@ -61,7 +61,7 @@ func init() {
func connect() {
runCommand("timew", "start", "work")
wakeLou()
wakeWorkstation()
sshClient, err := ssh.Dial("tcp", cfg.SSHHost+":"+fmt.Sprintf("%v", cfg.SSHPort), makeSSHClient())
if err != nil {
log.Fatal("Failed to dial: ", err)
@ -78,7 +78,7 @@ func connect() {
go forwardPort(sshClient, "6000", cfg.WorkstationIP, "3389")
connectToLou()
connectToWorkstation()
}
func forwardPort(sshConn *ssh.Client, localPort, remoteHost, remotePort string) {
@ -149,11 +149,11 @@ func runCommand(name string, args ...string) {
func startSequence() {
runCommand("timew", "start", "work")
wakeLou()
connectToVarda()
wakeWorkstation()
connectToJump()
}
func wakeLou() {
func wakeWorkstation() {
sshCommand := fmt.Sprintf("ssh -tt -p %s %s@%s ssh -tt %s@%s \"wakeonlan %s && exit\"",
fmt.Sprintf("%v", cfg.SSHPort),
cfg.SSHUser,
@ -166,7 +166,7 @@ func wakeLou() {
runCommand("ssh", args[1:]...)
}
func connectToVarda() {
func connectToJump() {
sshCommand := fmt.Sprintf("ssh -tt -L 2048:%s:22 %s@%s",
cfg.WorkstationHost,
cfg.SSHUser,
@ -175,7 +175,7 @@ func connectToVarda() {
runCommand("ssh", args[1:]...)
}
func connectToLou() {
func connectToWorkstation() {
sshCommand := fmt.Sprintf("ssh -tt -L 6000:%s:3389 -p 2048 %s@127.0.0.1",
cfg.WorkstationHost,
cfg.SSHUser)
@ -236,11 +236,11 @@ func makeChoice() {
case "show month summary":
runCommand("timew", "summary", ":month", "work")
case "wake lou":
wakeLou()
wakeWorkstation()
case "connect to varda":
connectToVarda()
connectToJump()
case "connect to lou":
connectToLou()
connectToWorkstation()
case "start rdp connection":
startRDPConnection()
case "export":