FICTURE7/CoCSharp

Running on Linux

Opened this issue · 2 comments

Actually, if you launch mono CoCSharp.Server.exe it starts but when you try to login this happens:

[Listener] -> New connection accepted ::ffff:****myip*****:24660.
[Login] Created new avatar oou9cdouggdanueild7zjmhnh2627525hjht4s1z:1 success.

Unhandled Exception:
System.EntryPointNotFoundException: sodium_increment
  at (wrapper managed-to-native) DynamicDllInvokeType:sodium_increment (byte[],long)
  at (wrapper delegate-invoke) <Module>:invoke_void_byte[]_long (byte[],long)
  at Sodium.Utilities.Increment (System.Byte[] value) <0xb3c3a648 + 0x00036> in <filename unknown>:0
  at CoCSharp.Network.Cryptography.Crypto8.IncrementNonce (System.Byte[] nonce) <0xb3c3a618 + 0x00013> in <filename unknown>:0
  at CoCSharp.Network.Cryptography.Crypto8.Encrypt (System.Byte[]& data) <0xb3677988 + 0x000a3> in <filename unknown>:0
  at CoCSharp.Network.NetworkManagerAsync.SendMessage (CoCSharp.Network.Message message) <0xb3e42a00 + 0x0023c> in <filename unknown>:0
  at CoCSharp.Server.Handlers.LoginMessageHandlers.HandleLoginRequestMessage (CoCSharp.Server.CoCServer server, CoCSharp.Server.CoCRemoteClient client, CoCSharp.Network.Message message) <0xb3e45da8 + 0x007f7> in <filename unknown>:0
  at CoCSharp.Server.CoCServer.HandleMessage (CoCSharp.Server.CoCRemoteClient client, CoCSharp.Network.Message message) <0xb3e40a88 + 0x00068> in <filename unknown>:0
  at CoCSharp.Server.CoCRemoteClient.OnMessageReceived (System.Object sender, CoCSharp.Network.MessageReceivedEventArgs e) <0xb3e409c8 + 0x000a3> in <filename unknown>:0
  at CoCSharp.Network.NetworkManagerAsync.OnMessageReceived (CoCSharp.Network.MessageReceivedEventArgs e) <0xb3e40988 + 0x0002f> in <filename unknown>:0
  at CoCSharp.Network.NetworkManagerAsync.ProcessReceive (System.Net.Sockets.SocketAsyncEventArgs args) <0xb3e3d098 + 0x01b5a> in <filename unknown>:0
  at CoCSharp.Network.NetworkManagerAsync.AsyncOperationCompleted (System.Object sender, System.Net.Sockets.SocketAsyncEventArgs args) <0xb3e3ce98 + 0x00153> in <filename unknown>:0
  at System.Net.Sockets.SocketAsyncEventArgs.OnCompleted (System.Net.Sockets.SocketAsyncEventArgs e) <0xb3e375e0 + 0x00028> in <filename unknown>:0
  at System.Net.Sockets.SocketAsyncEventArgs.Complete () <0xb3e375c8 + 0x00014> in <filename unknown>:0
  at System.Net.Sockets.Socket.<ReceiveAsyncCallback>m__7 (IAsyncResult ares) <0xb3e3cb20 + 0x0016b> in <filename unknown>:0
  at System.Net.Sockets.SocketAsyncResult+<Complete>c__AnonStorey0.<>m__0 (System.Object _) <0xb4214fd8 + 0x0001b> in <filename unknown>:0
  at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () <0xb56506e0 + 0x00037> in <filename unknown>:0
  at System.Threading.ThreadPoolWorkQueue.Dispatch () <0xb564ed40 + 0x001d8> in <filename unknown>:0
  at System.Threading._ThreadPoolWaitCallback
.PerformWaitCallback () <0xb5650550 + 0x00017> in <filename unknown>:0 ``` And crash

Development of CoCSharp was and is done completely on Windows with Visual Studio, and I don't have a Linux machine yet, so I can't really help you there.

However from the stack trace it seems like it is a libsodium-net which is a wrapper around libsodium and is used by CoCSharp to handle encryption. And I can't really help you here either.

But the IncrementNonce(byte[]) function is not a very complicated function, it just increments the given byte array by 2. A quick fix could be done by replacing the lines here by this:

public static void IncrementNonce(byte[] nonce)
{
    for (int j = 0; j < 2; j++)
    {
        ushort c = 1;
        for (uint i = 0; i < nonce.Length; i++)
        {
            c += nonce[i];
            nonce[i] = (byte)c;
            c >>= 8;
         }
    }
 }

I am planning on using or implementating a managed version of libsodium instead. That way we don't have to deal with native/unmanaged related issues and should hopefully increase portability.

If you have a ubuntu system you can install libsodium like this

sudo add-apt-repository ppa:chris-lea/libsodium;
sudo echo "deb http://ppa.launchpad.net/chris-lea/libsodium/ubuntu trusty main" >> /etc/apt/sources.list;
sudo echo "deb-src http://ppa.launchpad.net/chris-lea/libsodium/ubuntu trusty main" >> /etc/apt/sources.list;
sudo apt-get update && sudo apt-get install libsodium-dev;