[REBOL] Re: VNC tunnel over Rugby
From: maarten:koopmans:surfnet:nl at: 24-Apr-2002 21:22
OK, here it goes, albeit a rough version....
Here' what to do:
- Put the latest rugby.r and vnc-tunnel.r in one directory on client and
server.
- Start a vnc server on your desktop inside your corporate network.
- Start the vnc-tunnel.r in your rebol console on the viewing side. Type
vnc-client <enter>
- Start the vnc-tunnel script on the server side. Type vnc-server and enter
the ip-address with port 8002 and the http protocol when asked. Aka
http:/your-ip:8002
- Connect the vnc-viewer to the local port 5902.
And no it is not fast on the WAN althoug with tightvnc (www.tightvnc.com) it
may be better. With a bit of luck I'll turn this in to a generic
TCP-over-HTTP tunnel. The point this proves it the limited usefullness of
firewalls. ;-)
--Maarten
-- Attached file included as plaintext by Listar --
-- File: vnc-tunnel.r
REBOL []
do %rugby.r
configure-rugby
[
use compression
set max-threads 1
]
vnc-tunnel: context
[
server-port: none
inpoint: none
outpoint: none
inbuffer: copy {}
outbuffer: copy {}
rugby-url: none
accept-inpoint: func
[
{Sets the inpoint (i.e. the server port on the application client}
i [integer!] {The port number to listen on}
]
[
vnc-tunnel/server-port: open/no-wait/binary/direct join tcp://: i
]
inpoint?: func
[]
[
if not none? wait [ vnc-tunnel/server-port 0.002]
[
vnc-tunnel/inpoint: first server-port
close vnc-tunnel/server-port
if not empty? vnc-tunnel/inbuffer
[
insert vnc-tunnel/inpoint vnc-tunnel/inbuffer
vnc-tunnel/inbuffer: copy {}
]
]
]
initialize-outpoint: func
[
{Sets the outpoint (the application server port that the client
connects to}
u [url!] {The outpoint url}
]
[
vnc-tunnel/outpoint: open/no-wait/binary/direct u
]
set-rugby-url: func
[
u [url!] {The rugby url to connect to}
]
[
vnc-tunnel/rugby-url: u
]
exchange: func
[
s [binary!] {The sent data}
]
[
if none? vnc-tunnel/inpoint
[
inpoint?
]
if not empty? s
[
either none? vnc-tunnel/inpoint
[ append vnc-tunnel/inbuffer s]
[ insert vnc-tunnel/inpoint s ]
]
;Do we have a client connection?
either none? vnc-tunnel/inpoint
[
return {}
]
[
return copy vnc-tunnel/inpoint
]
]
send-vnc-data: func
[
{Sends the data from the outpoint to the inpoint}
/local _rez
]
[
if not none? vnc-tunnel/outpoint
[
_rez: rexec/with compose [ exchange (copy/part vnc-tunnel/outpoint 512000) ]
vnc-tunnel/rugby-url
if not empty? _rez
[
insert vnc-tunnel/outpoint _rez
]
]
]
]
set/any 'exchange get/any in vnc-tunnel 'exchange
vnc-server: does
[
vnc-tunnel/initialize-outpoint tcp://localhost:5901
vnc-tunnel/set-rugby-url to-url ask {What's your Rugby url: }
forever [vnc-tunnel/send-vnc-data ]
]
vnc-client: does
[
vnc-tunnel/accept-inpoint 5902
serve [exchange]
]