Reverse Port Forward using libssh2 on iOS - objective-c

I'm looking for some example code of a reverse port forward on iOS using libssh2. Here's a close example:
Example code of libssh2 being used for port forwarding
But I'd like it to be tailored to iOS and objective-C if possible. Straight C is fine too. I'm wary of the socket and FD code, and would rather have a robust solution than the one I'm hacking up. I've tried RTFMing libssh2 for a while, but it ends up being just RTF Code... and I'm not confident enough in my C code to do this networking part.
EDIT: bounty for a working implementation of ssh with port forwarding on iOS 4.3 (e.g. iphone4, ipad2), doesn't need to be libssh2 in specific.

As it turns out, it's fairly straightforward to migrate the putty source http://www.chiark.greenend.org.uk/~sgtatham/putty/ to ios ...

Related

MacOS Dynamic Port Forwarding (ssh -D)

I want to do ssh -ND 888 root#0.0.0.0 functionality in my macos app can someone please suggest any idea ?
I tried with libSSH but not helpful I want to do SOCKS5 Proxy
Swift or Objective-C both okay, just want something working... Thanks
I had resolved this with SwiftNioSSH
https://github.com/apple/swift-nio-ssh
Its really good repo from Apple, right now in early stage but have really good feature

Connecting to tty port through C++ fails unless you've connected through screen first

I picked up an AUPS-A10-R11 DC UPS, and am working with their API to build some monitoring software for my xen host. Their API runs over the USB connection on the device, which presents itself as /dev/ttyUSB# on the host.
I've got things working fine except for one thing that's puzzling me. When I first power on or reboot the host it's connected to, I can't communicate with the device. However, if I open up a screen connection to it:
screen /dev/ttyUSB0 9600
and then close it (ctrl+a, k) then it will work perfectly fine until the next time that you reboot the host.
Does anyone have any idea as to why I would have to connect to the device over screen first? I've pasted my code here: http://susepaste.org/0b8bb37f . When connecting on a fresh reboot, it stops at the "Read Nothing" section of the if...else clause. After connecting to the device with screen, it works fine.
Any thoughts??
Does anyone have any idea as to why I would have to connect to the device over screen first?
Such behavior is almost always related to incomplete termios initialization by your program.
The ideal program would configure a serial terminal for its purposes, and on exit restore the termios configuration back to the way it found it.
But most programs, including terminal emulation programs such as minicom and apparently screen, simply leave their termios configuration instead of restoring it.
Fortunately for you, this leftover termios configuration fills in the missing pieces that allows your program to access the serial terminal as expected.
Review of "your" code suggests that it was copied from the accepted answer of this question. Based on the number of up-votes, this code apparently works for a lot of people. However the author admits it was written before POSIX standards, and therefore the code should not be considered portable. In other words, your mileage may vary.
Apparently you overlooked the alternative answer which is POSIX compliant. A tested termios configuration for blocking non-canonical mode is in that program.
If you prefer to simplify with the use of the cfmakeraw() macro, then here's another code example.

Send SSH commands from iOS?

The app I am planning to develop involves sending SSH commands from the phone to a server that supports SSH. Is there a library that will help me connect and send commands to an SSH server?
Thanks! I looked at libssh, but a lot of the stuff it used was deprecated in iOS6.
~Carpetfizz
NMSSH works great! I was able to successfully implement this into an iOS project, and get everything to work.
https://github.com/Lejdborg/NMSSH
You can look at this: I expect you'd still need to do a non-trivial bit of work to make it fit into your app, but that should work.

red5phone sound problem

I have installed Red5 Server 0.9.0 and red5phone sip_r53. When i make a call , am not able to hear caller voice but he can hear me clearly. can any one faced similar problem ? please help.
Thanks and Regards,
Seniel
This can be many things! Need more info. From my experience the most likely reasons are fire-walled ports (check iptables rules, make sure you can send udp data to some random ports from remote machine to your host using netcat or something), then goes NAT. Are you behind NAT? If so, is your client NAT-aware, does it require STUN server, etc ?
Also it might be a good idea to check the speaker level on your machine and mic on the remote =)
When I search with keyword "Red5Phone" in Stackoverflow, and just 10 question appeared. :) I think our problems are same.
Hi, sunil. A moment ago, I successfully made a call using red5phone. I was using latest red5phone version from subversion, Red5 0.8.0, and Asterisk win32. I hope you also can make it.
Maybe like tuxxxedo says, it's about your Asterisk configuration.
don't forget put this in your extensions.conf
exten => 55,1,Playback(demo-echotest) ; Let them know what’s going on
exten => 55,2,Echo ; Do the echo test
exten => 55,3,Playback(demo-echodone) ; Let them know it’s over
try it.
I also experiencing this. I tried on Red5 0.9.1 and Chrome browser. I could not hear the voice both way even though dialer end up dialing. When i tried with firefox 5.0 and flash player 10 it worked on from red5phone remote phone but did does not work the other way. If the remote machine does to allow incomming udp as above reader suggest how do we fix this?

Getting Orbited to work with my Twisted app

I can't seem to get Orbited working with my Twisted app. I have a page, served by Twisted (say localhost:8000/page) which includes Orbited.js from the orbited server (localhost:8001/static/Orbited.js). I then have a TCP chat server example running on port 7777. I try to use Orbited.TCPSocket to connect to the chat server:
conn=new Orbited.TCPSocket();
conn.open("localhost", 7777);
conn.send("test\r\n"); //error: bad readyState
It works fine when Orbited is serving the page, but not when twisted serves it from a different port. My orbited.cfg looks like this:
[listen]
http://:8001
[access]
* -> localhost:7777
And before (which worked) I had this in it as well:
[static]
test=index.html
Where index.html was another page grabbing localhost:8001/static/Orbited.js, and was accessed from localhost:8001/test.
How do I need to change my config file to work with requests from my twisted site on another port?
Update
I tried changing Orbited.settings.port to 8001 before trying to open the connection, but I got an error: "unsafe javascript attempt to access frame with url http://localhost:8000/page from frame with url http://localhost:8001/static/xsdrBridge.html#1. Domains, protocols and ports must match."
Hmm, also, I just looked at the orbited wiki, and apparently, setting Orbited.settings.port is exactly what I'm supposed to do. but I'm getting horrible errors
You can call send() only after the connection is in opened state.
Put a handler for .onopen() and do a .send() from there.
I have used Orbited in the past. It works in general but there are several quirks to get it set up and running smoothly. The project itself seems to be in a state of flux (it seems to be moving to node.js). Both of these points lead me to suggest that - if you can avoid it - not to use Orbited.
Are there alternatives that are cleaner? I would say, yes. You can pretty much emulate Orbited with Websockets on stock Twisted. This will clearly work for newer browsers. What about older ones? Well, there are open-source projects that wrap websockets and fall back to flash as a transport for older browsers. The setup works quite well, and actually feels cleaner than using a solution like orbited.
If you check out http://github.com/rlotun/txWebSocket you'll find the current state of Twisted's websocket implementation, as well as an example of how to fall back to flash on older browsers. Hopefully this will be useful enough for you to serve as a drop in replacement to Orbited.