x11vnc: add avahi (aka mDNS/Zeroconf/Bonjour...) support thanks to Diego Petteno. add -find -create

pull/1/head
runge 18 years ago
parent 0016cd4280
commit 241f3ed566

@ -335,6 +335,33 @@ elif test "x$uname_s" = "xDarwin"; then
ld_minus_R="no" ld_minus_R="no"
fi fi
AH_TEMPLATE(HAVE_AVAHI, [Avahi/mDNS client build environment present])
AC_ARG_WITH(avahi,
[ --without-avahi disable support for Avahi/mDNS]
[ --with-avahi=DIR use avahi include/library files in DIR],,)
if test "x$with_avahi" != "xno"; then
printf "checking for avahi... "
if test ! -z "$with_avahi" -a "x$with_avahi" != "xyes"; then
AVAHI_CFLAGS="-I$with_avahi/include"
AVAHI_LIBS="-L$with_avahi/lib -lavahi-common -lavahi-client"
echo "using $with_avahi"
with_avahi=yes
elif pkg-config --atleast-version=0.6.4 avahi-client >/dev/null 2>&1; then
AVAHI_CFLAGS=`pkg-config --cflags avahi-client`
AVAHI_LIBS=`pkg-config --libs avahi-client`
with_avahi=yes
echo yes
else
with_avahi=no
echo no
fi
fi
if test "x$with_avahi" = "xyes"; then
AC_DEFINE(HAVE_AVAHI)
AC_SUBST(AVAHI_CFLAGS)
AC_SUBST(AVAHI_LIBS)
fi
AC_ARG_WITH(jpeg, AC_ARG_WITH(jpeg,
[ --without-jpeg disable support for jpeg] [ --without-jpeg disable support for jpeg]
[ --with-jpeg=DIR use jpeg include/library files in DIR],,) [ --with-jpeg=DIR use jpeg include/library files in DIR],,)

@ -1,3 +1,8 @@
2007-02-12 Karl Runge <runge@karlrunge.com>
* x11vnc: add avahi (aka mDNS/Zeroconf/Bonjour...)
support thanks to Diego Pettenò. -avahi/-mdns.
Add -find and -create FINDISPLAY aliases.
2007-02-11 Karl Runge <runge@karlrunge.com> 2007-02-11 Karl Runge <runge@karlrunge.com>
* x11vnc: add -grabalways, -forcedpms, -clientdpms, and * x11vnc: add -grabalways, -forcedpms, -clientdpms, and
-noserverdpms (ultravnc viewer) for improvements in -noserverdpms (ultravnc viewer) for improvements in

@ -17,11 +17,12 @@ LD_CYGIPC=-lcygipc
endif endif
bin_PROGRAMS=x11vnc bin_PROGRAMS=x11vnc
x11vnc_SOURCES = 8to24.c cleanup.c connections.c cursor.c gui.c help.c inet.c keyboard.c linuxfb.c macosx.c macosxCG.c macosxCGP.c macosxCGS.c options.c pm.c pointer.c rates.c remote.c scan.c screen.c selection.c solid.c sslcmds.c sslhelper.c uinput.c unixpw.c user.c userinput.c util.c v4l.c win_utils.c x11vnc.c x11vnc_defs.c xdamage.c xevents.c xinerama.c xkb_bell.c xrandr.c xrecord.c xwrappers.c 8to24.h allowed_input_t.h blackout_t.h cleanup.h connections.h cursor.h enums.h gui.h help.h inet.h keyboard.h linuxfb.h macosx.h macosxCG.h macosxCGP.h macosxCGS.h nox11.h nox11_funcs.h options.h params.h pm.h pointer.h rates.h remote.h scan.h screen.h scrollevent_t.h selection.h solid.h sslcmds.h sslhelper.h ssltools.h tkx11vnc.h uinput.h unixpw.h user.h userinput.h util.h v4l.h win_utils.h winattr_t.h x11vnc.h xdamage.h xevents.h xinerama.h xkb_bell.h xrandr.h xrecord.h xwrappers.h x11vnc_SOURCES = 8to24.c avahi.c cleanup.c connections.c cursor.c gui.c help.c inet.c keyboard.c linuxfb.c macosx.c macosxCG.c macosxCGP.c macosxCGS.c options.c pm.c pointer.c rates.c remote.c scan.c screen.c selection.c solid.c sslcmds.c sslhelper.c uinput.c unixpw.c user.c userinput.c util.c v4l.c win_utils.c x11vnc.c x11vnc_defs.c xdamage.c xevents.c xinerama.c xkb_bell.c xrandr.c xrecord.c xwrappers.c 8to24.h allowed_input_t.h avahi.h blackout_t.h cleanup.h connections.h cursor.h enums.h gui.h help.h inet.h keyboard.h linuxfb.h macosx.h macosxCG.h macosxCGP.h macosxCGS.h nox11.h nox11_funcs.h options.h params.h pm.h pointer.h rates.h remote.h scan.h screen.h scrollevent_t.h selection.h solid.h sslcmds.h sslhelper.h ssltools.h tkx11vnc.h uinput.h unixpw.h user.h userinput.h util.h v4l.h win_utils.h winattr_t.h x11vnc.h xdamage.h xevents.h xinerama.h xkb_bell.h xrandr.h xrecord.h xwrappers.h
if HAVE_X if HAVE_X
INCLUDES=@X_CFLAGS@ INCLUDES=@X_CFLAGS@ @AVAHI_CFLAGS@
x11vnc_LDADD=$(LDADD) @SSL_LIBS@ @CRYPT_LIBS@ @X_LIBS@ $(LD_CYGIPC) x11vnc_LDADD=$(LDADD) @SSL_LIBS@ @CRYPT_LIBS@ @X_LIBS@ @AVAHI_LIBS@ $(LD_CYGIPC)
else else
x11vnc_LDADD=$(LDADD) @SSL_LIBS@ @CRYPT_LIBS@ $(LD_CYGIPC) INCLUDES=@AVAHI_CFLAGS@
x11vnc_LDADD=$(LDADD) @SSL_LIBS@ @CRYPT_LIBS@ @AVAHI_LIBS@ $(LD_CYGIPC)
endif endif

File diff suppressed because it is too large Load Diff

@ -0,0 +1,207 @@
/* -- avahi.c -- */
#include "x11vnc.h"
void avahi_initialise(void);
void avahi_advertise(const char *name, const char *host, const uint16_t port);
void avahi_reset(void);
void avahi_cleanup(void);
#if !defined(LIBVNCSERVER_HAVE_AVAHI) || !defined(LIBVNCSERVER_HAVE_LIBPTHREAD)
void avahi_initialise(void) {
rfbLog("avahi_initialise: no Avahi support at buildtime.\n");
}
void avahi_advertise(const char *name, const char *host, const uint16_t port) {
if (!name || !host || !port) {}
rfbLog("avahi_advertise: no Avahi support at buildtime.\n");
}
void avahi_reset(void) {
rfbLog("avahi_reset: no Avahi support at buildtime.\n");
}
void avahi_cleanup(void) {
rfbLog("avahi_cleanup: no Avahi support at buildtime.\n");
}
#else
#include <avahi-common/thread-watch.h>
#include <avahi-common/alternative.h>
#include <avahi-client/client.h>
#include <avahi-client/publish.h>
static AvahiThreadedPoll *_poll = NULL;
static AvahiClient *_client = NULL;
static AvahiEntryGroup *_group = NULL;
static int db = 0;
void avahi_initialise(void) {
int ret;
if (getenv("AVAHI_DEBUG")) {
db = 1;
}
if (db) fprintf(stderr, "in avahi_initialise\n");
if (_poll) {
if (db) fprintf(stderr, " avahi_initialise: poll not null\n");
return;
}
if (! (_poll = avahi_threaded_poll_new()) ) {
rfbLog("warning: unable to open Avahi poll.\n");
return;
}
_client = avahi_client_new(avahi_threaded_poll_get(_poll),
0, NULL, NULL, &ret);
if (! _client) {
rfbLog("warning: unable to open Avahi client: %s\n",
avahi_strerror(ret));
avahi_threaded_poll_free(_poll);
_poll = NULL;
return;
}
if (avahi_threaded_poll_start(_poll) < 0) {
rfbLog("warning: unable to start Avahi poll.\n");
avahi_client_free(_client);
_client = NULL;
avahi_threaded_poll_free(_poll);
_poll = NULL;
return;
}
if (db) fprintf(stderr, "out avahi_initialise\n");
}
typedef struct {
const char *name;
const char *host;
uint16_t port;
} avahi_service_t;
static void _avahi_create_services(const char *name, const char *host,
const uint16_t port);
static void _avahi_entry_group_callback(AvahiEntryGroup *g,
AvahiEntryGroupState state, void *userdata) {
char *new_name;
avahi_service_t *svc = (avahi_service_t *)userdata;
if (db) fprintf(stderr, "in _avahi_entry_group_callback %d 0x%p\n", state, svc);
if (g != _group && _group != NULL) {
rfbLog("avahi_entry_group_callback fatal error (group).\n");
clean_up_exit(1);
}
if (userdata == NULL) {
rfbLog("avahi_entry_group_callback fatal error (userdata).\n");
clean_up_exit(1);
}
switch(state) {
case AVAHI_ENTRY_GROUP_ESTABLISHED:
rfbLog("Avahi group %s established.\n", svc->name);
#if 0 /* is this the segv problem? */
free(svc);
#endif
break;
case AVAHI_ENTRY_GROUP_COLLISION:
new_name = avahi_alternative_service_name(svc->name);
_avahi_create_services(new_name, svc->host, svc->port);
rfbLog("Avahi Entry group collision\n");
avahi_free(new_name);
break;
case AVAHI_ENTRY_GROUP_FAILURE:
rfbLog("Avahi Entry group failure: %s\n",
avahi_strerror(avahi_client_errno(
avahi_entry_group_get_client(g))));
break;
}
if (db) fprintf(stderr, "out _avahi_entry_group_callback\n");
}
static void _avahi_create_services(const char *name, const char *host,
const uint16_t port) {
avahi_service_t *svc = (avahi_service_t *)malloc(sizeof(avahi_service_t));
int ret = 0;
if (db) fprintf(stderr, "in _avahi_create_services %s %s %d\n", name, host, port);
svc->name = name;
svc->host = host;
svc->port = port;
if (!_group) {
if (db) fprintf(stderr, " _avahi_create_services create group\n");
_group = avahi_entry_group_new(_client,
_avahi_entry_group_callback, svc);
}
if (!_group) {
rfbLog("avahi_entry_group_new() failed: %s\n",
avahi_strerror(avahi_client_errno(_client)));
return;
}
ret = avahi_entry_group_add_service(_group, AVAHI_IF_UNSPEC,
AVAHI_PROTO_UNSPEC, 0, name, "_rfb._tcp", NULL, NULL, port, NULL);
if (ret < 0) {
rfbLog("Failed to add _rfb._tcp service: %s\n",
avahi_strerror(ret));
return;
}
ret = avahi_entry_group_commit(_group);
if (ret < 0) {
rfbLog("Failed to commit entry_group:: %s\n",
avahi_strerror(ret));
return;
}
if (db) fprintf(stderr, "out _avahi_create_services\n");
}
void avahi_advertise(const char *name, const char *host, const uint16_t port) {
if (db) fprintf(stderr, "in avahi_advertise\n");
if (!_client) {
if (db) fprintf(stderr, " avahi_advertise client null\n");
return;
}
if (_poll == NULL) {
rfbLog("Avahi poll not initialized.\n");
return;
}
avahi_threaded_poll_lock(_poll);
_avahi_create_services(name, host, port >= 5900 ? port : 5900+port);
avahi_threaded_poll_unlock(_poll);
if (db) fprintf(stderr, "out avahi_advertise\n");
}
void avahi_reset(void) {
if (db) fprintf(stderr, "in avahi_reset\n");
if (!_client || !_group) {
if (db) fprintf(stderr, " avahi_reset client/group null\n");
return;
}
avahi_entry_group_reset(_group);
rfbLog("Avahi resetting group.\n");
if (db) fprintf(stderr, "out avahi_reset\n");
}
void avahi_cleanup(void) {
if (db) fprintf(stderr, "in avahi_cleanup\n");
if (!_client) {
if (db) fprintf(stderr, " avahi_cleanup client null\n");
return;
}
avahi_threaded_poll_lock(_poll);
avahi_threaded_poll_stop(_poll);
avahi_client_free(_client);
_client = NULL;
avahi_threaded_poll_free(_poll);
_poll = NULL;
if (db) fprintf(stderr, "out avahi_cleanup\n");
}
#endif

@ -0,0 +1,11 @@
#ifndef _X11VNC_AVAHI_H
#define _X11VNC_AVAHI_H
/* -- avahi.h -- */
extern void avahi_initialise(void);
extern void avahi_advertise(const char *name, const char *host, const uint16_t port);
extern void avahi_reset(void);
extern void avahi_cleanup(void);
#endif /* _X11VNC_AVAHI_H */

@ -14,6 +14,7 @@
#include "connections.h" #include "connections.h"
#include "macosx.h" #include "macosx.h"
#include "macosxCG.h" #include "macosxCG.h"
#include "avahi.h"
/* /*
* Exiting and error handling routines * Exiting and error handling routines
@ -129,6 +130,10 @@ void clean_up_exit (int ret) {
ssl_helper_pid(0, 0); /* killall */ ssl_helper_pid(0, 0); /* killall */
} }
if (avahi) {
avahi_cleanup();
}
#ifdef MACOSX #ifdef MACOSX
if (client_connect_file) { if (client_connect_file) {
if (strstr(client_connect_file, "/tmp/x11vnc-macosx-channel.") if (strstr(client_connect_file, "/tmp/x11vnc-macosx-channel.")

@ -70,8 +70,13 @@ void print_help(int mode) {
"-display disp X11 server display to connect to, usually :0. The X\n" "-display disp X11 server display to connect to, usually :0. The X\n"
" server process must be running on same machine and\n" " server process must be running on same machine and\n"
" support MIT-SHM. Equivalent to setting the DISPLAY\n" " support MIT-SHM. Equivalent to setting the DISPLAY\n"
" environment variable to \"disp\". See the description\n" " environment variable to \"disp\".\n"
" below of the \"-display WAIT:...\" extensions.\n" "\n"
" See the description below of the \"-display WAIT:...\"\n"
" extensions, where alias \"-find\" will find the user's\n"
" display automatically, and \"-create\" will create a\n"
" Xvfb session if no session is found.\n"
"\n"
"-auth file Set the X authority file to be \"file\", equivalent to\n" "-auth file Set the X authority file to be \"file\", equivalent to\n"
" setting the XAUTHORITY environment variable to \"file\"\n" " setting the XAUTHORITY environment variable to \"file\"\n"
" before startup. Same as -xauth file. See Xsecurity(7),\n" " before startup. Same as -xauth file. See Xsecurity(7),\n"
@ -365,6 +370,13 @@ void print_help(int mode) {
"-http_ssl As -http, but force lookup for ssl classes subdir.\n" "-http_ssl As -http, but force lookup for ssl classes subdir.\n"
#endif #endif
"\n" "\n"
"-avahi Use the Avahi/mDNS ZeroConf protocol to advertize\n"
" this VNC server to the local network. (Related terms:\n"
" Rendezvous, Bonjour). Depending on your setup, you\n"
" may need to start avahi-daemon and open udp port 5353\n"
" in your firewall.\n"
"-mdns Same as -avahi.\n"
"\n"
"-connect string For use with \"vncviewer -listen\" reverse connections.\n" "-connect string For use with \"vncviewer -listen\" reverse connections.\n"
" If \"string\" has the form \"host\" or \"host:port\"\n" " If \"string\" has the form \"host\" or \"host:port\"\n"
" the connection is made once at startup. Use commas\n" " the connection is made once at startup. Use commas\n"
@ -711,11 +723,19 @@ void print_help(int mode) {
" in addition to this option.\n" " in addition to this option.\n"
"\n" "\n"
#endif #endif
"-svc Terminal services mode. Also \"-service\", implies\n" "-find Find the user's display using FINDDISPLAY. It is an\n"
" alias for \"-display WAIT:cmd=FINDDISPLAY\".\n"
"\n"
"-create First try to find the user's display using FINDDISPLAY,\n"
" if that doesn't work create an X session via the\n"
" FINDCREATEDISPLAY method. This is an alias for\n"
" \"-display WAIT:cmd=FINDCREATEDISPLAY-Xvfb\".\n"
"\n"
"-svc Terminal services mode. Also \"-service\". Alias for\n"
" -display WAIT:cmd=FINDCREATEDISPLAY-Xvfb -unixpw\n" " -display WAIT:cmd=FINDCREATEDISPLAY-Xvfb -unixpw\n"
" -users unixpw= -ssl SAVE\n" " -users unixpw= -ssl SAVE\n"
"\n" "\n"
"-xdmsvc Terminal services mode. Also \"-xdm_service\", implies\n" "-xdmsvc Terminal services mode. Also \"-xdm_service\". Alias for\n"
" -display WAIT:cmd=FINDCREATEDISPLAY-Xvfb.xdmcp -unixpw\n" " -display WAIT:cmd=FINDCREATEDISPLAY-Xvfb.xdmcp -unixpw\n"
" -users unixpw= -ssl SAVE\n" " -users unixpw= -ssl SAVE\n"
"\n" "\n"
@ -3373,6 +3393,10 @@ void print_help(int mode) {
" nohttp disable http client connections.\n" " nohttp disable http client connections.\n"
" deny deny any new connections, same as \"lock\"\n" " deny deny any new connections, same as \"lock\"\n"
" nodeny allow new connections, same as \"unlock\"\n" " nodeny allow new connections, same as \"unlock\"\n"
" avahi enable avahi service advertizing.\n"
" noavahi disable avahi service advertizing.\n"
" mdns enable avahi service advertizing.\n"
" nomdns disable avahi service advertizing.\n"
/* access, filename */ /* access, filename */
" connect:host do reverse connection to host, \"host\"\n" " connect:host do reverse connection to host, \"host\"\n"
" may be a comma separated list of hosts\n" " may be a comma separated list of hosts\n"
@ -3676,24 +3700,24 @@ void print_help(int mode) {
" nooverlay_yescursor overlay_nocursor 8to24 no8to24\n" " nooverlay_yescursor overlay_nocursor 8to24 no8to24\n"
" 8to24_opts 24to32 no24to32 visual scale scale_cursor\n" " 8to24_opts 24to32 no24to32 visual scale scale_cursor\n"
" viewonly noviewonly shared noshared forever noforever\n" " viewonly noviewonly shared noshared forever noforever\n"
" once timeout filexfer nofilexfer deny lock nodeny\n" " once timeout filexfer nofilexfer deny lock nodeny unlock\n"
" unlock connect allowonce allow localhost nolocalhost\n" " avahi mdns noavahi nomdns connect allowonce allow\n"
" listen lookup nolookup accept afteraccept gone shm\n" " localhost nolocalhost listen lookup nolookup accept\n"
" noshm flipbyteorder noflipbyteorder onetile noonetile\n" " afteraccept gone shm noshm flipbyteorder noflipbyteorder\n"
" solid_color solid nosolid blackout xinerama noxinerama\n" " onetile noonetile solid_color solid nosolid blackout\n"
" xtrap noxtrap xrandr noxrandr xrandr_mode rotate padgeom\n" " xinerama noxinerama xtrap noxtrap xrandr noxrandr\n"
" quiet q noquiet modtweak nomodtweak xkb noxkb capslock\n" " xrandr_mode rotate padgeom quiet q noquiet modtweak\n"
" nocapslock skip_lockkeys noskip_lockkeys skip_keycodes\n" " nomodtweak xkb noxkb capslock nocapslock skip_lockkeys\n"
" sloppy_keys nosloppy_keys skip_dups noskip_dups\n" " noskip_lockkeys skip_keycodes sloppy_keys nosloppy_keys\n"
" add_keysyms noadd_keysyms clear_mods noclear_mods\n" " skip_dups noskip_dups add_keysyms noadd_keysyms\n"
" clear_keys noclear_keys remap repeat norepeat fb nofb\n" " clear_mods noclear_mods clear_keys noclear_keys remap\n"
" bell nobell sel nosel primary noprimary setprimary\n" " repeat norepeat fb nofb bell nobell sel nosel primary\n"
" nosetprimary clipboard noclipboard setclipboard\n" " noprimary setprimary nosetprimary clipboard noclipboard\n"
" nosetclipboard seldir cursorshape nocursorshape\n" " setclipboard nosetclipboard seldir cursorshape\n"
" cursorpos nocursorpos cursor_drag nocursor_drag cursor\n" " nocursorshape cursorpos nocursorpos cursor_drag\n"
" show_cursor noshow_cursor nocursor arrow xfixes\n" " nocursor_drag cursor show_cursor noshow_cursor nocursor\n"
" noxfixes xdamage noxdamage xd_area xd_mem alphacut\n" " arrow xfixes noxfixes xdamage noxdamage xd_area xd_mem\n"
" alphafrac alpharemove noalpharemove alphablend\n" " alphacut alphafrac alpharemove noalpharemove alphablend\n"
" noalphablend xwarppointer xwarp noxwarppointer\n" " noalphablend xwarppointer xwarp noxwarppointer\n"
" noxwarp buttonmap dragging nodragging ncache_cr\n" " noxwarp buttonmap dragging nodragging ncache_cr\n"
" noncache_cr ncache_no_moveraise noncache_no_moveraise\n" " noncache_cr ncache_no_moveraise noncache_no_moveraise\n"

@ -113,6 +113,11 @@ int xform24to32 = 0; /* -24to32 */
char *cmap8to24_str = NULL; char *cmap8to24_str = NULL;
int launch_gui = 0; /* -gui */ int launch_gui = 0; /* -gui */
#ifndef AVAHI
#define AVAHI 0
#endif
int avahi = AVAHI; /* -avahi, -mdns */
int use_modifier_tweak = 1; /* use the shift/altgr modifier tweak */ int use_modifier_tweak = 1; /* use the shift/altgr modifier tweak */
int watch_capslock = 0; /* -capslock */ int watch_capslock = 0; /* -capslock */
int skip_lockkeys = 0; /* -skip_lockkeys */ int skip_lockkeys = 0; /* -skip_lockkeys */

@ -88,6 +88,8 @@ extern char *cmap8to24_str;
extern int xform24to32; extern int xform24to32;
extern int launch_gui; extern int launch_gui;
extern int avahi;
extern int use_modifier_tweak; extern int use_modifier_tweak;
extern int watch_capslock; extern int watch_capslock;
extern int skip_lockkeys; extern int skip_lockkeys;

@ -26,6 +26,7 @@
#include "unixpw.h" #include "unixpw.h"
#include "uinput.h" #include "uinput.h"
#include "userinput.h" #include "userinput.h"
#include "avahi.h"
int send_remote_cmd(char *cmd, int query, int wait); int send_remote_cmd(char *cmd, int query, int wait);
int do_remote_query(char *remote_cmd, char *query_cmd, int remote_sync, int do_remote_query(char *remote_cmd, char *query_cmd, int remote_sync,
@ -1309,6 +1310,29 @@ char *process_remote_cmd(char *cmd, int stringonly) {
rfbLog("remote_cmd: allowing new connections.\n"); rfbLog("remote_cmd: allowing new connections.\n");
deny_all = 0; deny_all = 0;
} else if (!strcmp(p, "avahi") || !strcmp(p, "mdns")) {
if (query) {
snprintf(buf, bufn, "ans=%s:%d", p, avahi);
goto qry;
}
rfbLog("remote_cmd: enable -avahi mDNS mode.\n");
if (!avahi) {
avahi = 1;
avahi_initialise();
avahi_advertise(vnc_desktop_name, this_host(),
screen->port);
}
} else if (!strcmp(p, "noavahi") || !strcmp(p, "nomdns")) {
if (query) {
snprintf(buf, bufn, "ans=%s:%d", p, !avahi);
goto qry;
}
rfbLog("remote_cmd: disable -avahi mDNS mode.\n");
if (avahi) {
avahi = 0;
avahi_reset();
}
} else if (strstr(p, "connect") == p) { } else if (strstr(p, "connect") == p) {
NOTAPP NOTAPP
COLON_CHECK("connect:") COLON_CHECK("connect:")

@ -23,6 +23,7 @@
#include "linuxfb.h" #include "linuxfb.h"
#include "macosx.h" #include "macosx.h"
#include "macosxCG.h" #include "macosxCG.h"
#include "avahi.h"
#include <rfb/rfbclient.h> #include <rfb/rfbclient.h>
@ -2888,6 +2889,13 @@ void initialize_screen(int *argc, char **argv, XImage *fb) {
install_passwds(); install_passwds();
} }
#define DO_AVAHI \
if (avahi) { \
avahi_initialise(); \
avahi_advertise(vnc_desktop_name, host, lport); \
usleep(1000*1000); \
}
void announce(int lport, int ssl, char *iface) { void announce(int lport, int ssl, char *iface) {
char *host = this_host(); char *host = this_host();
@ -2911,17 +2919,20 @@ void announce(int lport, int ssl, char *iface) {
if (lport >= 5900) { if (lport >= 5900) {
snprintf(vnc_desktop_name, sz, "%s:%d", snprintf(vnc_desktop_name, sz, "%s:%d",
host, lport - 5900); host, lport - 5900);
DO_AVAHI
fprintf(stderr, "\n%s %s\n", tvdt, fprintf(stderr, "\n%s %s\n", tvdt,
vnc_desktop_name); vnc_desktop_name);
} else { } else {
snprintf(vnc_desktop_name, sz, "%s:%d", snprintf(vnc_desktop_name, sz, "%s:%d",
host, lport); host, lport);
DO_AVAHI
fprintf(stderr, "\n%s %s\n", tvdt, fprintf(stderr, "\n%s %s\n", tvdt,
vnc_desktop_name); vnc_desktop_name);
} }
} else if (lport >= 5900) { } else if (lport >= 5900) {
snprintf(vnc_desktop_name, sz, "%s:%d", snprintf(vnc_desktop_name, sz, "%s:%d",
host, lport - 5900); host, lport - 5900);
DO_AVAHI
fprintf(stderr, "\n%s %s\n", tvdt, vnc_desktop_name); fprintf(stderr, "\n%s %s\n", tvdt, vnc_desktop_name);
if (lport >= 6000) { if (lport >= 6000) {
rfbLog("possible aliases: %s:%d, " rfbLog("possible aliases: %s:%d, "
@ -2931,6 +2942,7 @@ void announce(int lport, int ssl, char *iface) {
} else { } else {
snprintf(vnc_desktop_name, sz, "%s:%d", snprintf(vnc_desktop_name, sz, "%s:%d",
host, lport); host, lport);
DO_AVAHI
fprintf(stderr, "\n%s %s\n", tvdt, vnc_desktop_name); fprintf(stderr, "\n%s %s\n", tvdt, vnc_desktop_name);
rfbLog("possible alias: %s::%d\n", rfbLog("possible alias: %s::%d\n",
host, lport); host, lport);

@ -123,6 +123,7 @@ Clients
afteraccept: afteraccept:
gone: gone:
vncconnect vncconnect
avahi
-- D -- D
filexfer filexfer
=GAL Java-applet:: =GAL Java-applet::

@ -134,6 +134,7 @@ char gui_code[] = "";
" afteraccept:\n" " afteraccept:\n"
" gone:\n" " gone:\n"
" vncconnect\n" " vncconnect\n"
" avahi\n"
" -- D\n" " -- D\n"
" filexfer\n" " filexfer\n"
" =GAL Java-applet::\n" " =GAL Java-applet::\n"

@ -1382,6 +1382,28 @@ int wait_for_client(int *argc, char** argv, int http) {
keep_unixpw = 1; keep_unixpw = 1;
} }
if (!inetd) {
if (!use_openssl) {
announce(screen->port, use_openssl, NULL);
fprintf(stdout, "PORT=%d\n", screen->port);
} else {
fprintf(stdout, "PORT=%d\n", screen->port);
if (stunnel_port) {
fprintf(stdout, "SSLPORT=%d\n", stunnel_port);
} else if (use_openssl) {
fprintf(stdout, "SSLPORT=%d\n", screen->port);
}
}
fflush(stdout);
} else if (!use_openssl && avahi) {
char *name = rfb_desktop_name;
if (!name) {
name = use_dpy;
}
avahi_initialise();
avahi_advertise(name, this_host(), screen->port);
}
if (inetd && use_openssl) { if (inetd && use_openssl) {
accept_openssl(OPENSSL_INETD); accept_openssl(OPENSSL_INETD);
} }

@ -576,4 +576,3 @@ Window descend_pointer(int depth, Window start, char *name_info, int len) {
#endif /* NO_X11 */ #endif /* NO_X11 */
} }

@ -2,7 +2,7 @@
.TH X11VNC "1" "February 2007" "x11vnc " "User Commands" .TH X11VNC "1" "February 2007" "x11vnc " "User Commands"
.SH NAME .SH NAME
x11vnc - allow VNC connections to real X11 displays x11vnc - allow VNC connections to real X11 displays
version: 0.8.5, lastmod: 2007-02-11 version: 0.8.5, lastmod: 2007-02-12
.SH SYNOPSIS .SH SYNOPSIS
.B x11vnc .B x11vnc
[OPTION]... [OPTION]...
@ -60,8 +60,12 @@ becomes a space character).
X11 server display to connect to, usually :0. The X X11 server display to connect to, usually :0. The X
server process must be running on same machine and server process must be running on same machine and
support MIT-SHM. Equivalent to setting the DISPLAY support MIT-SHM. Equivalent to setting the DISPLAY
environment variable to \fIdisp\fR. See the description environment variable to \fIdisp\fR.
below of the "\fB-display\fR \fIWAIT:...\fR" extensions. .IP
See the description below of the "\fB-display\fR \fIWAIT:...\fR"
extensions, where alias "\fB-find\fR" will find the user's
display automatically, and "\fB-create\fR" will create a
Xvfb session if no session is found.
.PP .PP
\fB-auth\fR \fIfile\fR \fB-auth\fR \fIfile\fR
.IP .IP
@ -432,6 +436,18 @@ to the program location and in standard locations
.IP .IP
As \fB-http,\fR but force lookup for ssl classes subdir. As \fB-http,\fR but force lookup for ssl classes subdir.
.PP .PP
\fB-avahi\fR
.IP
Use the Avahi/mDNS ZeroConf protocol to advertize
this VNC server to the local network. (Related terms:
Rendezvous, Bonjour). Depending on your setup, you
may need to start avahi-daemon and open udp port 5353
in your firewall.
.PP
\fB-mdns\fR
.IP
Same as \fB-avahi.\fR
.PP
\fB-connect\fR \fIstring\fR \fB-connect\fR \fIstring\fR
.IP .IP
For use with "vncviewer -listen" reverse connections. For use with "vncviewer -listen" reverse connections.
@ -843,15 +859,27 @@ is given 3 tries to enter the correct password.
If a list of allowed users is needed use \fB-unixpw\fR [list] If a list of allowed users is needed use \fB-unixpw\fR [list]
in addition to this option. in addition to this option.
.PP .PP
\fB-find\fR
.IP
Find the user's display using FINDDISPLAY. It is an
alias for "\fB-display\fR \fIWAIT:cmd=FINDDISPLAY\fR".
.PP
\fB-create\fR
.IP
First try to find the user's display using FINDDISPLAY,
if that doesn't work create an X session via the
FINDCREATEDISPLAY method. This is an alias for
"\fB-display\fR \fIWAIT:cmd=FINDCREATEDISPLAY-Xvfb\fR".
.PP
\fB-svc\fR \fB-svc\fR
.IP .IP
Terminal services mode. Also "\fB-service\fR", implies Terminal services mode. Also "\fB-service\fR". Alias for
\fB-display\fR WAIT:cmd=FINDCREATEDISPLAY-Xvfb \fB-unixpw\fR \fB-display\fR WAIT:cmd=FINDCREATEDISPLAY-Xvfb \fB-unixpw\fR
\fB-users\fR unixpw= \fB-ssl\fR SAVE \fB-users\fR unixpw= \fB-ssl\fR SAVE
.PP .PP
\fB-xdmsvc\fR \fB-xdmsvc\fR
.IP .IP
Terminal services mode. Also "\fB-xdm_service\fR", implies Terminal services mode. Also "\fB-xdm_service\fR". Alias for
\fB-display\fR WAIT:cmd=FINDCREATEDISPLAY-Xvfb.xdmcp \fB-unixpw\fR \fB-display\fR WAIT:cmd=FINDCREATEDISPLAY-Xvfb.xdmcp \fB-unixpw\fR
\fB-users\fR unixpw= \fB-ssl\fR SAVE \fB-users\fR unixpw= \fB-ssl\fR SAVE
.PP .PP
@ -3976,6 +4004,14 @@ deny deny any new connections, same as "lock"
.IP .IP
nodeny allow new connections, same as "unlock" nodeny allow new connections, same as "unlock"
.IP .IP
avahi enable avahi service advertizing.
.IP
noavahi disable avahi service advertizing.
.IP
mdns enable avahi service advertizing.
.IP
nomdns disable avahi service advertizing.
.IP
connect:host do reverse connection to host, "host" connect:host do reverse connection to host, "host"
may be a comma separated list of hosts may be a comma separated list of hosts
or host:ports. See \fB-connect.\fR Passwords or host:ports. See \fB-connect.\fR Passwords
@ -4511,24 +4547,24 @@ overlay_yescursor nooverlay_nocursor nooverlay_cursor
nooverlay_yescursor overlay_nocursor 8to24 no8to24 nooverlay_yescursor overlay_nocursor 8to24 no8to24
8to24_opts 24to32 no24to32 visual scale scale_cursor 8to24_opts 24to32 no24to32 visual scale scale_cursor
viewonly noviewonly shared noshared forever noforever viewonly noviewonly shared noshared forever noforever
once timeout filexfer nofilexfer deny lock nodeny once timeout filexfer nofilexfer deny lock nodeny unlock
unlock connect allowonce allow localhost nolocalhost avahi mdns noavahi nomdns connect allowonce allow
listen lookup nolookup accept afteraccept gone shm localhost nolocalhost listen lookup nolookup accept
noshm flipbyteorder noflipbyteorder onetile noonetile afteraccept gone shm noshm flipbyteorder noflipbyteorder
solid_color solid nosolid blackout xinerama noxinerama onetile noonetile solid_color solid nosolid blackout
xtrap noxtrap xrandr noxrandr xrandr_mode rotate padgeom xinerama noxinerama xtrap noxtrap xrandr noxrandr
quiet q noquiet modtweak nomodtweak xkb noxkb capslock xrandr_mode rotate padgeom quiet q noquiet modtweak
nocapslock skip_lockkeys noskip_lockkeys skip_keycodes nomodtweak xkb noxkb capslock nocapslock skip_lockkeys
sloppy_keys nosloppy_keys skip_dups noskip_dups noskip_lockkeys skip_keycodes sloppy_keys nosloppy_keys
add_keysyms noadd_keysyms clear_mods noclear_mods skip_dups noskip_dups add_keysyms noadd_keysyms
clear_keys noclear_keys remap repeat norepeat fb nofb clear_mods noclear_mods clear_keys noclear_keys remap
bell nobell sel nosel primary noprimary setprimary repeat norepeat fb nofb bell nobell sel nosel primary
nosetprimary clipboard noclipboard setclipboard noprimary setprimary nosetprimary clipboard noclipboard
nosetclipboard seldir cursorshape nocursorshape setclipboard nosetclipboard seldir cursorshape
cursorpos nocursorpos cursor_drag nocursor_drag cursor nocursorshape cursorpos nocursorpos cursor_drag
show_cursor noshow_cursor nocursor arrow xfixes nocursor_drag cursor show_cursor noshow_cursor nocursor
noxfixes xdamage noxdamage xd_area xd_mem alphacut arrow xfixes noxfixes xdamage noxdamage xd_area xd_mem
alphafrac alpharemove noalpharemove alphablend alphacut alphafrac alpharemove noalpharemove alphablend
noalphablend xwarppointer xwarp noxwarppointer noalphablend xwarppointer xwarp noxwarppointer
noxwarp buttonmap dragging nodragging ncache_cr noxwarp buttonmap dragging nodragging ncache_cr
noncache_cr ncache_no_moveraise noncache_no_moveraise noncache_cr ncache_no_moveraise noncache_no_moveraise

@ -1657,6 +1657,10 @@ int main(int argc, char* argv[]) {
exit(0); exit(0);
} }
} }
} else if (!strcmp(arg, "-find")) {
use_dpy = strdup("WAIT:cmd=FINDDISPLAY");
} else if (!strcmp(arg, "-create")) {
use_dpy = strdup("WAIT:cmd=FINDCREATEDISPLAY-Xvfb");
} else if (!strcmp(arg, "-auth") || !strcmp(arg, "-xauth")) { } else if (!strcmp(arg, "-auth") || !strcmp(arg, "-xauth")) {
CHECK_ARGC CHECK_ARGC
auth_file = strdup(argv[++i]); auth_file = strdup(argv[++i]);
@ -1773,6 +1777,8 @@ int main(int argc, char* argv[]) {
} else if (!strcmp(arg, "-http_ssl")) { } else if (!strcmp(arg, "-http_ssl")) {
try_http = 1; try_http = 1;
http_ssl = 1; http_ssl = 1;
} else if (!strcmp(arg, "-avahi") || !strcmp(arg, "-mdns")) {
avahi = 1;
} else if (!strcmp(arg, "-connect") || } else if (!strcmp(arg, "-connect") ||
!strcmp(arg, "-connect_or_exit")) { !strcmp(arg, "-connect_or_exit")) {
CHECK_ARGC CHECK_ARGC

@ -15,7 +15,7 @@ int xtrap_base_event_type = 0;
int xdamage_base_event_type = 0; int xdamage_base_event_type = 0;
/* date +'lastmod: %Y-%m-%d' */ /* date +'lastmod: %Y-%m-%d' */
char lastmod[] = "0.8.5 lastmod: 2007-02-11"; char lastmod[] = "0.8.5 lastmod: 2007-02-12";
/* X display info */ /* X display info */

Loading…
Cancel
Save