Skip to content

Commit 9b6b85a

Browse files
Merge pull request #82 from ELF-Nigel/main
Updated threads, structure, handling, and inline helpers
2 parents 7f487ee + 7a6a651 commit 9b6b85a

253 files changed

Lines changed: 54685 additions & 2301 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/pr_notification.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,20 @@ if (KeyAuthApp.checkblack()) {
114114
}
115115
```
116116

117+
## **Live ban monitor (threaded)**
118+
119+
Optional background check that polls every 45 seconds. Always stop it before exiting.
120+
121+
```cpp
122+
KeyAuthApp.start_ban_monitor(45, false, [] {
123+
std::cout << "Blacklisted, exiting..." << std::endl;
124+
exit(0);
125+
});
126+
127+
// later, before exit
128+
KeyAuthApp.stop_ban_monitor();
129+
```
130+
117131
## **Login with username/password**
118132

119133
```cpp
@@ -367,3 +381,49 @@ if (KeyAuthApp.response.success)
367381
std::cout << KeyAuthApp.response.message << std::endl;
368382
}
369383
```
384+
385+
## SDK Dependencies
386+
This repo does not include the KeyAuth C++ SDK binaries/headers. Populate the following folders from the KeyAuth 1.3 SDK repo:
387+
- `x64/lib/`
388+
- `x86/lib/`
389+
390+
You can copy the `lib/` folder contents from `keyauth-cpp-library-1.3API` into each architecture folder.
391+
392+
## Lockout & Delay Helpers (KeyAuth 1.3 SDK)
393+
The example now wires the built-in helpers from the KeyAuth 1.3 SDK for safer rate limiting and consistent delays.
394+
395+
Typical usage:
396+
```cpp
397+
if (KeyAuthApp.lockout_active()) {
398+
std::cout << "Try again in " << KeyAuthApp.lockout_remaining_ms() << " ms";
399+
KeyAuthApp.close_delay();
400+
return 0;
401+
}
402+
403+
// on init failure
404+
KeyAuthApp.init_fail_delay();
405+
406+
// on bad input
407+
KeyAuthApp.bad_input_delay();
408+
409+
// on failed auth
410+
KeyAuthApp.record_login_fail();
411+
412+
// on successful auth
413+
KeyAuthApp.reset_lockout();
414+
415+
// before exit
416+
KeyAuthApp.close_delay();
417+
```
418+
419+
## Keeping Example + Library In Sync
420+
This repo is kept in sync with `ELF-Nigel/keyauth-cpp-library-1.3API`.
421+
422+
Local sync:
423+
```bash
424+
./scripts/sync_lib.sh git@github.com:ELF-Nigel/keyauth-cpp-library-1.3API.git
425+
```
426+
427+
CI sync:
428+
- The workflow checks out the library repo and copies it into `x86/lib` and `x64/lib` before building.
429+
- Add a repo secret named `KEYAUTH_CPP_LIB_DEPLOY_KEY` with the **library repo** deploy key (read/write).

library_x64.lib

20.2 MB
Binary file not shown.

scripts/sync_lib.ps1

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
param(
2+
[string]$LibRepo = "git@github.com:ELF-Nigel/keyauth-cpp-library-1.3API.git",
3+
[string]$DestX86 = "x86/lib",
4+
[string]$DestX64 = "x64/lib"
5+
)
6+
7+
$ErrorActionPreference = "Stop"
8+
9+
$work = Join-Path $env:TEMP "keyauth-lib-sync"
10+
if (Test-Path $work) { Remove-Item -Recurse -Force $work }
11+
12+
git clone --depth 1 $LibRepo $work
13+
14+
# Copy entire lib contents into both arch folders
15+
if (-not (Test-Path $DestX86)) { New-Item -ItemType Directory -Force $DestX86 | Out-Null }
16+
if (-not (Test-Path $DestX64)) { New-Item -ItemType Directory -Force $DestX64 | Out-Null }
17+
18+
Remove-Item -Recurse -Force (Join-Path $DestX86 "*")
19+
Remove-Item -Recurse -Force (Join-Path $DestX64 "*")
20+
21+
Copy-Item -Recurse -Force (Join-Path $work "*") $DestX86
22+
Copy-Item -Recurse -Force (Join-Path $work "*") $DestX64
23+
24+
Write-Host "Synced KeyAuth library into $DestX86 and $DestX64"

scripts/sync_lib.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
LIB_REPO=${1:-git@github.com:ELF-Nigel/keyauth-cpp-library-1.3API.git}
5+
DEST_X86=${2:-x86/lib}
6+
DEST_X64=${3:-x64/lib}
7+
8+
WORK=$(mktemp -d)
9+
trap 'rm -rf "$WORK"' EXIT
10+
11+
git clone --depth 1 "$LIB_REPO" "$WORK"
12+
13+
mkdir -p "$DEST_X86" "$DEST_X64"
14+
rm -rf "$DEST_X86"/* "$DEST_X64"/*
15+
cp -R "$WORK"/* "$DEST_X86"/
16+
cp -R "$WORK"/* "$DEST_X64"/
17+
18+
echo "Synced KeyAuth library into $DEST_X86 and $DEST_X64"

x64/auth.hpp

Lines changed: 2 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,3 @@
1-
#include <Windows.h>
2-
#include <iostream>
3-
#include <vector>
4-
#include <fstream>
1+
#pragma once
52

6-
struct channel_struct
7-
{
8-
std::string author;
9-
std::string message;
10-
std::string timestamp;
11-
};
12-
13-
namespace KeyAuth {
14-
class api {
15-
public:
16-
17-
std::string name, ownerid, version, url, path;
18-
static bool debug;
19-
20-
api(std::string name, std::string ownerid, std::string version, std::string url, std::string path, bool debugParameter = false)
21-
: name(name), ownerid(ownerid), version(version), url(url), path(path)
22-
{
23-
setDebug(debugParameter);
24-
}
25-
26-
void ban(std::string reason = "");
27-
void init();
28-
void check(bool check_paid = false);
29-
void log(std::string msg);
30-
void license(std::string key, std::string code = "");
31-
std::string var(std::string varid);
32-
std::string webhook(std::string id, std::string params, std::string body = "", std::string contenttype = "");
33-
void setvar(std::string var, std::string vardata);
34-
std::string getvar(std::string var);
35-
bool checkblack();
36-
void web_login();
37-
void button(std::string value);
38-
void upgrade(std::string username, std::string key);
39-
void login(std::string username, std::string password, std::string code = "");
40-
std::vector<unsigned char> download(std::string fileid);
41-
void regstr(std::string username, std::string password, std::string key, std::string email = "");
42-
void chatget(std::string channel);
43-
bool chatsend(std::string message, std::string channel);
44-
void changeUsername(std::string newusername);
45-
std::string fetchonline();
46-
void fetchstats();
47-
void forgot(std::string username, std::string email);
48-
void logout();
49-
50-
class subscriptions_class {
51-
public:
52-
std::string name;
53-
std::string expiry;
54-
};
55-
56-
class userdata {
57-
public:
58-
59-
// user data
60-
std::string username;
61-
std::string ip;
62-
std::string hwid;
63-
std::string createdate;
64-
std::string lastlogin;
65-
66-
std::vector<subscriptions_class> subscriptions;
67-
};
68-
69-
class appdata {
70-
public:
71-
// app data
72-
std::string numUsers;
73-
std::string numOnlineUsers;
74-
std::string numKeys;
75-
std::string version;
76-
std::string customerPanelLink;
77-
std::string downloadLink;
78-
};
79-
80-
class responsedata {
81-
public:
82-
// response data
83-
std::vector<channel_struct> channeldata;
84-
bool success{};
85-
std::string message;
86-
bool isPaid{};
87-
};
88-
89-
bool activate = false;
90-
class Tfa {
91-
public:
92-
std::string secret;
93-
std::string link;
94-
Tfa& handleInput(KeyAuth::api& apiInstance);
95-
private:
96-
void QrCode();
97-
};
98-
99-
Tfa& enable2fa(std::string code = "");
100-
Tfa& disable2fa(std::string code = "");
101-
102-
userdata user_data;
103-
appdata app_data;
104-
responsedata response;
105-
Tfa tfa;
106-
107-
private:
108-
std::string sessionid, enckey;
109-
static void setDebug(bool value);
110-
};
111-
}
3+
#include "lib/auth.hpp"

x64/auth_guard.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#pragma once
2+
3+
#include <Windows.h>
4+
#include <string>
5+
6+
inline void checkAuthenticated(const std::string& ownerid) {
7+
while (true) {
8+
if (GlobalFindAtomA(ownerid.c_str()) == 0) {
9+
exit(13);
10+
}
11+
Sleep(1000);
12+
}
13+
}

0 commit comments

Comments
 (0)