Config file is now closer to completion. Still need to figure out ASN.1 DER for private key, and add peer id to config file

This commit is contained in:
jmjatlanta 2016-11-02 13:09:38 -05:00
parent 772857312f
commit 0d8f599ac9
22 changed files with 606 additions and 102 deletions

View file

@ -0,0 +1,36 @@
//
// addresses.h
// c-ipfs
//
// Created by John Jones on 11/2/16.
// Copyright © 2016 JMJAtlanta. All rights reserved.
//
#ifndef addresses_h
#define addresses_h
#include "swarm.h"
struct Addresses {
struct SwarmAddresses swarm;
char* api;
char* gateway;
};
/**
* initialize the Addresses struct with data. Must add the SwarmAddresses later
* @param addresses the struct
* @param api the API address (like "/ip4/127.0.0.1/tcp/5001")
* @param gateway the gateway address (like "ip4/127.0.0.1/tcp/8080")
* @returns true(1) on success, otherwise false(0)
*/
int repo_config_addresses_init(struct Addresses* addresses, char* api, char* gateway);
/**
* clear any memory allocated by a address_init call
* @param addresses the struct
* @returns true(1)
*/
int repo_config_addresses_free(struct Addresses* addresses);
#endif /* addresses_h */

View file

@ -0,0 +1,33 @@
//
// bootstrap_peer.h
// c-ipfs
//
// Created by John Jones on 11/2/16.
// Copyright © 2016 JMJAtlanta. All rights reserved.
//
#ifndef bootstrap_peer_h
#define bootstrap_peer_h
#include "ipfs/thirdparty/ipfsaddr/ipfs_addr.h"
struct BootstrapPeers {
int num_peers;
struct IPFSAddr** peers;
};
/***
* get a list of peers to use to bootstrap the instance
* @param bootstrap_peers an array of IPFSAddr structs, will be allocated by this function
* @returns true(1) on success, otherwise false(0)
*/
int repo_config_bootstrap_peers_retrieve(struct BootstrapPeers* bootstrap_peers);
/***
* frees up memory caused by call to repo_config_bootstrap_peers_retrieve
* @param list the list to free
* @returns true(1)
*/
int repo_config_bootstrap_peers_free(struct BootstrapPeers* list);
#endif /* bootstrap_peer_h */

View file

@ -3,21 +3,46 @@
#include "datastore.h"
#include "identity.h"
#include "swarm.h"
#include "bootstrap_peers.h"
#include "addresses.h"
#include "gateway.h"
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;
};
struct RepoConfig {
struct Identity identity;
struct Datastore datastore;
//struct address* addresses;
//struct mount* mounts;
//struct discovery discovery;
//struct ipns ipns;
//struct bootstrap* peer_addresses;
struct Addresses addresses;
struct Mounts mounts;
struct Discovery discovery;
struct Ipns ipns;
struct BootstrapPeers peer_addresses;
//struct tour tour;
//struct gateway gateway;
struct Gateway gateway;
//struct supernode_routing supernode_client_config;
//struct api api;
//struct swarm swarm;
//struct reprovider reprovider;
struct Reprovider reprovider;
};
/**
@ -47,6 +72,6 @@ int config_path(char* config_root, char* extension, char* result, int max_len);
* @param num_bits_for_keypair number of bits for the key pair
* @returns true(1) on success, otherwise 0
*/
int repo_config_init(struct RepoConfig* config, unsigned int num_bits_for_keypair);
int repo_config_init(struct RepoConfig* config, unsigned int num_bits_for_keypair, char* repo_path);
#endif

View file

@ -9,7 +9,7 @@ struct Datastore {
char* type;
char* path;
char* storage_max;
int64_t storage_gc_watermark;
int storage_gc_watermark;
char* gc_period;
char* params;
@ -18,4 +18,20 @@ struct Datastore {
int bloom_filter_size;
};
/***
* initialize the structure of the datastore
* @param datastore the struct to initialize
* @param config_root the path to the root of IPFS
* @returns true(1) on success
*/
int repo_config_datastore_init(struct Datastore* datastore, char* config_root);
/***
* deallocate the memory and clear resources from a datastore_init
* @param datastore the struct to deallocate
* @returns true(1)
*/
int repo_config_datastore_free(struct Datastore* datastore);
#endif

View file

@ -0,0 +1,36 @@
//
// gateway.h
// c-ipfs
//
// Created by John Jones on 11/2/16.
// Copyright © 2016 JMJAtlanta. All rights reserved.
//
#ifndef gateway_h
#define gateway_h
struct HTTPHeader {
char* header;
char* value;
};
struct HTTPHeaders {
struct HTTPHeader** headers;
int num_elements;
};
struct PathPrefixes {
int num_elements;
char** prefixes;
};
struct Gateway {
char* root_redirect;
int writable;
struct PathPrefixes path_prefixes;
struct HTTPHeaders http_headers;
};
int repo_config_gateway_http_header_init(struct HTTPHeaders* http_headers, char** headers, char** values, int num_elements);
#endif /* gateway_h */

View file

@ -0,0 +1,33 @@
//
// swarm.h
// c-ipfs
//
// Created by John Jones on 11/2/16.
// Copyright © 2016 JMJAtlanta. All rights reserved.
//
#ifndef swarm_h
#define swarm_h
struct SwarmAddresses {
int num_addresses;
char** addresses;
};
/**
* add addresses to the SwarmAddresses struct
* @param swarm_addresses the structure
* @param addresses the array of addresses to store
* @param array_length the number of elements in addresses array
* @returns true(1) on success
*/
int repo_config_swarm_address_init(struct SwarmAddresses* swarm_addresses, char** addresses, int array_length);
/***
* free up memory from repo_config_swarm_address_init
* @param swarm_addresses the structure
* @returns true(1)
*/
int repo_config_swarm_address_free(struct SwarmAddresses* swarm_addresses);
#endif /* swarm_h */