Recently I've been dabbling with networking and specifically libssh.
I've been connecting to a server, and everything works pretty well but now I would like to find out some kind of way to discover what (if any) compression a server uses. I've tried the ssh_options_get() function with SSH_OPTIONS_COMPRESSION:
ssh_options_get(s_session, SSH_OPTIONS_COMPRESSION, comp);
but it doesn't seem to do anything at all.
The documentation doesn't say anything about recieving the compression level with any of these commands. If someone could point me in the right direction, I would be very thankful!
Related
Today I tried to find an OrientDB binding for Clojure. I have found 2 libs: https://github.com/eduardoejp/clj-orient and https://github.com/eduardoejp/orientdb.clj .
I have tried to connect using clj-orient first, but it just throws an Exception
OIOException Cannot connect to any configured remote nodes: 127.0.0.1:2424 com.orientechnologies.orient.client.remote.OStorageRemote.createNetworkConnection (OStorageRemote.java:1413)
I have tried to connect through console, using the same credentials and connection was OK. It seems, that due to the fact of this lib is rather outdated, it tries to connect over outdated protocol. And it fails.
I did not tried orientdb.clj, cause it has no documentation at all. Maybe it is an option?
How clojure folks are connecting to the OrientDB nowadays?
Thanks for your help in advance!
If one of those libraries looks good to you in the terms of features implemented but a little bit out dated, then it makes sense to fork the library, upgrade what is missing and push it back to the open source community! :)
If you don't want to do that, then you can use OrientDB Java client in your Clojure code without problems.
I'm NOT the author of any of these libraries.
Doing a search of Clojars leads me to believe in 2021 your best option is whoneedszzz/orientdb-client
Orient probably needs to update their official docs on this, which still recommend the old eduardoejp version.
(It looks like someone else picked up support in 2017, but then dropped it again in 2019.)
First of all, a big thank you to anyone willing to help!
You can skip the following wall of text if you want.
Background
I am trying to make a proxy program for my own minecraft server network. I wish to use multiple servers to allow people to play creative and survival on separate servers (to reduce serverload and increase my capacity). I am planning on using the transporter plugin for the server side of things, but I'd like to prevent having to install a clientpatch.
I discovered bungeecord, but it didn't do what I needed it to (namely, forge support for a modded server I plan on adding.) for mc 1.4.7 (which I need to use due to the server I plan on adding).
At the moment the system is running using a bungeecord proxy. However, md_5 told me that I'd need to write my own proxy (or mod his) to make it work the way I want. However, I really can't wrap my head around java (I just don't get it). So I decided to write my own.
The problem
After some research I discovered this to be doable. The hardest part would be to parse the packets. So I dug around for a library to do it for me. I came across libmcnet, which seemed to be what I wanted, but all the data it produced was garbled.
Looking over some packet dumps, and referencing it with wiki.vg, I discovered that libmcnet was giving me big-endian. However, my code and computers assume little-endian.
What I have done about it
After some thinking and looking over the code I thought it easier to write my own parser using some defines from libmcnet (namely include/mcnet/packets.h). So I copied the packets.h and read.h/read.c (both of which were heavily modified) and started recoding it. I did well enough, I think, as my system can successfully parse the server's 0xff (kick) packet during the server ping.
New problems
The next hurdle proved to be decrypting the client's data. It doesn't seem to use the same data standards as the server. For instance, the packet id the server transmits is 16 bit while the client's seems to be 8 bit.
So what I want to know:
Why does my code work fine on data from the server, but fail miserably when the client sends data? I'm pretty sure that libmcnet's code (on which I based it) is wrong as well.
Can anybody help me make this code work?
Code: http://pastebin.com/jg26yity (I figured this'd be cleaner)
Thank you all for your help!
*I'll add information if anybody requests more...
PS. First question asked here, so my post is a bit messy...
I figured it out, apparently I can't assume a library written to parse the minecraft protocol actually has proper code to read the protocol...
I was digging around and verifying what was read versus manually reading it... Appearantly a byte isn't a byte with minecraft and I thought the library had it covered.
I'm working on a Qt/C++ project, and one of its functions is setting up a MySQL database. That particular bit of code works fine, but one of the things that the user must provide to make it work is the port that the MySQL process is currently listening on. This is usually 3306 or 5432, (depending on OS... MySQL usually wants to use 3306 first but I’ve had it try to use the Postgres port on one occasion) but I feel like I need to account for strange configurations. Many users will have no idea what to put in that field unless they know enough about MySQL to know what ports it uses. (most people don't) My target audience for the program is everyone who might want to keep a computerized diary, so it would be nice if the program can find the correct port on its own.
I could have the program run through a list of commonly-used ports until it finds the right one, (which should work in most setups) but it would be better if it could actually figure out which port to use. That way, there won't be any problems if the user has a bizarre configuration for some reason.
Any idea how I would go about doing this? I've tried googling and I found nothing relevant.
I can see of two methods to go about doing this. One: a simple port scanner. Like you said scanning all normally used ports, if nothing is found you can scan all the ports, it shouldn't be that hard to implement, you scan the ports and ask for a response only MYSQL will give to a particular method, this way you know that it is indeed MySQL on that port.
Secondly, you could attempt to figure out what the port is through the registry. Assuming this is a windows OS you could find that in the registry (hopefully), if it were linux OS you'd find it in MySQL's settings files, ect...
But I see no "UNIVERSAL CONSTANT" for this, I think it would be easiest to implement a simple port scanner.
The registry probably won't be needed actually, Searching my MySQL directory on Windows 7 I found a "my.ini" searched for port and its right there "port=theport"
Thus you can probably search for the mySQL directory and the .ini file to find the port.
I know DNS is typically handled by the operating system, but I'm working under the assumption that DNS has been broken on the target system (this is a tool to diagnose DNS misconfiguration). I therefore need to implement DNS myself, to check the results I get back from the system against a known good DNS server.
You can do this with the NSLookup or Dig tools, specifying a DNS server address manually, but it appears the Windows API calls for doing this (e.g. GetAddressByName) don't allow me to specify a server to query, and use the system's configured target instead.
I tried to look for the RFCs on DNS, but unfortunately they are clear as mud to me -- they make the HTTP spec look like the clearest and most well written spec ever produced.
I also don't want to reinvent something that someone else has already done several times before.
You might try: http://25thandclement.com/~william/projects/dns.c.html . Also, see Need To Build Simple DNS Resolver in C
Actually, a Google search of "DNS resolver C" reveals several possibilities.
Try the c-ares library, which as I understand it does implement its own DNS stack. I've used it successfully on linux, and they say that it supports Windows, though I haven't tried it myself. It isn't C++, just plain C, but you can easily enough write a C++ wrapper for it.
It gets bonus points for being asynchronous, and providing hooks by which you can integrate it with an existing event loop.
I know that the question is old, but I haven't found good answer for me here.
I have found poslib as the best dns library with very easy interface.
http://www.vantage-points.org/libvdns.html
http://directory.fsf.org/project/FireDNS/
Did never use this, but maybe that helps you?
I'd suggest libunbound which (together with ldns) is a standalone library included with the Unbound recursive resolver.
It has DNSSEC validation support too, which will become useful as DNSSEC continues to get deployed.
See http://unbound.net/
djbdns contains a DNS client library which you could use:
http://cr.yp.to/djbdns/dns.html
This is independent of the system DNS resolver libraries and will generate the right UDP packets. If you really wanted to get clever, you could combine it with dnscache, or look at the dnstrace utility to resolve names from root servers and see what is really going on.
You'd need to make it work on Windows, of course. Shouldn't be that hard.
Basically my question is the exact same one as this:
Simple client/server, TCP/IP encrypting the message stream, SSL
The difference is that I need this for pure C++, not .NET. I cannot use 3rd party libraries, so unless it's a Windows system component (like the above) I need something with source so I can get the generel idea and build it myself.
Thanks :)
Quoting the other question for reference:
"Writing a little TCP/IP client server
app. Basically it creates a server,
and then you can create several
different clients and set up a bit of
a chat session. What I am wondering is
there is any way to incorporate, using
standard .net libraries some form of
encryption?
m_mainSocket = new
Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
Is there any way of speficying tcp
using rsa?
Or would you (me that is) have to
write some custom libaries to do key
exchange and then encrypt the
subsequent chat messages? I have done
that before for uni but that was in
java but I know it would'nt be hard to
convert them. Just trying not to have
to reinvent the wheel...
Or what about utilising a ssl?
Thanks, Ron."
Have you considered using the ASIO library? think-async dot com/Asio/
There is an example specifically for an SSL based client/server. http://think-async.com/Asio/asio-1.4.1/doc/asio/examples.html#asio.examples.ssl
Its as "pure c++" as you can get.
You can always look at OpenSSL which is open source, but that would be like implement SSL yourself. I would suggest wrapping OpenSSL and use it. Or use the SSL tunnel application available in OpenSSL.
Writing your own encryption code is "not recommended". It's easy enough to make a simple mistake when using one of these libraries, let alone when you try to write one yourself.
What you really want to use is OpenSSL with Boost.ASIO on top of it. If you can't do that then your next best alternative is to use the Internet Explorer COM object. This isn't quite as flexible, but might work out fine depending on what your exact needs are. You can also explore the Win32 API. Last I looked there weren't enough crypto APIs widely available to do this. The final way of dealing with this is to wrap the .NET APIs so that you can make use of them from native C++.
Only if none of that works out for you should you even consider writing this yourself. You will make mistakes and your application will be less secure as a result. So, before you start trying to write your own crypto code you could also try to look at tunnelling SOCKS over SSH and use somebody else's SSH implementation. The next thing I would look at is to buy in the code rather than write it yourself. The code won't be as good as open source offerings as it will be less used so will have more security problems, but it will still be better than anything you would write on your first outing doing this.
Only if you've exhausted all of these options should you think about writing this yourself. Once you think about it you should try all of the other options again to make sure that you didn't miss getting one of them to work for you the first time around.
If you do still write your own implementation then throw it away and use one of the other options before putting it into production use as there will be mistakes that compromise the security to the extent where you probably may as well not have bothered.
Sorry to sound down on all of this, but getting these things right is really hard and not something you can do by just taking a quick look at somebody else's implementation.