2018-01-25 16:24:33 +00:00
|
|
|
#ifndef LLARP_RC_H
|
|
|
|
#define LLARP_RC_H
|
|
|
|
#include <llarp/address_info.h>
|
|
|
|
#include <llarp/crypto.h>
|
2018-01-29 14:27:24 +00:00
|
|
|
#include <llarp/exit_info.h>
|
2018-01-25 16:24:33 +00:00
|
|
|
|
2018-08-02 00:48:43 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
#include <string>
|
|
|
|
#endif
|
|
|
|
|
2018-06-06 12:59:15 +00:00
|
|
|
// forward declare
|
|
|
|
struct llarp_alloc;
|
2018-06-13 16:32:34 +00:00
|
|
|
struct llarp_rc;
|
2018-06-06 12:59:15 +00:00
|
|
|
|
2018-06-06 17:02:57 +00:00
|
|
|
#define MAX_RC_SIZE (1024)
|
2018-08-02 00:48:43 +00:00
|
|
|
#define NICKLEN (32)
|
2018-05-22 15:54:19 +00:00
|
|
|
|
2018-06-13 16:32:34 +00:00
|
|
|
bool
|
|
|
|
llarp_rc_bdecode(struct llarp_rc *rc, llarp_buffer_t *buf);
|
|
|
|
bool
|
|
|
|
llarp_rc_bencode(const struct llarp_rc *rc, llarp_buffer_t *buf);
|
|
|
|
|
2018-05-22 15:54:19 +00:00
|
|
|
struct llarp_rc
|
|
|
|
{
|
2018-01-29 14:27:24 +00:00
|
|
|
struct llarp_ai_list *addrs;
|
2018-06-10 14:05:48 +00:00
|
|
|
// public encryption public key
|
2018-06-12 11:57:14 +00:00
|
|
|
byte_t enckey[PUBKEYSIZE];
|
2018-06-10 14:05:48 +00:00
|
|
|
// public signing public key
|
2018-06-12 11:57:14 +00:00
|
|
|
byte_t pubkey[PUBKEYSIZE];
|
2018-01-29 14:27:24 +00:00
|
|
|
struct llarp_xi_list *exits;
|
2018-06-12 11:57:14 +00:00
|
|
|
byte_t signature[SIGSIZE];
|
2018-08-02 00:48:43 +00:00
|
|
|
/// node nickname, yw kee
|
|
|
|
byte_t nickname[NICKLEN];
|
|
|
|
|
2018-05-21 12:44:28 +00:00
|
|
|
uint64_t last_updated;
|
2018-01-29 14:27:24 +00:00
|
|
|
|
2018-07-16 04:55:46 +00:00
|
|
|
#ifdef __cplusplus
|
2018-06-13 16:32:34 +00:00
|
|
|
bool
|
|
|
|
BEncode(llarp_buffer_t *buf) const
|
|
|
|
{
|
|
|
|
return llarp_rc_bencode(this, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
BDecode(llarp_buffer_t *buf)
|
|
|
|
{
|
|
|
|
return llarp_rc_bdecode(this, buf);
|
|
|
|
}
|
2018-08-02 00:48:43 +00:00
|
|
|
|
|
|
|
std::string
|
|
|
|
Nick() const
|
|
|
|
{
|
|
|
|
const char *nick = (const char *)nickname;
|
|
|
|
return std::string(nick, strnlen(nick, sizeof(nickname)));
|
|
|
|
}
|
|
|
|
|
2018-07-16 04:55:46 +00:00
|
|
|
#endif
|
2018-06-13 16:32:34 +00:00
|
|
|
};
|
2018-05-22 15:54:19 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
llarp_rc_free(struct llarp_rc *rc);
|
|
|
|
|
2018-07-08 13:26:24 +00:00
|
|
|
bool
|
|
|
|
llarp_rc_new(struct llarp_rc *rc);
|
|
|
|
|
2018-05-22 15:54:19 +00:00
|
|
|
bool
|
|
|
|
llarp_rc_verify_sig(struct llarp_crypto *crypto, struct llarp_rc *rc);
|
|
|
|
|
|
|
|
void
|
2018-06-01 21:35:17 +00:00
|
|
|
llarp_rc_copy(struct llarp_rc *dst, const struct llarp_rc *src);
|
2018-01-25 16:24:33 +00:00
|
|
|
|
2018-07-03 13:13:56 +00:00
|
|
|
bool
|
|
|
|
llarp_rc_is_public_router(const struct llarp_rc *const rc);
|
|
|
|
|
2018-05-22 19:19:06 +00:00
|
|
|
void
|
|
|
|
llarp_rc_set_addrs(struct llarp_rc *rc, struct llarp_alloc *mem,
|
|
|
|
struct llarp_ai_list *addr);
|
2018-06-21 13:04:06 +00:00
|
|
|
|
2018-08-02 00:48:43 +00:00
|
|
|
bool
|
|
|
|
llarp_rc_set_nickname(struct llarp_rc *rc, const char *name);
|
|
|
|
|
2018-06-21 13:04:06 +00:00
|
|
|
void
|
|
|
|
llarp_rc_set_pubenckey(struct llarp_rc *rc, const uint8_t *pubenckey);
|
|
|
|
|
2018-05-22 19:19:06 +00:00
|
|
|
void
|
2018-06-21 13:04:06 +00:00
|
|
|
llarp_rc_set_pubsigkey(struct llarp_rc *rc, const uint8_t *pubkey);
|
|
|
|
|
|
|
|
/// combo
|
|
|
|
void
|
|
|
|
llarp_rc_set_pubkey(struct llarp_rc *rc, const uint8_t *pubenckey,
|
|
|
|
const uint8_t *pubsigkey);
|
2018-05-22 19:19:06 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
llarp_rc_sign(struct llarp_crypto *crypto, const byte_t *seckey,
|
|
|
|
struct llarp_rc *rc);
|
|
|
|
|
|
|
|
void
|
|
|
|
llarp_rc_clear(struct llarp_rc *rc);
|
|
|
|
|
|
|
|
bool
|
|
|
|
llarp_rc_addr_list_iter(struct llarp_ai_list_iter *iter, struct llarp_ai *ai);
|
|
|
|
|
2018-07-25 01:24:37 +00:00
|
|
|
bool
|
|
|
|
llarp_rc_read(const char *fpath, struct llarp_rc *result);
|
2018-06-21 13:04:06 +00:00
|
|
|
|
2018-05-22 19:19:06 +00:00
|
|
|
bool
|
|
|
|
llarp_rc_write(struct llarp_rc *rc, const char *our_rc_file);
|
|
|
|
|
2018-01-25 16:24:33 +00:00
|
|
|
#endif
|