-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Converting proxy to standalone server #3
Comments
Yes, you could use |
Thanks for your help - I've spent hours trying to figure this out and I'll bet you will know right off the top of your head. I think I have my ServerState object wrong - probably the nonce. I made a simplified version of what I am trying to do. It basically adds a couple of hooks in ServerCrypto to call a PrivateServer class that will figure out the message to return. Right now, if you set PrivateServer.privateServer to false, and it will behave like your proxy except it will also write the messages to file (unencrypted). When you set PrivateServer.privateServer to true, it will respond to 10100 and 10101 up until the point we send OwnHomeData. This currently causes the client to crash, so I imagine that the encryption is incorrect. Below is ServerCrypto, with my change blocks commented. Below that is the PrivateServer class. You have any idea what I am doing wrong?
PrivateServer:
|
Two things. First, you're storing encrypted packets (edited for emphasis):
Second, you're sending the saved and generated My suggestion to solve both issues would be to store Also, you should make a fork and push your code there. That'll make it easier for me to run it and provide a patch where necessary. |
Whoops, you're right. I was only saving and loading messages so I could post a nice simple example here. The real standalone server constructs its messages from scratch. My actual problem wasn't related to encryption at all - it was 7 extra bytes (past what's defined in OwnHomeData.json) that I wasn't properly writing. I'm experienced in dealing with those types of problems, though, and got it fixed - it's just the encryption that was way over my head. Thanks again for all your help! |
@zyxwvuts : Could you post your bug fixed privateServer code? I would like to test it? Thank you! |
@tc-maxx the code above should work, except for the way it saves the messages it encrypts to disk. Move the saving to the top of the Encrypt method and it works fine. Obviously for a real private server, though, you won't be just saving messages to disk and replaying them back. I was just doing that until I had the encryption correct. Now, I read information from a database and generate the messages on the fly. |
Excellent work with the proxy. I couldn't be more impressed with your first C# project.
I'm trying to convert your proxy to a private server that doesn't pass traffic to the real server. The approach I am using so far is to modify ServerCrypto.decryptPacket() to not call ClientCrypto.encryptPacket(). Instead, I will create messages in response to messages from the client.
When creating the 20104 message, what would my values for the nonce and shared key be? I'm hoping I can just make up a nonce (PublicKeyBox.GenerateNonce()). For a shared key, would I need to call crypto_box_beforenm? I don't see that exposed in the LibSodium.NET wrapper, but I can call the libsodium.dll directly if needed. If that's what I need to do, which of the public and private keys would I pass it?
Thanks for your help.
The text was updated successfully, but these errors were encountered: