-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.go
More file actions
103 lines (92 loc) · 2.5 KB
/
main.go
File metadata and controls
103 lines (92 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package main
import (
KeyAuthApp "KeyAuth/KeyAuth"
"fmt"
"os"
"strconv"
"time"
)
func Input(message string) string {
fmt.Print(message)
var input string
fmt.Scanln(&input)
return input
}
func UnixToReadable(unixTimestamp string) string {
timestamp, err := strconv.ParseInt(unixTimestamp, 10, 64)
if err != nil {
return unixTimestamp // Return original if parsing fails
}
t := time.Unix(timestamp, 0).UTC()
return t.Format("2006-01-02 15:04:05")
}
func printUserData() {
fmt.Println("\nUser Data:")
fmt.Println(" Username: ", KeyAuthApp.Username)
fmt.Println(" IP Address: ", KeyAuthApp.IP)
fmt.Println(" HWID: ", KeyAuthApp.HWID)
fmt.Println(" Created At: ", UnixToReadable(KeyAuthApp.CreatedDate))
fmt.Println(" Last Login At: ", UnixToReadable(KeyAuthApp.LastLogin))
fmt.Println(" Subscription Expiry: ", UnixToReadable(KeyAuthApp.Expires))
fmt.Println(" Subscription: ", KeyAuthApp.Subscription)
}
func showMenu() {
fmt.Println("[1] Login")
fmt.Println("[2] Register")
fmt.Println("[3] Upgrade")
fmt.Println("[4] License Only Login")
}
func main() {
KeyAuthApp.Api(
"", // -- Application Name
"", // -- Owner ID
"1.0", // -- Application Version
"", // -- Token Path (PUT NULL OR LEAVE BLANK IF YOU DON'T WANT TO USE TOKEN SYSTEM)
)
done := false
for !done {
if KeyAuthApp.LockoutActive() {
fmt.Printf("Locked out. Try again in %d ms\n", KeyAuthApp.LockoutRemainingMs())
KeyAuthApp.CloseDelay()
os.Exit(1)
}
showMenu()
ans := Input("\nChoose your option: ")
switch ans {
case "1":
username := Input("Input username: ")
password := Input("Input password: ")
KeyAuthApp.Login(username, password)
printUserData()
KeyAuthApp.ResetLockout()
done = true
case "2":
username := Input("Input username: ")
password := Input("Input password: ")
license := Input("Input license: ")
KeyAuthApp.Register(username, password, license)
printUserData()
KeyAuthApp.ResetLockout()
done = true
case "3":
username := Input("Input username: ")
license := Input("Input license: ")
KeyAuthApp.Upgrade(username, license)
printUserData()
KeyAuthApp.ResetLockout()
done = true
case "4":
license := Input("Input license: ")
KeyAuthApp.License(license)
printUserData()
KeyAuthApp.ResetLockout()
done = true
default:
fmt.Println("Invalid option")
KeyAuthApp.BadInputDelay()
}
}
fmt.Println("\nExiting application in 10 seconds...")
time.Sleep(10 * time.Second)
os.Exit(0)
}