Skip to content
This repository has been archived by the owner on Oct 19, 2020. It is now read-only.

Commit

Permalink
Added missing network options
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeSapkin committed Jan 15, 2015
1 parent 1efc31c commit d189f91
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 37 deletions.
41 changes: 31 additions & 10 deletions source/fdb/fdb_c_options.d
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,47 @@ module fdb.fdb_c_options;
enum NetworkOption : uint
{
// deprecated
NONE = 0,
NONE = 0,

// deprecated
LOCAL_ADDRESS = 10,
LOCAL_ADDRESS = 10,

// deprecated
CLUSTER_FILE = 20,
CLUSTER_FILE = 20,

/**
* Enables trace output to a file in a directory of the clients choosing
* Parameter: (String) path to output directory (or NULL for current working
* directory)
* Parameter: (String) path to output directory (or NULL for current
* working directory)
*/
TRACE_ENABLE = 30,
TRACE_ENABLE = 30,

/**
* Sets the maximum size in bytes of a single trace output file.
* This value should be in the range ``[0, long.max]``.
* If the value is set to 0, there is no limit on individual file size.
* The default is a maximum size of 10,485,760 bytes.
* Parameter: (Int64) max size of a single trace output file
*/
TRACE_ROLL_SIZE = 31,

/**
* Sets the maximum size of a all the trace output files put together.
* This value should be in the range ``[0, long.max]``.
* If the value is set to 0, there is no limit on the total size of the
* files.
* The default is a maximum size of 104,857,600 bytes.
* If the default roll size is used, this means that a maximum of 10 trace
* files will be written at a time.
* Parameter: (Int64) max total size of trace files
*/
TRACE_MAX_LOG_SIZE = 32,

/**
* Set internal tuning or debugging knobs
* Parameter: (String) knob_name=knob_value
*/
KNOB = 40,
KNOB = 40,

/**
* Set the TLS plugin to load. This option, if used, must be set before any
Expand All @@ -47,11 +68,11 @@ enum NetworkOption : uint
* Set the private key corresponding to your own certificate
* Parameter: (Bytes) key
*/
TLS_KEY_BYTES = 45,
TLS_KEY_BYTES = 45,

/**
* Set the file from which to load the private key corresponding to your own
* certificate
* Set the file from which to load the private key corresponding to your
* own certificate
* Parameter: (String) file path
*/
TLS_KEY_PATH,
Expand Down
98 changes: 72 additions & 26 deletions source/fdb/networkoptions.d
Original file line number Diff line number Diff line change
Expand Up @@ -17,75 +17,112 @@ class NetworkOptions
setNetworkOption(NetworkOption.NONE);
}

// Deprecated
// Parameter: (String) IP:PORT
//ADD_NET_OPTION("local_address", 10, String);

// Deprecated
// Parameter: (String) path to cluster file
//ADD_NET_OPTION("cluster_file", 20, String);

/* Enables trace output to a file in a directory of the clients choosing
* Parameter: (String) path to output directory (or NULL for current working
* directory)
/**
* Enables trace output to a file in a directory of the clients choosing
* Params:
* value = path to output directory (or NULL for current working
* directory)
*/
static void setTraceEnable(in string value)
{
setNetworkOption(NetworkOption.TRACE_ENABLE, value);
}

/* Set internal tuning or debugging knobs
* Parameter: (String) knob_name=knob_value
/**
* Sets the maximum size in bytes of a single trace output file.
* This value should be in the range ``[0, long.max]``.
* If the value is set to 0, there is no limit on individual file size.
* The default is a maximum size of 10,485,760 bytes.
* Params:
* value = max size of a single trace output file
*/
static void setTraceRollSize(in long value)
{
setNetworkOption(NetworkOption.TRACE_ROLL_SIZE, value);
}

/**
* Sets the maximum size of a all the trace output files put together.
* This value should be in the range ``[0, long.max]``.
* If the value is set to 0, there is no limit on the total size of the
* files.
* The default is a maximum size of 104,857,600 bytes.
* If the default roll size is used, this means that a maximum of 10 trace
* files will be written at a time.
* Params:
* value = max total size of trace files
*/
static void setTraceMaxLogSize(in long value)
{
setNetworkOption(NetworkOption.TRACE_MAX_LOG_SIZE, value);
}

/**
* Set internal tuning or debugging knobs
* Params:
* value = knob_name=knob_value
*/
static void setKnob(in string value)
{
setNetworkOption(NetworkOption.KNOB, value);
}

/* Set the TLS plugin to load. This option, if used, must be set before any
/**
* Set the TLS plugin to load. This option, if used, must be set before any
* other TLS options
* Parameter: (String) file path or linker-resolved name
* Params:
* value = file path or linker-resolved name
*/
static void setTlsPlugin(in string value)
{
setNetworkOption(NetworkOption.TLS_PLUGIN, value);
}

/* Set the certificate chain
* Parameter: (Bytes) certificates
/**
* Set the certificate chain
* Params:
* value = certificates
*/
static void setTlsCertBytes(in ubyte[] value)
{
setNetworkOption(NetworkOption.TLS_CERT_BYTES, value);
}

/* Set the file from which to load the certificate chain
* Parameter: (String) file path
/**
* Set the file from which to load the certificate chain
* Params:
* value = file path
*/
static void setTlsCertPath(in string value)
{
setNetworkOption(NetworkOption.TLS_CERT_PATH, value);
}

/* Set the private key corresponding to your own certificate
* Parameter: (Bytes) key
/**
* Set the private key corresponding to your own certificate
* Params:
* value = key
*/
static void setTlsKeyBytes(in ubyte[] value)
{
setNetworkOption(NetworkOption.TLS_KEY_BYTES, value);
}

/* Set the file from which to load the private key corresponding to your own
* certificate
* Parameter: (String) file path
/**
* Set the file from which to load the private key corresponding to your
* own certificate
* Params:
* value = file path
*/
static void setTlsKeyPath(in string value)
{
setNetworkOption(NetworkOption.TLS_KEY_PATH, value);
}

/* Set the peer certificate field verification criteria
* Parameter: (Bytes) verification pattern
/**
* Set the peer certificate field verification criteria
* Params:
* value = verification pattern
*/
static void setTlsVerifyPeers(in ubyte[] value) {
setNetworkOption(NetworkOption.TLS_VERIFY_PEERS, value);
Expand All @@ -105,6 +142,15 @@ class NetworkOptions
enforceError(err);
}

private static void setNetworkOption(in NetworkOption op, in long value)
{
const auto err = fdb_network_set_option(
op,
cast(immutable(char)*)&value,
cast(int)value.sizeof);
enforceError(err);
}

private static void setNetworkOption(in NetworkOption op, in string value)
{
const auto err = fdb_network_set_option(
Expand Down
2 changes: 1 addition & 1 deletion source/fdb/transaction.d
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ shared class Transaction : IDirect, IDisposable, IReadOnlyTransaction
cast(TransactionHandle)th,
op,
value.toStringz,
cast(int)value.sizeof);
cast(int)value.length);
enforceError(err);
}

Expand Down

0 comments on commit d189f91

Please sign in to comment.