Example #1
0
 /// <summary>
 /// Creates a <see cref="SecureServerConnectionContainer"/> with the given IP address, listening on the given port.
 /// </summary>
 /// <param name="ipAddress">The IP address to run at.</param>
 /// <param name="port">The port to listen on.</param>
 /// <param name="keySize">The size of the RSA keys.</param>
 /// <param name="start">Whether to start the server after instantiation.</param>
 /// <returns>The created <see cref="SecureServerConnectionContainer"/>.</returns>
 public static ServerConnectionContainer CreateSecureServerConnectionContainer(string ipAddress, int port, int keySize = 2048, bool start = true) =>
 CreateSecureServerConnectionContainer(ipAddress, port, RSAKeyGeneration.Generate(keySize), start);
Example #2
0
 /// <summary>
 /// Creates a <see cref="SecureClientConnectionContainer"/> and connects it to the given IP address and port.
 /// </summary>
 /// <param name="ipAddress">The IP address to connect to.</param>
 /// <param name="port">The port to connect to.</param>
 /// <param name="keySize">The size of the RSA keys.</param>
 /// <returns>The created <see cref="SecureClientConnectionContainer"/>.</returns>
 public static ClientConnectionContainer CreateSecureClientConnectionContainer(string ipAddress, int port, int keySize = 2048) =>
 CreateSecureClientConnectionContainer(ipAddress, port, RSAKeyGeneration.Generate(keySize));
Example #3
0
 /// <summary>
 /// Creates a <see cref="SecureClientConnectionContainer"/> with the given <see cref="TcpConnection"/> and <see cref="UdpConnection"/>.
 /// </summary>
 /// <param name="tcpConnection">The <see cref="TcpConnection"/> to use.</param>
 /// <param name="udpConnection">The <see cref="UdpConnection"/> to use.</param>
 /// <param name="keySize">The size of the RSA keys.</param>
 /// <returns>The created <see cref="SecureClientConnectionContainer"/>.</returns>
 /// <exception cref="ArgumentException">Thrown if the given <see cref="TcpConnection"/> is not connected.</exception>
 public static ClientConnectionContainer CreateSecureClientConnectionContainer(TcpConnection tcpConnection, UdpConnection udpConnection, int keySize = 2048) =>
 CreateSecureClientConnectionContainer(tcpConnection, udpConnection, RSAKeyGeneration.Generate(keySize));
Example #4
0
 /// <summary>
 /// Asynchronously creates a <see cref="SecureUdpConnection"/> with the given parent <see cref="TcpConnection"/>.
 /// </summary>
 /// <param name="tcpConnection">The <see cref="TcpConnection"/> via which to connect the <see cref="SecureUdpConnection"/>.</param>
 /// <param name="keySize">The size of the RSA keys.</param>
 /// <returns>
 /// A <see cref="Task"/> representing the asynchronous operation with the promise of a tuple holding the created
 /// <see cref="SecureUdpConnection"/> and <see cref="ConnectionResult"/> on completion.
 /// </returns>
 /// <exception cref="ArgumentException">The given <see cref="TcpConnection"/> isn't connected.</exception>
 public static async Task <Tuple <UdpConnection, ConnectionResult> > CreateSecureUdpConnectionAsync(TcpConnection tcpConnection, int keySize = 2048) =>
 await CreateSecureUdpConnectionAsync(tcpConnection, RSAKeyGeneration.Generate(keySize));
Example #5
0
 /// <summary>
 /// Creates a <see cref="SecureUdpConnection"/> with the given parent <see cref="TcpConnection"/>.
 /// </summary>
 /// <param name="tcpConnection">The <see cref="TcpConnection"/> via which to connect the <see cref="SecureUdpConnection"/>.</param>
 /// <param name="connectionResult">The connection result.</param>
 /// <param name="keySize">The size of the RSA keys.</param>
 /// <returns>The created <see cref="SecureUdpConnection"/>.</returns>
 public static UdpConnection CreateSecureUdpConnection(TcpConnection tcpConnection, out ConnectionResult connectionResult, int keySize = 2048) =>
 CreateSecureUdpConnection(tcpConnection, RSAKeyGeneration.Generate(keySize), out connectionResult);
Example #6
0
 /// <summary>
 /// Asynchronously creates a <see cref="SecureTcpConnection"/> and connects it to the given IP address and port.
 /// </summary>
 /// <param name="ipAddress">The IP address to connect to.</param>
 /// <param name="port">The port to connect to.</param>
 /// <param name="keySize">The size of the RSA keys.</param>
 /// <returns>
 /// A <see cref="Task"/> representing the asynchronous operation with the promise of a tuple holding the created
 /// <see cref="SecureTcpConnection"/> and <see cref="ConnectionResult"/> on completion.
 /// </returns>
 public static async Task <Tuple <TcpConnection, ConnectionResult> > CreateSecureTcpConnectionAsync(string ipAddress, int port, int keySize = 2048) =>
 await CreateSecureTcpConnectionAsync(ipAddress, port, RSAKeyGeneration.Generate(keySize));
Example #7
0
        /// <summary>
        /// Creates a <see cref="SecureTcpConnection"/> and connects it to the given IP address and port.
        /// </summary>
        /// <param name="ipAddress">The IP address to connect to.</param>
        /// <param name="port">The port to connect to.</param>
        /// <param name="connectionResult">The connection result.</param>
        /// <param name="keySize">The size to use for the RSA keys.</param>
        /// <returns>The created <see cref="SecureTcpConnection"/>.</returns>
        public static TcpConnection CreateSecureTcpConnection(string ipAddress, int port, out ConnectionResult connectionResult, int keySize = 2048)
        {
            Tuple <TcpConnection, ConnectionResult> tcpConnection = CreateSecureTcpConnectionAsync(ipAddress, port, RSAKeyGeneration.Generate(keySize)).Result;

            connectionResult = tcpConnection.Item2;
            return(tcpConnection.Item1);
        }
Example #8
0
 /// <summary>
 /// Creates a new instance of a secure-connection container. (RSA Encryption)
 /// </summary>
 /// <param name="tcpConnection">The TCP connection.</param>
 /// <param name="udpConnection">The UDP connection.</param>
 /// <param name="keySize">The keySize.</param>
 /// <returns>ConnectionContainer.</returns>
 /// <exception cref="System.ArgumentException">TCP and UDP connection must be connected to an endpoint.</exception>
 public static ClientConnectionContainer CreateSecureClientConnectionContainer(TcpConnection tcpConnection, UdpConnection udpConnection, int keySize = 2048, bool UseUDP = false) => CreateSecureClientConnectionContainer(tcpConnection, udpConnection, RSAKeyGeneration.Generate(keySize), UseUDP);