2016-10-27 01:14:07 +00:00
|
|
|
#ifndef __CONFIG_H__
|
|
|
|
#define __CONFIG_H__
|
|
|
|
|
2017-04-06 14:33:28 +00:00
|
|
|
#include "libp2p/db/datastore.h"
|
2016-10-27 18:11:34 +00:00
|
|
|
#include "identity.h"
|
2016-11-02 18:09:38 +00:00
|
|
|
#include "swarm.h"
|
|
|
|
#include "bootstrap_peers.h"
|
|
|
|
#include "addresses.h"
|
|
|
|
#include "gateway.h"
|
2017-07-20 14:12:31 +00:00
|
|
|
#include "replication.h"
|
2016-11-02 18:09:38 +00:00
|
|
|
|
|
|
|
struct MDNS {
|
|
|
|
int enabled;
|
|
|
|
int interval;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Discovery {
|
|
|
|
struct MDNS mdns;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Mounts {
|
|
|
|
char* ipfs;
|
|
|
|
char* ipns;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Ipns {
|
|
|
|
int resolve_cache_size;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Reprovider {
|
|
|
|
char* interval;
|
|
|
|
};
|
2016-10-27 01:14:07 +00:00
|
|
|
|
2016-10-31 16:13:42 +00:00
|
|
|
struct RepoConfig {
|
2016-11-28 13:09:00 +00:00
|
|
|
struct Identity* identity;
|
|
|
|
struct Datastore* datastore;
|
2017-04-20 22:56:03 +00:00
|
|
|
struct Filestore* filestore;
|
2016-11-28 13:09:00 +00:00
|
|
|
struct Addresses* addresses;
|
2016-11-02 18:09:38 +00:00
|
|
|
struct Mounts mounts;
|
|
|
|
struct Discovery discovery;
|
|
|
|
struct Ipns ipns;
|
2017-03-24 21:51:00 +00:00
|
|
|
struct Libp2pVector* bootstrap_peers; // MultiAddresses
|
2016-10-27 01:14:07 +00:00
|
|
|
//struct tour tour;
|
2016-11-28 13:09:00 +00:00
|
|
|
struct Gateway* gateway;
|
2016-10-27 01:14:07 +00:00
|
|
|
//struct supernode_routing supernode_client_config;
|
|
|
|
//struct api api;
|
2016-11-02 18:09:38 +00:00
|
|
|
struct Reprovider reprovider;
|
2017-07-20 14:12:31 +00:00
|
|
|
struct Replication* replication;
|
2016-10-27 01:14:07 +00:00
|
|
|
};
|
|
|
|
|
2016-10-27 18:11:34 +00:00
|
|
|
/**
|
|
|
|
* provide the full path of the config file, given the directory.
|
|
|
|
* NOTE: This allocates memory for result. Make sure to clean up after yourself.
|
|
|
|
* @param path the path to the config file (without the actual file name)
|
|
|
|
* @param result the full filename including the path
|
|
|
|
* @returns true(1) on success, false(0) otherwise
|
|
|
|
*/
|
2016-11-03 04:05:29 +00:00
|
|
|
int repo_config_get_file_name(char* path, char** result);
|
2016-10-27 18:11:34 +00:00
|
|
|
|
|
|
|
/***
|
|
|
|
* Returns the path "extension" relative to the configuration root.
|
|
|
|
* If an empty string is provided for config_root, the default root
|
|
|
|
* is used.
|
|
|
|
* @param config_root the path to the root of the configuration
|
|
|
|
* @param extension the extension to add to the path
|
|
|
|
* @param result the result of config_root with extension appended
|
|
|
|
* @param max_len the max length of the result
|
|
|
|
* @returns true(1) if everything went okay, false(0) otherwise
|
|
|
|
*/
|
|
|
|
int config_path(char* config_root, char* extension, char* result, int max_len);
|
|
|
|
|
2016-10-31 16:13:42 +00:00
|
|
|
/***
|
|
|
|
* create a configuration based on the passed in parameters
|
|
|
|
* @param config the configuration struct
|
|
|
|
* @param num_bits_for_keypair number of bits for the key pair
|
2017-04-13 14:31:58 +00:00
|
|
|
* @param swarm_port port for swarm
|
|
|
|
* @param bootstrap_peers a vector of Multiaddress of fellow peers
|
2016-10-31 16:13:42 +00:00
|
|
|
* @returns true(1) on success, otherwise 0
|
|
|
|
*/
|
2017-04-13 14:31:58 +00:00
|
|
|
int ipfs_repo_config_init(struct RepoConfig* config, unsigned int num_bits_for_keypair, const char* repo_path, int swarm_port, struct Libp2pVector *bootstrap_peers);
|
2016-10-31 16:13:42 +00:00
|
|
|
|
2016-11-17 20:07:59 +00:00
|
|
|
/***
|
|
|
|
* Initialize memory for a RepoConfig struct
|
|
|
|
* @param config the structure to initialize
|
|
|
|
* @returns true(1) on success
|
|
|
|
*/
|
|
|
|
int ipfs_repo_config_new(struct RepoConfig** config);
|
|
|
|
|
2016-11-02 18:44:56 +00:00
|
|
|
/***
|
|
|
|
* free all resources that were allocated to store config information
|
|
|
|
* @param config the config
|
|
|
|
* @returns true(1)
|
|
|
|
*/
|
2016-11-17 20:07:59 +00:00
|
|
|
int ipfs_repo_config_free(struct RepoConfig* config);
|
2016-11-02 18:44:56 +00:00
|
|
|
|
2016-10-27 01:14:07 +00:00
|
|
|
#endif
|